WordPress.org

Make WordPress Core

Ticket #27795: 27795.diff

File 27795.diff, 1.9 KB (added by dd32, 7 years ago)
  • src/wp-admin/includes/post.php

     
    162162 *
    163163 * @since 1.5.0
    164164 *
    165165 * @param array $post_data Optional.
    166166 * @return int Post ID.
    167167 */
    168168function edit_post( $post_data = null ) {
    169169
    170170        if ( empty($post_data) )
    171171                $post_data = &$_POST;
    172172
    173173        // Clear out any data in internal vars.
    174174        unset( $post_data['filter'] );
    175175
    176176        $post_ID = (int) $post_data['post_ID'];
    177177        $post = get_post( $post_ID );
    178178        $post_data['post_type'] = $post->post_type;
    179179        $post_data['post_mime_type'] = $post->post_mime_type;
    180180
    181181        if ( ! empty( $post_data['post_status'] ) ) {
    182182                $post_data['post_status'] = sanitize_key( $post_data['post_status'] );
    183183
    184184                if ( 'inherit' == $post_data['post_status'] ) {
    185185                        unset( $post_data['post_status'] );
    186186                }
     187        } else {
     188                $post_data['post_status'] = $post->post_status;
    187189        }
    188190
    189191        $ptype = get_post_type_object($post_data['post_type']);
    190192        if ( !current_user_can( 'edit_post', $post_ID ) ) {
    191193                if ( 'page' == $post_data['post_type'] )
    192194                        wp_die( __('You are not allowed to edit this page.' ));
    193195                else
    194196                        wp_die( __('You are not allowed to edit this post.' ));
    195197        }
    196198
    197199        if ( post_type_supports( $ptype->name, 'revisions' ) ) {
    198200                $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) );
    199201                $revision = current( $revisions );
    200202
    201203                // Check if the revisions have been upgraded
    202204                if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
    203205                        _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
    204206        }
    205207
    206208        if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) {
    207209                $post_data['post_status'] = 'draft';
    208210        }
    209211
    210212        if ( isset($post_data['visibility']) ) {
    211213                switch ( $post_data['visibility'] ) {