WordPress 3.8.3
[autoinstalls/wordpress.git] / wp-admin / includes / post.php
index bd624979caf0016c962360cc25da17ec9ad984ca..11aa9cf8f568b96a63b503e5e3603c08604c361d 100644 (file)
@@ -203,10 +203,6 @@ function edit_post( $post_data = null ) {
                        _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
        }
 
-       if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) {
-               $post_data['post_status'] = 'draft';
-       }
-
        if ( isset($post_data['visibility']) ) {
                switch ( $post_data['visibility'] ) {
                        case 'public' :
@@ -227,6 +223,10 @@ function edit_post( $post_data = null ) {
        if ( is_wp_error($post_data) )
                wp_die( $post_data->get_error_message() );
 
+       if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) {
+               $post_data['post_status'] = 'draft';
+       }
+
        // Post Formats
        if ( isset( $post_data['post_format'] ) )
                set_post_format( $post_ID, $post_data['post_format'] );
@@ -411,7 +411,12 @@ function bulk_edit_posts( $post_data = null ) {
        }
 
        $updated = $skipped = $locked = array();
+       $shared_post_data = $post_data;
+
        foreach ( $post_IDs as $post_ID ) {
+               // Start with fresh post data with each iteration.
+               $post_data = $shared_post_data;
+
                $post_type_object = get_post_type_object( get_post_type( $post_ID ) );
 
                if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) {
@@ -460,13 +465,13 @@ function bulk_edit_posts( $post_data = null ) {
                $post_data['ID'] = $post_ID;
                $post_data['post_ID'] = $post_ID;
 
-               $translated_post_data = _wp_translate_postdata( true, $post_data );
-               if ( is_wp_error( $translated_post_data ) ) {
+               $post_data = _wp_translate_postdata( true, $post_data );
+               if ( is_wp_error( $post_data ) ) {
                        $skipped[] = $post_ID;
                        continue;
                }
 
-               $updated[] = wp_update_post( $translated_post_data );
+               $updated[] = wp_update_post( $post_data );
 
                if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
                        if ( 'sticky' == $post_data['sticky'] )