Media: Only show parent post titles when the user can read said post.
fixes #37186. Built from https://develop.svn.wordpress.org/trunk@37941 git-svn-id: http://core.svn.wordpress.org/trunk@37882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
26c07ed8d9
commit
20b329ba08
|
@ -476,16 +476,18 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||||
if ( $parent ) {
|
if ( $parent ) {
|
||||||
$title = _draft_or_post_title( $post->post_parent );
|
$title = _draft_or_post_title( $post->post_parent );
|
||||||
$parent_type = get_post_type_object( $parent->post_type );
|
$parent_type = get_post_type_object( $parent->post_type );
|
||||||
|
|
||||||
|
if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
|
||||||
?>
|
?>
|
||||||
<strong>
|
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
|
||||||
<?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
|
<?php echo $title ?></a></strong><?php
|
||||||
<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
|
} elseif ( current_user_can( 'read_post', $post->post_parent ) ) {
|
||||||
<?php echo $title ?></a><?php
|
?>
|
||||||
|
<strong><?php echo $title ?></strong><?php
|
||||||
} else {
|
} else {
|
||||||
echo $title;
|
_e( '(Private post)' );
|
||||||
} ?></strong>
|
}
|
||||||
<br />
|
|
||||||
<?php
|
|
||||||
if ( $user_can_edit ):
|
if ( $user_can_edit ):
|
||||||
$detach_url = add_query_arg( array(
|
$detach_url = add_query_arg( array(
|
||||||
'parent_post_id' => $post->post_parent,
|
'parent_post_id' => $post->post_parent,
|
||||||
|
@ -493,7 +495,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||||
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
|
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
|
||||||
), 'upload.php' );
|
), 'upload.php' );
|
||||||
printf(
|
printf(
|
||||||
'<a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>',
|
'<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>',
|
||||||
$detach_url,
|
$detach_url,
|
||||||
/* translators: %s: title of the post the attachment is attached to */
|
/* translators: %s: title of the post the attachment is attached to */
|
||||||
esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ),
|
esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ),
|
||||||
|
@ -501,11 +503,11 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
} else {
|
} else {
|
||||||
_e( '(Unattached)' ); ?><br />
|
_e( '(Unattached)' ); ?>
|
||||||
<?php if ( $user_can_edit ) {
|
<?php if ( $user_can_edit ) {
|
||||||
$title = _draft_or_post_title( $post->post_parent );
|
$title = _draft_or_post_title( $post->post_parent );
|
||||||
printf(
|
printf(
|
||||||
'<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js" aria-label="%s">%s</a>',
|
'<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js" aria-label="%s">%s</a>',
|
||||||
$post->ID,
|
$post->ID,
|
||||||
/* translators: %s: attachment title */
|
/* translators: %s: attachment title */
|
||||||
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ),
|
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ),
|
||||||
|
|
|
@ -3065,7 +3065,10 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
||||||
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' );
|
||||||
}
|
}
|
||||||
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
|
|
||||||
|
if ( current_user_can( 'read_post', $attachment->post_parent ) ) {
|
||||||
|
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$attached_file = get_attached_file( $attachment->ID );
|
$attached_file = get_attached_file( $attachment->ID );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-beta1-37940';
|
$wp_version = '4.6-beta1-37941';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue