Make WordPress Core

Ticket #46573: 46573.8.diff

File 46573.8.diff, 6.0 KB (added by pento, 6 years ago)
  • Gruntfile.js

    diff --git a/Gruntfile.js b/Gruntfile.js
    index f40fa336cf..c71fe02612 100644
    a b module.exports = function(grunt) { 
    166166                                files: [
    167167                                        {
    168168                                                [ WORKING_DIR + 'wp-includes/js/backbone.js' ]: [ './node_modules/backbone/backbone.js' ],
     169                                                [ WORKING_DIR + 'wp-includes/js/clipboard.js' ]: [ './node_modules/clipboard/dist/clipboard.js' ],
    169170                                                [ WORKING_DIR + 'wp-includes/js/hoverIntent.js' ]: [ './node_modules/jquery-hoverintent/jquery.hoverIntent.js' ],
    170171                                                [ WORKING_DIR + 'wp-includes/js/imagesloaded.min.js' ]: [ './node_modules/imagesloaded/imagesloaded.pkgd.min.js' ],
    171172                                                [ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.js' ],
  • package.json

    diff --git a/package.json b/package.json
    index 2e4c7ead45..3f777bce1e 100644
    a b  
    9494                "@wordpress/viewport": "2.3.0",
    9595                "@wordpress/wordcount": "2.2.0",
    9696                "backbone": "1.3.3",
     97                "clipboard": "2.0.4",
    9798                "element-closest": "^2.0.2",
    9899                "formdata-polyfill": "3.0.13",
    99100                "imagesloaded": "3.2.0",
  • src/js/_enqueues/admin/site-health.js

    diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js
    index fba118bb78..b49770a0f8 100644
    a b jQuery( document ).ready( function( $ ) { 
    1010
    1111        var data;
    1212
    13         // Debug information copy section.
    14         $( '.health-check-copy-field' ).click( function( e ) {
    15                 var $textarea = $( '#system-information-' + $( this ).data( 'copy-field' ) + '-copy-field' ),
    16                         $wrapper = $( this ).closest( 'div' );
    17 
    18                 e.preventDefault();
    19 
    20                 $textarea.select();
     13        var clipboard = new ClipboardJS( '.health-check-copy-field' );
    2114
    22                 if ( document.execCommand( 'copy' ) ) {
    23                         $( '.copy-field-success', $wrapper ).addClass( 'visible' );
    24                         $( this ).focus();
     15        // Debug information copy section.
     16        clipboard.on( 'success', function( e ) {
     17                var $wrapper = $( e.trigger ).closest( 'div' );
     18                $( '.copy-field-success', $wrapper ).addClass( 'visible' );
    2519
    26                         wp.a11y.speak( SiteHealth.string.site_info_copied );
    27                 }
     20                wp.a11y.speak( SiteHealth.string.site_info_copied );
    2821        } );
    2922
    3023        // Accordion handling in various areas.
  • src/wp-admin/css/site-health.css

    diff --git a/src/wp-admin/css/site-health.css b/src/wp-admin/css/site-health.css
    index c12b52b019..8dd07b5a50 100644
    a b body.site-health .system-information-copy-wrapper { 
    211211        margin: 1rem 0;
    212212}
    213213
    214 body.site-health .system-information-copy-wrapper textarea {
    215         border: 0;
    216         padding: 0;
    217         margin: 0;
    218         position: absolute;
    219         left: -9999px;
    220         top: -9999px;
    221 }
    222 
    223214body.site-health .health-check-toggle-copy-section:hover {
    224215        background: none;
    225216}
  • src/wp-admin/site-health-info.php

    diff --git a/src/wp-admin/site-health-info.php b/src/wp-admin/site-health-info.php
    index 164ff989c4..985419ead7 100644
    a b require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    5959                <?php
    6060                WP_Debug_Data::check_for_updates();
    6161
    62                 $info = WP_Debug_Data::debug_data();
     62                $info         = WP_Debug_Data::debug_data();
     63                $english_info = '';
     64                if ( 0 !== strpos( get_locale(), 'en' ) ) {
     65                        $english_info = WP_Debug_Data::debug_data( 'en_US' );
     66                }
    6367                ?>
    6468
    6569                <h2>
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    7175                </p>
    7276
    7377                <div class="system-information-copy-wrapper">
    74                         <textarea id="system-information-default-copy-field" readonly><?php WP_Debug_Data::textarea_format( $info ); ?></textarea>
    75 
    76                         <?php
    77                         if ( 0 !== strpos( get_locale(), 'en' ) ) :
    78 
    79                                 $english_info = WP_Debug_Data::debug_data( 'en_US' );
    80                                 ?>
    81                                 <textarea id="system-information-english-copy-field" readonly><?php WP_Debug_Data::textarea_format( $english_info ); ?></textarea>
    82 
    83                         <?php endif; ?>
    84 
    8578                        <div class="copy-button-wrapper">
    86                                 <button type="button" class="button button-primary health-check-copy-field" data-copy-field="default"><?php _e( 'Copy to clipboard' ); ?></button>
     79                                <button type="button" class="button button-primary health-check-copy-field" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::textarea_format( $info ) ); ?>"><?php _e( 'Copy report to clipboard' ); ?></button>
    8780                                <span class="copy-field-success" aria-hidden="true">Copied!</span>
    8881                        </div>
    89                         <?php if ( 0 !== strpos( get_locale(), 'en' ) ) : ?>
     82                        <?php if ( $english_info ) : ?>
    9083                                <div class="copy-button-wrapper">
    91                                         <button type="button" class="button health-check-copy-field" data-copy-field="english"><?php _e( 'Copy to clipboard (English)' ); ?></button>
     84                                        <button type="button" class="button health-check-copy-field" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::textarea_format( $english_info ) ); ?>"><?php _e( 'Copy report to clipboard (English)' ); ?></button>
    9285                                        <span class="copy-field-success" aria-hidden="true">Copied!</span>
    9386                                </div>
    9487                        <?php endif; ?>
  • src/wp-includes/script-loader.php

    diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
    index 5bba581d8f..3a3f57eded 100644
    a b function wp_default_scripts( &$scripts ) { 
    924924
    925925        $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );
    926926
     927        $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
     928
    927929        // Back-compat for old DFW. To-do: remove at the end of 2016.
    928930        $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );
    929931
    function wp_default_scripts( &$scripts ) { 
    16881690                        )
    16891691                );
    16901692
    1691                 $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
     1693                $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
    16921694
    16931695                $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
    16941696                did_action( 'init' ) && $scripts->localize(