Media: Only show “Copy” and “Download” actions when an attachment URL is available.
Includes unit tests to verify the logic for displaying row actions in the Media Library in certain scenarios, e.g. with and without the “Trash” or “Unattached” filter. Follow-up to [55949]. Props costdev, kebbet, mukesh27, oglekler. Fixes #57893. Built from https://develop.svn.wordpress.org/trunk@56072 git-svn-id: http://core.svn.wordpress.org/trunk@55584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
955720d678
commit
26a0bf0049
|
@ -816,23 +816,27 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
);
|
||||
}
|
||||
|
||||
$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>',
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
|
||||
__( 'Copy URL' ),
|
||||
__( 'Copied!' )
|
||||
);
|
||||
if ( $attachment_url ) {
|
||||
$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>',
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
|
||||
__( 'Copy URL' ),
|
||||
__( 'Copied!' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$actions['download'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" download>%s</a>',
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
|
||||
__( 'Download file' )
|
||||
);
|
||||
if ( $attachment_url ) {
|
||||
$actions['download'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" download>%s</a>',
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
|
||||
__( 'Download file' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $this->detached && current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$actions['attach'] = sprintf(
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-56071';
|
||||
$wp_version = '6.3-alpha-56072';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue