Ticket #44588: 44588.diff
| File 44588.diff, 5.6 KB (added by , 6 years ago) |
|---|
-
src/js/_enqueues/admin/privacy-tools.js
4 4 * @output wp-admin/js/privacy-tools.js 5 5 */ 6 6 7 /* global ClipboardJS, wp */ 8 7 9 // Privacy request action handling 8 10 jQuery( document ).ready( function( $ ) { 11 12 var __ = wp.i18n.__; 13 9 14 var strings = window.privacyToolsL10n || {}; 15 var clipboard = new ClipboardJS( '.privacy-text-copy-button' ); 10 16 11 17 function setActionState( $action, state ) { 12 18 $action.children().addClass( 'hidden' ); … … 230 236 doNextErasure( 1, 1 ); 231 237 }); 232 238 233 // Privacy policy page, copy button. 234 $( document ).on( 'click', function( event ) { 235 var $target = $( event.target ); 236 var $parent, $container, range; 237 238 if ( $target.is( 'button.privacy-text-copy' ) ) { 239 $parent = $target.parent().parent(); 240 $container = $parent.find( 'div.wp-suggested-text' ); 241 242 if ( ! $container.length ) { 243 $container = $parent.find( 'div.policy-text' ); 244 } 239 // Copy 'Suggested Privacy' section. 240 clipboard.on( 'success', function( e ) { 241 var $wrapper = $( e.trigger ).closest( 'div' ); 242 $( '.success', $wrapper ).addClass( 'visible' ); 245 243 246 if ( $container.length ) { 247 try { 248 window.getSelection().removeAllRanges(); 249 range = document.createRange(); 250 $container.addClass( 'hide-privacy-policy-tutorial' ); 251 252 range.selectNodeContents( $container[0] ); 253 window.getSelection().addRange( range ); 254 document.execCommand( 'copy' ); 255 256 $container.removeClass( 'hide-privacy-policy-tutorial' ); 257 window.getSelection().removeAllRanges(); 258 } catch ( er ) {} 259 } 260 } 261 }); 244 wp.a11y.speak( __( 'Privacy Content has been added to your clipboard.' ) ); 245 } ); 262 246 }); 263 247 -
src/wp-admin/css/edit.css
688 688 margin: 1em 0 0.5em; 689 689 } 690 690 691 .privacy-text-section .privacy-text-copy {691 .privacy-text-section .privacy-text-copy-button { 692 692 float: right; 693 693 } 694 694 … … 714 714 padding-bottom: 6px; 715 715 } 716 716 717 .privacy-text-actions .success { 718 display: none; 719 color: #40860a; 720 } 721 722 .privacy-text-actions .success.visible { 723 display: inline-block; 724 height: 32px; 725 } 726 717 727 .wp-privacy-policy-guide .policy-text h2 { 718 728 margin: 1.2em 0 1em; 719 729 padding: 0; -
src/wp-admin/includes/class-wp-privacy-policy-content.php
372 372 373 373 $content_array = self::get_suggested_policy_text(); 374 374 375 $content = ''; 376 $toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' ); 377 $date_format = __( 'F j, Y' ); 378 $copy = __( 'Copy this section to clipboard' ); 379 $return_to_top = '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>'; 375 $content = ''; 376 $toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' ); 377 $date_format = __( 'F j, Y' ); 378 $copy = __( 'Copy this section to clipboard' ); 379 $return_to_top = '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>'; 380 $on_copy_success = __( 'Copied!' ); 380 381 381 382 foreach ( $content_array as $section ) { 382 383 $class = ''; … … 417 418 $content .= $return_to_top; 418 419 419 420 if ( empty( $section['removed'] ) ) { 420 $content .= '<div class="privacy-text-actions">';421 $content .= '<button type="button" class="privacy-text-copy button">';422 $content.= $copy;423 $content .= '<span class="screen-reader-text">';421 $content .= '<div class="privacy-text-actions">'; 422 $content .= sprintf( '<button type="button" class="privacy-text-copy-button button" data-clipboard-text="%1$s">', esc_attr( self::get_default_content( false, false ) ) ); 423 $content .= $copy; 424 $content .= '<span class="screen-reader-text">'; 424 425 /* translators: %s: Plugin name. */ 425 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 426 $content .= '</span>'; 427 $content .= '</button>'; 428 $content .= '</div>'; 426 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 427 $content .= '</span>'; 428 $content .= '</button>'; 429 430 /* on Copy success feedback */ 431 $content .= '<span class="success" aria-hidden="true">'; 432 $content .= $on_copy_success; 433 $content .= '</span>'; 434 $content .= '</div>'; 429 435 } 430 436 431 437 $content .= "</div>\n"; // End of .privacy-text-section. -
src/wp-includes/script-loader.php
1468 1468 $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 ); 1469 1469 $scripts->set_translations( 'site-health' ); 1470 1470 1471 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( ' jquery' ), false, 1 );1471 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'clipboard', 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 ); 1472 1472 did_action( 'init' ) && $scripts->localize( 1473 1473 'privacy-tools', 1474 1474 'privacyToolsL10n',