Make WordPress Core

Ticket #24258: 24258.diff

File 24258.diff, 1.9 KB (added by adamsilverstein, 11 years ago)
  • wp-includes/link-template.php

     
    302302
    303303        $post = get_post( $post );
    304304
     305        if ( empty( $post ) )
     306                return null;
     307
    305308        if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
    306                 $parent = get_post($post->post_parent);
     309                $parent = get_post( $post->post_parent );
     310
     311        if ( ! empty( $parent ) ) {
    307312                if ( 'page' == $parent->post_type )
    308313                        $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
    309314                else
    310315                        $parentlink = get_permalink( $post->post_parent );
    311316
    312                 if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
     317                if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) )
    313318                        $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
    314319                else
    315320                        $name = $post->post_name;
    316321
    317                 if ( strpos($parentlink, '?') === false )
    318                         $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
     322                if ( strpos( $parentlink, '?' ) === false )
     323                        $link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' );
    319324
    320325                if ( ! $leavename )
    321326                        $link = str_replace( '%postname%', $name, $link );
     327
     328                }
     329
    322330        }
    323331
    324332        if ( ! $link )
  • wp-admin/includes/class-wp-media-list-table.php

     
    302302                break;
    303303
    304304        case 'parent':
    305                 if ( $post->post_parent > 0 ) {
     305                if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) {
    306306                        if ( get_post( $post->post_parent ) ) {
    307307                                $title =_draft_or_post_title( $post->post_parent );
    308308                        }