diff --git a/Gruntfile.js b/Gruntfile.js
index f40fa336cf..c71fe02612 100644
a
|
b
|
module.exports = function(grunt) { |
166 | 166 | files: [ |
167 | 167 | { |
168 | 168 | [ 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' ], |
169 | 170 | [ WORKING_DIR + 'wp-includes/js/hoverIntent.js' ]: [ './node_modules/jquery-hoverintent/jquery.hoverIntent.js' ], |
170 | 171 | [ WORKING_DIR + 'wp-includes/js/imagesloaded.min.js' ]: [ './node_modules/imagesloaded/imagesloaded.pkgd.min.js' ], |
171 | 172 | [ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.js' ], |
diff --git a/package.json b/package.json
index 2e4c7ead45..3f777bce1e 100644
a
|
b
|
|
94 | 94 | "@wordpress/viewport": "2.3.0", |
95 | 95 | "@wordpress/wordcount": "2.2.0", |
96 | 96 | "backbone": "1.3.3", |
| 97 | "clipboard": "2.0.4", |
97 | 98 | "element-closest": "^2.0.2", |
98 | 99 | "formdata-polyfill": "3.0.13", |
99 | 100 | "imagesloaded": "3.2.0", |
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( $ ) { |
10 | 10 | |
11 | 11 | var data; |
12 | 12 | |
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' ); |
21 | 14 | |
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' ); |
25 | 19 | |
26 | | wp.a11y.speak( SiteHealth.string.site_info_copied ); |
27 | | } |
| 20 | wp.a11y.speak( SiteHealth.string.site_info_copied ); |
28 | 21 | } ); |
29 | 22 | |
30 | 23 | // Accordion handling in various areas. |
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 { |
211 | 211 | margin: 1rem 0; |
212 | 212 | } |
213 | 213 | |
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 | 214 | body.site-health .health-check-toggle-copy-section:hover { |
224 | 215 | background: none; |
225 | 216 | } |
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' ); |
59 | 59 | <?php |
60 | 60 | WP_Debug_Data::check_for_updates(); |
61 | 61 | |
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 | } |
63 | 67 | ?> |
64 | 68 | |
65 | 69 | <h2> |
… |
… |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
71 | 75 | </p> |
72 | 76 | |
73 | 77 | <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 | | |
85 | 78 | <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> |
87 | 80 | <span class="copy-field-success" aria-hidden="true">Copied!</span> |
88 | 81 | </div> |
89 | | <?php if ( 0 !== strpos( get_locale(), 'en' ) ) : ?> |
| 82 | <?php if ( $english_info ) : ?> |
90 | 83 | <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> |
92 | 85 | <span class="copy-field-success" aria-hidden="true">Copied!</span> |
93 | 86 | </div> |
94 | 87 | <?php endif; ?> |
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 ) { |
924 | 924 | |
925 | 925 | $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); |
926 | 926 | |
| 927 | $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 ); |
| 928 | |
927 | 929 | // Back-compat for old DFW. To-do: remove at the end of 2016. |
928 | 930 | $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 ); |
929 | 931 | |
… |
… |
function wp_default_scripts( &$scripts ) { |
1688 | 1690 | ) |
1689 | 1691 | ); |
1690 | 1692 | |
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 ); |
1692 | 1694 | |
1693 | 1695 | $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 ); |
1694 | 1696 | did_action( 'init' ) && $scripts->localize( |