Ticket #44588: 44588.3.diff
| File 44588.3.diff, 5.5 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( $ ) { 9 var strings = window.privacyToolsL10n || {};10 11 12 var __ = wp.i18n.__, 13 strings = window.privacyToolsL10n || {}, 14 clipboard = new ClipboardJS( '.privacy-text-copy' ); 15 11 16 function setActionState( $action, state ) { 12 17 $action.children().addClass( 'hidden' ); 13 18 $action.children( '.' + state ).removeClass( 'hidden' ); … … 230 235 doNextErasure( 1, 1 ); 231 236 }); 232 237 233 // Privacy policy page, copy button.234 $( document ).on( 'click', function( event) {235 var $ target = $( event.target);236 var $parent, $container, range;238 // Copy 'Suggested Privacy' section. 239 clipboard.on( 'success', function( e ) { 240 var $wrapper = $( e.trigger ).closest( 'div' ); 241 $( '.success', $wrapper ).addClass( 'visible' ); 237 242 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 } 245 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 }); 243 wp.a11y.speak( __( 'Privacy Policy Guide section has been copied to your clipboard.' ) ); 244 } ); 262 245 }); 263 246 -
src/wp-admin/css/edit.css
714 714 padding-bottom: 6px; 715 715 } 716 716 717 .privacy-text-actions .success { 718 display: none; 719 color: #40860a; 720 float: right; 721 padding-right: 1em; 722 } 723 724 .privacy-text-actions .success.visible { 725 display: inline-block; 726 height: 32px; 727 } 728 717 729 .wp-privacy-policy-guide .policy-text h2 { 718 730 margin: 1.2em 0 1em; 719 731 padding: 0; -
src/wp-admin/includes/class-wp-privacy-policy-content.php
371 371 public static function privacy_policy_guide() { 372 372 373 373 $content_array = self::get_suggested_policy_text(); 374 375 374 $content = ''; 376 375 $toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' ); 377 376 $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 377 381 378 foreach ( $content_array as $section ) { 382 379 $class = ''; … … 414 411 $content .= $removed; 415 412 416 413 $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>'; 417 $content .= $return_to_top;414 $content .= '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>'; 418 415 419 416 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">'; 424 /* translators: %s: Plugin name. */ 425 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 426 $content .= '</span>'; 427 $content .= '</button>'; 428 $content .= '</div>'; 417 $content .= '<div class="privacy-text-actions">'; 418 $content .= sprintf( '<button type="button" class="privacy-text-copy button" data-clipboard-text="%1$s">', esc_attr( self::get_default_content( false, false ) ) ); 419 $content .= __( 'Copy this section to clipboard' ); 420 $content .= '<span class="screen-reader-text">'; 421 /* translators: %s: Plugin name. */ 422 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 423 $content .= '</span>'; 424 $content .= '</button>'; 425 426 /* on Copy success feedback */ 427 $content .= '<span class="success" aria-hidden="true">' . __( 'Copied!' ) . '</span>'; 428 $content .= '</div>'; 429 429 } 430 430 431 431 $content .= "</div>\n"; // End of .privacy-text-section. -
src/wp-includes/script-loader.php
1469 1469 $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 ); 1470 1470 $scripts->set_translations( 'site-health' ); 1471 1471 1472 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( ' jquery' ), false, 1 );1472 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'clipboard', 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 ); 1473 1473 did_action( 'init' ) && $scripts->localize( 1474 1474 'privacy-tools', 1475 1475 'privacyToolsL10n',