diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js
index 13d46e485b..f0e2a8731d 100644
a
|
b
|
|
205 | 205 | $( '.find-box-inside' ).on( 'click', 'tr', function() { |
206 | 206 | $( this ).find( '.found-radio input' ).prop( 'checked', true ); |
207 | 207 | }); |
| 208 | |
| 209 | // Handles media list copy media URL button |
| 210 | $( '.copy-attachment-url' ).click( function() { |
| 211 | const clipboard = new ClipboardJS( '.copy-attachment-url' ); |
| 212 | const targetElement = $( this ); |
| 213 | clipboard.on( 'success', function( e ) { |
| 214 | // Show visual success |
| 215 | $( targetElement ).text( wp.i18n.__( 'Copied' ) ); |
| 216 | // Announce success |
| 217 | wp.a11y.speak( wp.i18n.__( 'The file URL has been copied to your clipboard' ) ); |
| 218 | // Clear the visual success queue after 3 seconds |
| 219 | setTimeout( function() { |
| 220 | $( targetElement ).text( wp.i18n.__( 'Copy URL' ) ); |
| 221 | }, 3000 ); |
| 222 | }); |
| 223 | }); |
208 | 224 | }); |
209 | 225 | })( jQuery ); |
diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php
index d425bccfbf..98128c7f87 100644
a
|
b
|
class WP_Media_List_Table extends WP_List_Table { |
806 | 806 | esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
807 | 807 | __( 'View' ) |
808 | 808 | ); |
| 809 | |
| 810 | $actions['copy'] = sprintf( |
| 811 | '<button type="button" class="button copy-attachment-url list-media" data-clipboard-text="%s" aria-label="%s">%s</button>', |
| 812 | esc_url( wp_get_attachment_url( $post->ID ) ), |
| 813 | /* translators: %s: Attachment title. */ |
| 814 | esc_attr( sprintf( __( 'Copy URL “%s”' ), $att_title ) ), |
| 815 | __( 'Copy URL' ) |
| 816 | ); |
809 | 817 | } |
810 | 818 | } |
811 | 819 | |
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 8313088e67..3322406d8c 100644
a
|
b
|
function wp_default_scripts( $scripts ) { |
1351 | 1351 | $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); |
1352 | 1352 | |
1353 | 1353 | $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); |
1354 | | $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); |
| 1354 | $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 ); |
1355 | 1355 | $scripts->set_translations( 'media' ); |
1356 | 1356 | |
1357 | 1357 | $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 ); |