Changeset 47572
- Timestamp:
- 04/12/2020 02:24:38 PM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/privacy-tools.js
r47420 r47572 260 260 }); 261 261 262 // Privacy policy page, copy button.262 // Privacy Policy page, copy action. 263 263 $( document ).on( 'click', function( event ) { 264 var $target = $( event.target ); 265 var $parent, $container, range; 264 var $parent, 265 $container, 266 range, 267 __ = wp.i18n.__, 268 $target = $( event.target ), 269 copiedNotice = $target.siblings( '.success' ); 266 270 267 271 if ( $target.is( 'button.privacy-text-copy' ) ) { … … 278 282 bodyPosition = document.body.scrollTop; 279 283 284 // Setup copy. 280 285 window.getSelection().removeAllRanges(); 286 287 // Hide tutorial content to remove from copied content. 281 288 range = document.createRange(); 282 289 $container.addClass( 'hide-privacy-policy-tutorial' ); 283 290 291 // Copy action. 284 292 range.selectNodeContents( $container[0] ); 285 293 window.getSelection().addRange( range ); 286 294 document.execCommand( 'copy' ); 287 295 296 // Reset section. 288 297 $container.removeClass( 'hide-privacy-policy-tutorial' ); 289 298 window.getSelection().removeAllRanges(); 290 299 300 // Return scroll position - see #49540. 291 301 if ( documentPosition > 0 && documentPosition !== document.documentElement.scrollTop ) { 292 302 document.documentElement.scrollTop = documentPosition; … … 294 304 document.body.scrollTop = bodyPosition; 295 305 } 306 307 // Display and speak notice to indicate action complete. 308 copiedNotice.addClass( 'visible' ); 309 wp.a11y.speak( __( 'The section has been copied to your clipboard.' ) ); 310 311 // Delay notice dismissal. 312 setTimeout( function(){ copiedNotice.removeClass( 'visible' ); }, 3000 ); 296 313 } catch ( er ) {} 297 314 } -
trunk/src/wp-admin/css/edit.css
r47560 r47572 727 727 line-height: 2.46153846; 728 728 padding-bottom: 6px; 729 } 730 731 .privacy-text-actions .success { 732 display: none; 733 color: #40860a; 734 float: right; 735 padding-right: 1em; 736 } 737 738 .privacy-text-actions .success.visible { 739 display: inline-block; 740 height: 32px; 729 741 } 730 742 -
trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php
r47284 r47572 373 373 374 374 $content_array = self::get_suggested_policy_text(); 375 376 375 $content = ''; 377 376 $toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' ); 378 377 $date_format = __( 'F j, Y' ); 379 $copy = __( 'Copy this section to clipboard' );380 $return_to_top = '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>';381 378 382 379 foreach ( $content_array as $section ) { … … 386 383 387 384 if ( ! empty( $section['removed'] ) ) { 388 $class = ' 385 $class = 'text-removed'; 389 386 $date = date_i18n( $date_format, $section['removed'] ); 390 387 /* translators: %s: Date of plugin deactivation. */ … … 395 392 $removed = '<div class="error inline"><p>' . sprintf( $removed, $date ) . '</p></div>'; 396 393 } elseif ( ! empty( $section['updated'] ) ) { 397 $class = ' 394 $class = 'text-updated'; 398 395 $date = date_i18n( $date_format, $section['updated'] ); 399 396 /* translators: %s: Date of privacy policy text update. */ … … 409 406 $toc[] = sprintf( '<li><a href="#%1$s">%2$s</a>' . $meta . '</li>', $toc_id, $plugin_name ); 410 407 411 $content .= '<div class="privacy-text-section ' . $class . '">';408 $content .= '<div class="privacy-text-section ' . $class . '">'; 412 409 $content .= '<a id="' . $toc_id . '"> </a>'; 413 410 /* translators: %s: Plugin name. */ … … 416 413 417 414 $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>'; 418 $content .= $return_to_top;415 $content .= '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>'; 419 416 420 417 if ( empty( $section['removed'] ) ) { 421 $content .= '<div class="privacy-text-actions">'; 422 $content .= '<button type="button" class="privacy-text-copy button">'; 423 $content .= $copy; 424 $content .= '<span class="screen-reader-text">'; 425 /* translators: %s: Plugin name. */ 426 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 427 $content .= '</span>'; 428 $content .= '</button>'; 429 $content .= '</div>'; 430 } 431 432 $content .= "</div>\n"; // End of .privacy-text-section. 418 $content .= '<div class="privacy-text-actions">'; 419 $content .= '<button type="button" class="privacy-text-copy button">'; 420 $content .= __( 'Copy this section to clipboard' ); 421 $content .= '<span class="screen-reader-text">'; 422 /* translators: %s: Plugin name. */ 423 $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name ); 424 $content .= '</span>'; 425 $content .= '</button>'; 426 $content .= '<span class="success" aria-hidden="true">' . __( 'Copied!' ) . '</span>'; 427 $content .= '</div>'; 428 } 429 430 $content .= '</div>'; // End of .privacy-text-section. 433 431 } 434 432 435 433 if ( count( $toc ) > 2 ) { 436 434 ?> 437 <div 435 <div class="privacy-text-box-toc"> 438 436 <p><?php _e( 'Table of Contents' ); ?></p> 439 437 <ol> 440 <?php echo implode( "\n",$toc ); ?>438 <?php echo implode( $toc ); ?> 441 439 </ol> 442 440 </div> -
trunk/src/wp-includes/script-loader.php
r47416 r47572 1418 1418 $scripts->set_translations( 'site-health' ); 1419 1419 1420 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );1420 $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 ); 1421 1421 did_action( 'init' ) && $scripts->localize( 1422 1422 'privacy-tools',
Note: See TracChangeset
for help on using the changeset viewer.