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.
Built from https://develop.svn.wordpress.org/trunk@29320


git-svn-id: http://core.svn.wordpress.org/trunk@29101 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-29 01:41:16 +00:00
parent 0ae76229ec
commit 3f3395a086
3 changed files with 10 additions and 3 deletions

View File

@ -370,7 +370,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
$parent_type = get_post_type_object( $parent->post_type );
?>
<td <?php echo $attributes ?>><strong>
<?php if ( current_user_can( 'edit_post', $post->post_parent ) && $parent_type && $parent_type->show_ui ) { ?>
<?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
<?php echo $title ?></a><?php
} else {

View File

@ -395,7 +395,11 @@ function wp_print_media_templates() {
<# if ( data.uploadedTo ) { #>
<label class="setting">
<span class="name"><?php _e( 'Uploaded To' ); ?></span>
<span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
<# if ( data.uploadedToLink ) { #>
<span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span>
<# } else { #>
<span class="value">{{ data.uploadedToTitle }}</span>
<# } #>
</label>
<# } #>
<div class="attachment-compat"></div>

View File

@ -2636,7 +2636,10 @@ function wp_prepare_attachment_for_js( $attachment ) {
if ( $attachment->post_parent ) {
$post_parent = get_post( $attachment->post_parent );
$response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
$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' );
}
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' );
}