Make WordPress Core

Ticket #46647: 46647.diff

File 46647.diff, 8.6 KB (added by pento, 4 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..8683acca77 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( '.site-health-copy-buttons .copy-button' );
    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                $( '.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..82013d18b5 100644
    a b body.site-health .spinner { 
    206206        float: none;
    207207}
    208208
    209 body.site-health .system-information-copy-wrapper {
     209.site-health-copy-buttons {
    210210        display: block;
    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 
    223 body.site-health .health-check-toggle-copy-section:hover {
    224         background: none;
    225 }
    226 
    227 body.site-health .system-information-copy-wrapper .copy-button-wrapper {
     214.site-health-copy-buttons .copy-button-wrapper {
    228215        margin: 0.5rem 0 1rem;
    229216}
    230217
    231 body.site-health .copy-field-success {
     218.site-health-copy-buttons .success {
    232219        display: none;
    233220        color: #40860a;
    234221        line-height: 1.8;
    235222        margin-left: 0.5rem;
    236223}
    237224
    238 body.site-health .copy-field-success.visible {
     225.site-health-copy-buttons .success.visible {
    239226        display: inline-block;
    240227        height: 28px;
    241228    line-height: 28px;
  • src/wp-admin/includes/class-wp-debug-data.php

    diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php
    index 6e82e0b672..a49ffc2922 100644
    a b class WP_Debug_Data { 
    881881        }
    882882
    883883        /**
    884          * Print the formatted variation of the information gathered for debugging, in a manner
    885          * suitable for a text area that can be instantly copied to a forum or support ticket.
     884         * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
    886885         *
    887886         * @since 5.2.0
    888887         *
    889888         * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
     889         * @param string $type      Optional. The data type to format the information as. Default 'text'.
     890         * @return string The formatted data.
    890891         */
    891         public static function textarea_format( $info_array ) {
    892                 echo "`\n";
     892        public static function format( $info_array, $type = 'text' ) {
     893                $return = '';
    893894
    894895                foreach ( $info_array as $section => $details ) {
    895896                        // Skip this section if there are no fields, or the section has been declared as private.
    class WP_Debug_Data { 
    897898                                continue;
    898899                        }
    899900
    900                         printf(
     901                        $return .= sprintf(
    901902                                "### %s%s ###\n\n",
    902903                                $details['label'],
    903904                                ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
    class WP_Debug_Data { 
    921922                                        }
    922923                                }
    923924
    924                                 printf(
     925                                $return .= sprintf(
    925926                                        "%s: %s\n",
    926927                                        $field['label'],
    927928                                        $values
    928929                                );
    929930                        }
    930                         echo "\n";
     931                        $return .= "\n";
    931932                }
    932                 echo '`';
     933
     934                return $return;
    933935        }
    934936
    935937        /**
  • 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..dbf4aa27ec 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' ); 
    7074                        <?php _e( 'You can export the information on this page so it can be easily copied and pasted in support requests such as on the WordPress.org forums, or shared with your website / theme / plugin developers.' ); ?>
    7175                </p>
    7276
    73                 <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 
     77                <div class="site-health-copy-buttons">
    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>
    87                                 <span class="copy-field-success" aria-hidden="true">Copied!</span>
     79                                <button type="button" class="button button-primary copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'text' ) ); ?>"><?php _e( 'Copy report to clipboard' ); ?></button>
     80                                <span class="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>
    92                                         <span class="copy-field-success" aria-hidden="true">Copied!</span>
     84                                        <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $english_info, 'text' ) ); ?>"><?php _e( 'Copy report to clipboard (English)' ); ?></button>
     85                                        <span class="success" aria-hidden="true">Copied!</span>
    9386                                </div>
    9487                        <?php endif; ?>
    9588                </div>
  • 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(