Changeset 14886
- Timestamp:
- 05/25/2010 03:32:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r14869 r14886 849 849 $c = 0; 850 850 $pid = (int) $_POST['post_id']; 851 $post = get_post( $pid ); 852 851 853 if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { 852 854 if ( !current_user_can( 'edit_post', $pid ) ) … … 854 856 if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) 855 857 die('1'); 856 if ( $pid < 0 ) { 858 if ( $post->post_status == 'auto-draft' ) { 859 $save_POST = $_POST; // Backup $_POST 860 $_POST = array(); // Make it empty for edit_post() 861 $_POST['action'] = 'draft'; // Warning fix 862 $_POST['post_ID'] = $pid; 863 $_POST['post_type'] = $post->post_type; 864 $_POST['post_status'] = 'draft'; 857 865 $now = current_time('timestamp', 1); 858 if ( $pid = wp_insert_post( array(859 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) 860 )) ) {866 $_POST['post_title'] = sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)); 867 868 if ( $pid = edit_post() ) { 861 869 if ( is_wp_error( $pid ) ) { 862 870 $x = new WP_Ajax_Response( array( … … 866 874 $x->send(); 867 875 } 876 $_POST = $save_POST; // Now we can restore original $_POST again 868 877 if ( !$mid = add_meta( $pid ) ) 869 878 die(__('Please provide a custom field value.'));
Note: See TracChangeset
for help on using the changeset viewer.