]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/post.php
WordPress 3.8.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / post.php
index fea812e0cc92207cd44fc64b16e949a00cf7cc10..983e4e7023d6b78273d8b4cc4a00775e2c4e96be 100644 (file)
@@ -100,10 +100,6 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
                $post_id = false;
        $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
 
-       if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {
-               $post_data['post_status'] = $previous_status ? $previous_status : 'pending';
-       }
-
        $published_statuses = array( 'publish', 'future' );
 
        // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
@@ -115,10 +111,6 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
        if ( ! isset($post_data['post_status']) )
                $post_data['post_status'] = $previous_status;
 
-       if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) {
-               unset( $post_data['post_password'] );
-       }
-
        if (!isset( $post_data['comment_status'] ))
                $post_data['comment_status'] = 'closed';
 
@@ -178,14 +170,6 @@ function edit_post( $post_data = null ) {
        $post_data['post_type'] = $post->post_type;
        $post_data['post_mime_type'] = $post->post_mime_type;
 
-       if ( ! empty( $post_data['post_status'] ) ) {
-               $post_data['post_status'] = sanitize_key( $post_data['post_status'] );
-
-               if ( 'inherit' == $post_data['post_status'] ) {
-                       unset( $post_data['post_status'] );
-               }
-       }
-
        $ptype = get_post_type_object($post_data['post_type']);
        if ( !current_user_can( 'edit_post', $post_ID ) ) {
                if ( 'page' == $post_data['post_type'] )
@@ -203,6 +187,9 @@ function edit_post( $post_data = null ) {
                        _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
        }
 
+       $post_data = _wp_translate_postdata( true, $post_data );
+       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';
        }
@@ -223,10 +210,6 @@ function edit_post( $post_data = null ) {
                }
        }
 
-       $post_data = _wp_translate_postdata( true, $post_data );
-       if ( is_wp_error($post_data) )
-               wp_die( $post_data->get_error_message() );
-
        // Post Formats
        if ( isset( $post_data['post_format'] ) )
                set_post_format( $post_ID, $post_data['post_format'] );
@@ -349,14 +332,6 @@ function bulk_edit_posts( $post_data = null ) {
        }
        unset($post_data['_status']);
 
-       if ( ! empty( $post_data['post_status'] ) ) {
-               $post_data['post_status'] = sanitize_key( $post_data['post_status'] );
-
-               if ( 'inherit' == $post_data['post_status'] ) {
-                       unset( $post_data['post_status'] );
-               }
-       }
-
        $post_IDs = array_map( 'intval', (array) $post_data['post'] );
 
        $reset = array(
@@ -447,26 +422,11 @@ function bulk_edit_posts( $post_data = null ) {
                        unset( $post_data['tax_input']['category'] );
                }
 
-               $post_data['post_type'] = $post->post_type;
                $post_data['post_mime_type'] = $post->post_mime_type;
                $post_data['guid'] = $post->guid;
 
-               foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) {
-                       if ( ! isset( $post_data[ $field ] ) ) {
-                               $post_data[ $field ] = $post->$field;
-                       }
-               }
-
                $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 ) ) {
-                       $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'] )
@@ -609,6 +569,10 @@ function wp_write_post() {
        if ( isset( $_POST['post_ID'] ) )
                return edit_post();
 
+       $translated = _wp_translate_postdata( false );
+       if ( is_wp_error($translated) )
+               return $translated;
+
        if ( isset($_POST['visibility']) ) {
                switch ( $_POST['visibility'] ) {
                        case 'public' :
@@ -625,10 +589,6 @@ function wp_write_post() {
                }
        }
 
-       $translated = _wp_translate_postdata( false );
-       if ( is_wp_error($translated) )
-               return $translated;
-
        // Create the post.
        $post_ID = wp_insert_post( $_POST );
        if ( is_wp_error( $post_ID ) )
@@ -1225,7 +1185,7 @@ function wp_check_post_lock( $post_id ) {
        $time = $lock[0];
        $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
 
-       $time_window = apply_filters( 'wp_check_post_lock_window', 120 );
+       $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
 
        if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
                return $user;