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

Props littler.chicken.
See #37186.

git-svn-id: https://develop.svn.wordpress.org/trunk@37952 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2016-07-04 19:33:43 +00:00
parent bc6e877446
commit f7c680e84f
2 changed files with 3 additions and 2 deletions

View File

@ -481,7 +481,7 @@ class WP_Media_List_Table extends WP_List_Table {
?>
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
<?php echo $title ?></a></strong><?php
} elseif ( current_user_can( 'read_post', $post->post_parent ) ) {
} elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
?>
<strong><?php echo $title ?></strong><?php
} else {

View File

@ -3062,11 +3062,12 @@ function wp_prepare_attachment_for_js( $attachment ) {
if ( $post_parent ) {
$parent_type = get_post_type_object( $post_parent->post_type );
if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
$response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
}
if ( current_user_can( 'read_post', $attachment->post_parent ) ) {
if ( $parent_type && current_user_can( 'read_post', $attachment->post_parent ) ) {
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
}
}