Avoid PHP notices in media modal caused by orphaned attachments.

Merges [29724] to the 4.0 branch.

props SergeyBiryukov.
fixes #29566.

Built from https://develop.svn.wordpress.org/branches/4.0@30259


git-svn-id: http://core.svn.wordpress.org/branches/4.0@30259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-11-06 08:16:33 +00:00
parent 8930d00db0
commit 7be0716c9f
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' );