Media: Hide 'view' link if empty string passed to attachment_link.

Fix empty href attribute on 'View' link when the `attachment_link` filter is used to hide attachment pages.

Props oh_hello, iqbalrony.
Fixes #54824.
Built from https://develop.svn.wordpress.org/trunk@55218


git-svn-id: http://core.svn.wordpress.org/trunk@54751 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-02-03 22:25:16 +00:00
parent 4efd5d5623
commit e7a506c636
2 changed files with 19 additions and 15 deletions

View File

@ -768,13 +768,15 @@ class WP_Media_List_Table extends WP_List_Table {
}
}
$actions['view'] = sprintf(
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
get_permalink( $post->ID ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ),
__( 'View' )
);
if ( get_permalink( $post->ID ) ) {
$actions['view'] = sprintf(
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
get_permalink( $post->ID ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ),
__( 'View' )
);
}
if ( current_user_can( 'edit_post', $post->ID ) ) {
$actions['attach'] = sprintf(
@ -829,13 +831,15 @@ class WP_Media_List_Table extends WP_List_Table {
}
if ( ! $this->is_trash ) {
$actions['view'] = sprintf(
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
get_permalink( $post->ID ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ),
__( 'View' )
);
if ( get_permalink( $post->ID ) ) {
$actions['view'] = sprintf(
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
get_permalink( $post->ID ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ),
__( 'View' )
);
}
$actions['copy'] = sprintf(
'<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>',

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55217';
$wp_version = '6.2-alpha-55218';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.