Changeset 51023
- Timestamp:
- 05/26/2021 01:39:47 AM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/vendor/plupload/handlers.js
r48288 r51023 362 362 } 363 363 364 /** 365 * Copies the attachment URL to the clipboard. 366 * 367 * @since 5.8.0 368 * 369 * @param {MouseEvent} event A click event. 370 * 371 * @return {void} 372 */ 373 function copyAttachmentUploadURLClipboard() { 374 var clipboard = new ClipboardJS( '.copy-attachment-url' ), 375 successTimeout; 376 clipboard.on( 'success', function( event ) { 377 var triggerElement = jQuery( event.trigger ), 378 successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); 379 // Clear the selection and move focus back to the trigger. 380 event.clearSelection(); 381 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 382 triggerElement.trigger( 'focus' ); 383 // Show success visual feedback. 384 clearTimeout( successTimeout ); 385 successElement.removeClass( 'hidden' ); 386 // Hide success visual feedback after 3 seconds since last success. 387 successTimeout = setTimeout( function() { 388 successElement.addClass( 'hidden' ); 389 }, 3000 ); 390 // Handle success audible feedback. 391 wp.a11y.speak( pluploadL10n.file_url_copied ); 392 } ); 393 } 394 364 395 jQuery( document ).ready( function( $ ) { 396 copyAttachmentUploadURLClipboard(); 365 397 var tryAgainCount = {}; 366 398 var tryAgain; -
trunk/src/wp-admin/async-upload.php
r50505 r51023 49 49 switch ( $_REQUEST['fetch'] ) { 50 50 case 3: 51 echo '<div class="attachment-details">'; 51 52 $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ); 52 53 if ( $thumb_url ) { 53 54 echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />'; 54 55 } 55 if ( current_user_can( 'edit_post', $id ) ) { 56 echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>'; 57 } else { 58 echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>'; 59 } 56 // Title shouldn't ever be empty, but use filename just in case. 57 $file = get_attached_file( $post->ID ); 58 $fileurl = wp_get_attachment_url( $post->ID ); 59 $title = $post->post_title ? $post->post_title : wp_basename( $file ); 60 60 61 // Title shouldn't ever be empty, but use filename just in case. 62 $file = get_attached_file( $post->ID ); 63 $title = $post->post_title ? $post->post_title : wp_basename( $file ); 64 echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</span></div>'; 61 echo '<div class="filename new"><span class="media-list-title"><strong>' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</strong></span> <span class="media-list-subtitle">' . basename( $file ) . '</span></div>'; 62 echo '</div>'; 63 ?> 64 <div class="attachment-tools"> 65 <span class="media-item-copy-container copy-to-clipboard-container edit-attachment"> 66 <button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $fileurl; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button> 67 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 68 </span> 69 <?php 70 if ( current_user_can( 'edit_post', $id ) ) { 71 echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>'; 72 } else { 73 echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>'; 74 } 75 ?> 76 </div> 77 <?php 65 78 break; 66 79 case 2: -
trunk/src/wp-admin/css/media.css
r50829 r51023 52 52 } 53 53 54 .media-list-subtitle { 55 display: block; 56 } 57 58 .media-list-title { 59 display: block; 60 } 61 54 62 #wpbody-content #async-upload-wrap a { 55 63 display: none; … … 97 105 } 98 106 99 .media-item .edit-attachment,100 107 .describe-toggle-on, 101 108 .describe-toggle-off { … … 106 113 } 107 114 115 .media-item { 116 display: grid; 117 grid-template-columns: repeat( 2, 1fr ); 118 } 119 120 .media-item .attachment-tools { 121 display: flex; 122 justify-content: flex-end; 123 align-items: center; 124 } 125 126 .media-item .edit-attachment { 127 padding: 14px 0; 128 display: block; 129 margin-right: 10px; 130 } 131 132 .media-item .edit-attachment.copy-to-clipboard-container { 133 margin-top: 0; 134 } 135 136 .media-item-copy-container .success { 137 line-height: 0; 138 } 139 140 .media-item button .copy-attachment-url { 141 margin-top:14px; 142 } 143 144 .media-item .copy-to-clipboard-container { 145 margin-top:7px; 146 } 147 108 148 .media-item .describe-toggle-off, 109 149 .media-item.open .describe-toggle-on { … … 116 156 117 157 .media-upload-form .media-item { 118 min-height: 36px;158 min-height: 70px; 119 159 margin-bottom: 1px; 120 160 position: relative; … … 133 173 134 174 .media-item .filename { 135 line-height: 2.76923076;175 padding: 14px 0; 136 176 overflow: hidden; 137 177 margin-left: 6px; … … 140 180 .media-item .pinkynail { 141 181 float: left; 142 margin: 2px 10px 0 3px;143 max- width: 40px;144 max- height: 32px;182 margin: 0 10px 0 0; 183 max-height: 70px; 184 max-width: 70px; 145 185 } 146 186 -
trunk/src/wp-includes/script-loader.php
r51017 r51023 884 884 'error_uploading' => __( '“%s” has failed to upload.' ), 885 885 'unsupported_image' => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ), 886 'file_url_copied' => __( 'The file URL has been copied to your clipboard' ), 886 887 ); 887 888 … … 893 894 } 894 895 895 $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( ' plupload', 'jquery' ) );896 $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) ); 896 897 did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); 897 898
Note: See TracChangeset
for help on using the changeset viewer.