WordPress.org

Make WordPress Core

Ticket #15041: page-auto-draft-fix.2.diff

File page-auto-draft-fix.2.diff, 806 bytes (added by SergeyBiryukov, 3 years ago)

Moved the check to the proper place

  • wp-includes/link-template.php

     
    185185 
    186186        $slug = $post->post_name; 
    187187 
    188         $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); 
     188        $draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); 
    189189 
    190190        $post_type = get_post_type_object($post->post_type); 
    191191 
    192         if ( !empty($post_link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { 
     192        if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) { 
    193193                if ( ! $leavename ) { 
    194194                        if ( $post_type->hierarchical ) 
    195195                                $slug = get_page_uri($id);