Make WordPress Core


Ignore:
Timestamp:
05/07/2013 11:46:35 AM (13 years ago)
Author:
SergeyBiryukov
Message:

Avoid PHP notices in Media Library if an attachment parent does not exist. props trepmal, viniciusmassuchetto, alex-ye, adamsilverstein for initial patches. fixes #22312. fixes #23154.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r23660 r24182  
    302302
    303303    $post = get_post( $post );
    304 
    305     if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
    306         $parent = get_post($post->post_parent);
     304    $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
     305
     306    if ( $wp_rewrite->using_permalinks() && $parent ) {
    307307        if ( 'page' == $parent->post_type )
    308308            $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
Note: See TracChangeset for help on using the changeset viewer.