Avoid PHP notices in media modal caused by orphaned attachments.

fixes #29566 for trunk.
Built from https://develop.svn.wordpress.org/trunk@29724


git-svn-id: http://core.svn.wordpress.org/trunk@29498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-09-09 10:03:14 +00:00
parent 092c349443
commit 0113d3457b
2 changed files with 6 additions and 1 deletions

View File

@ -394,7 +394,7 @@ function wp_print_media_templates() {
<span class="name"><?php _e( 'Uploaded By' ); ?></span>
<span class="value">{{ data.authorName }}</span>
</label>
<# if ( data.uploadedTo ) { #>
<# if ( data.uploadedToTitle ) { #>
<label class="setting">
<span class="name"><?php _e( 'Uploaded To' ); ?></span>
<# if ( data.uploadedToLink ) { #>

View File

@ -2643,6 +2643,11 @@ function wp_prepare_attachment_for_js( $attachment ) {
if ( $attachment->post_parent ) {
$post_parent = get_post( $attachment->post_parent );
} else {
$post_parent = false;
}
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' );