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

Props littler.chicken.
See #37186.
Built from https://develop.svn.wordpress.org/trunk@37952


git-svn-id: http://core.svn.wordpress.org/trunk@37893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2016-07-04 19:34:28 +00:00
parent a7bbdb23cc
commit e64b88cb34
3 changed files with 4 additions and 3 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)' );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta1-37951';
$wp_version = '4.6-beta1-37952';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.