Make WordPress Core


Ignore:
Timestamp:
04/25/2011 01:01:34 AM (15 years ago)
Author:
azaozz
Message:

Distraction Free Writing mode, see #17136

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r17640 r17695  
    14691469        die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
    14701470        break;
     1471case 'wp-fullscreen-save-post' :
     1472        if ( isset($_POST['post_ID']) )
     1473                $post_id = (int) $_POST['post_ID'];
     1474        else
     1475                $post_id = 0;
     1476
     1477        $post = null;
     1478        $post_type_object = null;
     1479        $post_type = null;
     1480        if ( $post_id ) {
     1481                $post = get_post($post_id);
     1482                if ( $post ) {
     1483                        $post_type_object = get_post_type_object($post->post_type);
     1484                        if ( $post_type_object ) {
     1485                                $post_type = $post->post_type;
     1486                                $current_screen->post_type = $post->post_type;
     1487                                $current_screen->id = $current_screen->post_type;
     1488                        }
     1489                }
     1490        } elseif ( isset($_POST['post_type']) ) {
     1491                $post_type_object = get_post_type_object($_POST['post_type']);
     1492                if ( $post_type_object ) {
     1493                        $post_type = $post_type_object->name;
     1494                        $current_screen->post_type = $post_type;
     1495                        $current_screen->id = $current_screen->post_type;
     1496                }
     1497        }
     1498
     1499        check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');
     1500
     1501        $post_id = edit_post();
     1502
     1503        if ( is_wp_error($post_id) ) {
     1504                if ( $post_id->get_error_message() )
     1505                        $message = $post_id->get_error_message();
     1506                else
     1507                        $message = __('Save failed');
     1508
     1509                echo json_encode( array( 'message' => $message, 'last_edited' => '' ) );
     1510                die();
     1511        } else {
     1512                $message = __('Saved.');
     1513        }
     1514
     1515        if ( $post ) {
     1516                $last_date = mysql2date( get_option('date_format'), $post->post_modified );
     1517                $last_time = mysql2date( get_option('time_format'), $post->post_modified );
     1518        } else {
     1519                $last_date = date_i18n( get_option('date_format') );
     1520                $last_time = date_i18n( get_option('time_format') );
     1521        }
     1522
     1523        if ( $last_id = get_post_meta($post_id, '_edit_last', true) ) {
     1524                $last_user = get_userdata($last_id);
     1525                $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
     1526        } else {
     1527                $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
     1528        }
     1529
     1530        echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );
     1531        die();
     1532        break;
    14711533default :
    14721534        do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset for help on using the changeset viewer.