wp_ajax_wp_fullscreen_save_post

The timeline below displays how wordpress function wp_ajax_wp_fullscreen_save_post has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Handles saving posts from the fullscreen editor via AJAX.
 *
 * @since 3.1.0
 * @deprecated 4.3.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(__('F j, Y'), $post->post_modified);
        $last_time = mysql2date(__('g:i a'), $post->post_modified);
    } else {
        $last_date = date_i18n(__('F j, Y'));
        $last_time = date_i18n(__('g:i a'));
    }
    $last_id = get_post_meta($post_id, '_edit_last', true);
    if ($last_id) {
        $last_user = get_userdata($last_id);
        /* translators: 1: User's display name, 2: Date of last edit, 3: Time of last edit. */
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        /* translators: 1: Date of last edit, 2: Time of last edit. */
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 5.3

/**
 * Ajax handler for saving posts from the fullscreen editor.
 *
 * @since 3.1.0
 * @deprecated 4.3.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(__('F j, Y'), $post->post_modified);
        $last_time = mysql2date(__('g:i a'), $post->post_modified);
    } else {
        $last_date = date_i18n(__('F j, Y'));
        $last_time = date_i18n(__('g:i a'));
    }
    $last_id = get_post_meta($post_id, '_edit_last', true);
    if ($last_id) {
        $last_user = get_userdata($last_id);
        /* translators: 1: User's display name, 2: Date of last edit, 3: Time of last edit. */
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        /* translators: 1: Date of last edit, 2: Time of last edit. */
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 5.1

/**
 * Ajax handler for saving posts from the fullscreen editor.
 *
 * @since 3.1.0
 * @deprecated 4.3.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(__('F j, Y'), $post->post_modified);
        $last_time = mysql2date(__('g:i a'), $post->post_modified);
    } else {
        $last_date = date_i18n(__('F j, Y'));
        $last_time = date_i18n(__('g:i a'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        /* translators: 1: display_name of last user, 2: date of last edit, 3: time of last edit. */
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        /* translators: 1: date of last edit, 2: time of last edit. */
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 4.5

/**
 * Ajax handler for saving posts from the fullscreen editor.
 *
 * @since 3.1.0
 * @deprecated 4.3.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(__('F j, Y'), $post->post_modified);
        $last_time = mysql2date(__('g:i a'), $post->post_modified);
    } else {
        $last_date = date_i18n(__('F j, Y'));
        $last_time = date_i18n(__('g:i a'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 4.3

/**
 * Ajax handler for saving posts from the fullscreen editor.
 *
 * @since 3.1.0
 * @deprecated 4.3.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(get_option('date_format'), $post->post_modified);
        $last_time = mysql2date(get_option('time_format'), $post->post_modified);
    } else {
        $last_date = date_i18n(get_option('date_format'));
        $last_time = date_i18n(get_option('time_format'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 4.0

/**
 * Ajax handler for saving posts from the fullscreen editor.
 *
 * @since 3.1.0
 */
function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(get_option('date_format'), $post->post_modified);
        $last_time = mysql2date(get_option('time_format'), $post->post_modified);
    } else {
        $last_date = date_i18n(get_option('date_format'));
        $last_time = date_i18n(get_option('time_format'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 3.9

function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = $post_type = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    if ($post) {
        $post_type = $post->post_type;
    } elseif (isset($_POST['post_type']) && post_type_exists($_POST['post_type'])) {
        $post_type = $_POST['post_type'];
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        wp_send_json_error();
    }
    if ($post) {
        $last_date = mysql2date(get_option('date_format'), $post->post_modified);
        $last_time = mysql2date(get_option('time_format'), $post->post_modified);
    } else {
        $last_date = date_i18n(get_option('date_format'));
        $last_time = date_i18n(get_option('time_format'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    wp_send_json_success(array('last_edited' => $last_edited));
}

WordPress Version: 3.7

function wp_ajax_wp_fullscreen_save_post()
{
    $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
    $post = $post_type = null;
    if ($post_id) {
        $post = get_post($post_id);
    }
    if ($post) {
        $post_type = $post->post_type;
    } elseif (isset($_POST['post_type']) && post_type_exists($_POST['post_type'])) {
        $post_type = $_POST['post_type'];
    }
    check_ajax_referer('update-post_' . $post_id, '_wpnonce');
    $post_id = edit_post();
    if (is_wp_error($post_id)) {
        if ($post_id->get_error_message()) {
            $message = $post_id->get_error_message();
        } else {
            $message = __('Save failed');
        }
        echo json_encode(array('message' => $message, 'last_edited' => ''));
        wp_die();
    } else {
        $message = __('Saved.');
    }
    if ($post) {
        $last_date = mysql2date(get_option('date_format'), $post->post_modified);
        $last_time = mysql2date(get_option('time_format'), $post->post_modified);
    } else {
        $last_date = date_i18n(get_option('date_format'));
        $last_time = date_i18n(get_option('time_format'));
    }
    if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
        $last_user = get_userdata($last_id);
        $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
    } else {
        $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
    }
    echo json_encode(array('message' => $message, 'last_edited' => $last_edited));
    wp_die();
}