WordPress.org

Make WordPress Core

Changeset 37952


Ignore:
Timestamp:
07/04/2016 07:33:43 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Media: Avoid PHP notices when trying to show a parent post title of an orphaned post type.

Props littler.chicken.
See #37186.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r37941 r37952  
    482482                <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
    483483                    <?php echo $title ?></a></strong><?php
    484             } elseif ( current_user_can( 'read_post', $post->post_parent ) ) {
     484            } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
    485485?>
    486486                <strong><?php echo $title ?></strong><?php
  • trunk/src/wp-includes/media.php

    r37941 r37952  
    30633063    if ( $post_parent ) {
    30643064        $parent_type = get_post_type_object( $post_parent->post_type );
     3065
    30653066        if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
    30663067            $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
    30673068        }
    30683069
    3069         if ( current_user_can( 'read_post', $attachment->post_parent ) ) {
     3070        if ( $parent_type && current_user_can( 'read_post', $attachment->post_parent ) ) {
    30703071            $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
    30713072        }
Note: See TracChangeset for help on using the changeset viewer.