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-admin/includes/class-wp-media-list-table.php

    r23430 r24182  
    303303
    304304        case 'parent':
    305                 if ( $post->post_parent > 0 ) {
    306                         if ( get_post( $post->post_parent ) ) {
    307                                 $title =_draft_or_post_title( $post->post_parent );
    308                         }
     305                if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) {
     306                        $title = _draft_or_post_title( $post->post_parent );
    309307?>
    310308                        <td <?php echo $attributes ?>><strong>
    311                                 <?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
     309                                <?php if ( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
    312310                                        <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
    313311                                                <?php echo $title ?></a><?php
    … …  
    321319?>
    322320                        <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
    323                         <?php if( $user_can_edit ) {?>
     321                        <?php if ( $user_can_edit ) { ?>
    324322                                <a class="hide-if-no-js"
    325323                                        onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
Note: See TracChangeset for help on using the changeset viewer.