Make WordPress Core


Ignore:
Timestamp:
07/29/2014 01:40:24 AM (10 years ago)
Author:
SergeyBiryukov
Message:

Avoid PHP notices in Media Library if an attachment parent post type no longer exists.

Synchronize the 'edit_post' capability check between the list table and the media grid.

fixes #27446.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r29281 r29320  
    26372637    if ( $attachment->post_parent ) {
    26382638        $post_parent = get_post( $attachment->post_parent );
    2639         $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
     2639        $parent_type = get_post_type_object( $post_parent->post_type );
     2640        if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
     2641            $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
     2642        }
    26402643        $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' );
    26412644    }
Note: See TracChangeset for help on using the changeset viewer.