Make WordPress Core


Ignore:
Timestamp:
05/08/2008 05:25:07 PM (18 years ago)
Author:
ryan
Message:

Move autosave to post revisions. Props mdawaffe. see #6775

File:
1 edited

Legend:

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

    r7777 r7907  
    462462    define( 'DOING_AUTOSAVE', true );
    463463
    464     $nonce_age = check_ajax_referer( 'autosave', 'autosavenonce');
     464    $nonce_age = check_ajax_referer( 'autosave', 'autosavenonce' );
    465465    global $current_user;
    466466
    467     $_POST['post_status'] = 'draft';
    468467    $_POST['post_category'] = explode(",", $_POST['catslist']);
    469468    $_POST['tags_input'] = explode(",", $_POST['tags_input']);
     
    479478    $supplemental = array();
    480479
    481     $id = 0;
     480    $id = $revision_id = 0;
    482481    if($_POST['post_ID'] < 0) {
     482        $_POST['post_status'] = 'draft';
    483483        $_POST['temp_ID'] = $_POST['post_ID'];
    484484        if ( $do_autosave ) {
     
    511511                die(__('You are not allowed to edit this post.'));
    512512        }
     513
    513514        if ( $do_autosave ) {
    514             $id = edit_post();
     515            // Drafts are just overwritten by autosave
     516            if ( 'draft' == $post->post_status ) {
     517                $id = edit_post();
     518            } else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
     519                $revision_id = wp_create_autosave( $post->ID );
     520                if ( is_wp_error($revision_id) )
     521                    $id = $revision_id;
     522                else
     523                    $id = $post->ID;
     524            }
    515525            $data = $message;
    516526        } else {
Note: See TracChangeset for help on using the changeset viewer.