Avoid PHP notices in media modal caused by orphaned attachments.
fixes #29566 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@29724 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7ce9d697c6
commit
00bfc5bc34
@ -394,7 +394,7 @@ function wp_print_media_templates() {
|
|||||||
<span class="name"><?php _e( 'Uploaded By' ); ?></span>
|
<span class="name"><?php _e( 'Uploaded By' ); ?></span>
|
||||||
<span class="value">{{ data.authorName }}</span>
|
<span class="value">{{ data.authorName }}</span>
|
||||||
</label>
|
</label>
|
||||||
<# if ( data.uploadedTo ) { #>
|
<# if ( data.uploadedToTitle ) { #>
|
||||||
<label class="setting">
|
<label class="setting">
|
||||||
<span class="name"><?php _e( 'Uploaded To' ); ?></span>
|
<span class="name"><?php _e( 'Uploaded To' ); ?></span>
|
||||||
<# if ( data.uploadedToLink ) { #>
|
<# if ( data.uploadedToLink ) { #>
|
||||||
|
@ -2643,6 +2643,11 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
|||||||
|
|
||||||
if ( $attachment->post_parent ) {
|
if ( $attachment->post_parent ) {
|
||||||
$post_parent = get_post( $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 );
|
$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 ) ) {
|
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['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
|
||||||
|
Loading…
Reference in New Issue
Block a user