Make WordPress Core


Ignore:
Timestamp:
08/11/2006 03:54:45 AM (18 years ago)
Author:
ryan
Message:

Autosave and prototype. Props masquerade. fixes #3020 #3017

File:
1 edited

Legend:

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

    r4042 r4082  
    217217    die($r);
    218218    break;
     219case 'autosave' :
     220    $_POST['post_content'] = $_POST['content'];
     221    $_POST['post_excerpt'] = $_POST['excerpt'];
     222    $_POST['post_status'] = 'draft';
     223    $_POST['post_category'] = explode(",", $_POST['catslist']);
     224    if($_POST['post_type'] == 'page' || empty($_POST['post_category']))
     225        unset($_POST['post_category']);
     226   
     227    if($_POST['post_ID'] < 0) {
     228        $_POST['temp_ID'] = $_POST['post_ID'];
     229        $id = wp_write_post();
     230        if(is_wp_error($id))
     231            die($id->get_error_message());
     232        else
     233            die("$id");
     234    } else {
     235        $post_ID = (int) $_POST['post_ID'];
     236        $_POST['ID'] = $post_ID;
     237        $post = get_post($post_ID);
     238        if ( 'page' == $post->post_type ) {
     239            if ( !current_user_can('edit_page', $post_ID) )
     240                die(__('You are not allowed to edit this page.'));
     241        } else {
     242            if ( !current_user_can('edit_post', $post_ID) )
     243                die(__('You are not allowed to edit this post.'));
     244        }
     245        wp_update_post($_POST);
     246    }
     247    die('0');
     248break;
    219249default :
    220250    do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset for help on using the changeset viewer.