<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[47572] trunk/src: Privacy: Add an indication when the Copy action in Privacy Policy Guide is complete.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/47572">47572</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/47572","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-04-12 14:24:38 +0000 (Sun, 12 Apr 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Privacy: Add an indication when the Copy action in Privacy Policy Guide is complete.
This adds a "Copied!" text near the "Copy this section to clipboard" button to provide direct feedback that the action was completed.
Props garrett-eclipse, nickylimjj, xkon, desrosj, birgire.
Fixes <a href="https://core.trac.wordpress.org/ticket/44588">#44588</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadminprivacytoolsjs">trunk/src/js/_enqueues/admin/privacy-tools.js</a></li>
<li><a href="#trunksrcwpadmincsseditcss">trunk/src/wp-admin/css/edit.css</a></li>
<li><a href="#trunksrcwpadminincludesclasswpprivacypolicycontentphp">trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadminprivacytoolsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/privacy-tools.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/privacy-tools.js 2020-04-11 15:07:27 UTC (rev 47571)
+++ trunk/src/js/_enqueues/admin/privacy-tools.js 2020-04-12 14:24:38 UTC (rev 47572)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -259,10 +259,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> doNextErasure( 1, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Privacy policy page, copy button.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Privacy Policy page, copy action.
</ins><span class="cx" style="display: block; padding: 0 10px"> $( document ).on( 'click', function( event ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $target = $( event.target );
- var $parent, $container, range;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $parent,
+ $container,
+ range,
+ __ = wp.i18n.__,
+ $target = $( event.target ),
+ copiedNotice = $target.siblings( '.success' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $target.is( 'button.privacy-text-copy' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = $target.parent().parent();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -277,22 +281,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var documentPosition = document.documentElement.scrollTop,
</span><span class="cx" style="display: block; padding: 0 10px"> bodyPosition = document.body.scrollTop;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Setup copy.
</ins><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().removeAllRanges();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Hide tutorial content to remove from copied content.
</ins><span class="cx" style="display: block; padding: 0 10px"> range = document.createRange();
</span><span class="cx" style="display: block; padding: 0 10px"> $container.addClass( 'hide-privacy-policy-tutorial' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Copy action.
</ins><span class="cx" style="display: block; padding: 0 10px"> range.selectNodeContents( $container[0] );
</span><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().addRange( range );
</span><span class="cx" style="display: block; padding: 0 10px"> document.execCommand( 'copy' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Reset section.
</ins><span class="cx" style="display: block; padding: 0 10px"> $container.removeClass( 'hide-privacy-policy-tutorial' );
</span><span class="cx" style="display: block; padding: 0 10px"> window.getSelection().removeAllRanges();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Return scroll position - see #49540.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( documentPosition > 0 && documentPosition !== document.documentElement.scrollTop ) {
</span><span class="cx" style="display: block; padding: 0 10px"> document.documentElement.scrollTop = documentPosition;
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( bodyPosition > 0 && bodyPosition !== document.body.scrollTop ) {
</span><span class="cx" style="display: block; padding: 0 10px"> document.body.scrollTop = bodyPosition;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Display and speak notice to indicate action complete.
+ copiedNotice.addClass( 'visible' );
+ wp.a11y.speak( __( 'The section has been copied to your clipboard.' ) );
+
+ // Delay notice dismissal.
+ setTimeout( function(){ copiedNotice.removeClass( 'visible' ); }, 3000 );
</ins><span class="cx" style="display: block; padding: 0 10px"> } catch ( er ) {}
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadmincsseditcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/edit.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/edit.css 2020-04-11 15:07:27 UTC (rev 47571)
+++ trunk/src/wp-admin/css/edit.css 2020-04-12 14:24:38 UTC (rev 47572)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -728,6 +728,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> padding-bottom: 6px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.privacy-text-actions .success {
+ display: none;
+ color: #40860a;
+ float: right;
+ padding-right: 1em;
+}
+
+.privacy-text-actions .success.visible {
+ display: inline-block;
+ height: 32px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .wp-privacy-policy-guide .policy-text h2 {
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 1.2em 0 1em;
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 0;
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpprivacypolicycontentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php 2020-04-11 15:07:27 UTC (rev 47571)
+++ trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php 2020-04-12 14:24:38 UTC (rev 47572)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -372,12 +372,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public static function privacy_policy_guide() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $content_array = self::get_suggested_policy_text();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $content = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' );
</span><span class="cx" style="display: block; padding: 0 10px"> $date_format = __( 'F j, Y' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $copy = __( 'Copy this section to clipboard' );
- $return_to_top = '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>';
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $content_array as $section ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $class = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,7 +382,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $removed = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $section['removed'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $class = ' text-removed';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $class = 'text-removed';
</ins><span class="cx" style="display: block; padding: 0 10px"> $date = date_i18n( $date_format, $section['removed'] );
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Date of plugin deactivation. */
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = sprintf( __( 'Removed %s.' ), $date );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -394,7 +391,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' );
</span><span class="cx" style="display: block; padding: 0 10px"> $removed = '<div class="error inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $section['updated'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $class = ' text-updated';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $class = 'text-updated';
</ins><span class="cx" style="display: block; padding: 0 10px"> $date = date_i18n( $date_format, $section['updated'] );
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Date of privacy policy text update. */
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = sprintf( __( 'Updated %s.' ), $date );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -408,7 +405,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $toc_id = 'wp-privacy-policy-guide-' . sanitize_title( $plugin_name );
</span><span class="cx" style="display: block; padding: 0 10px"> $toc[] = sprintf( '<li><a href="#%1$s">%2$s</a>' . $meta . '</li>', $toc_id, $plugin_name );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content .= '<div class="privacy-text-section' . $class . '">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '<div class="privacy-text-section ' . $class . '">';
</ins><span class="cx" style="display: block; padding: 0 10px"> $content .= '<a id="' . $toc_id . '"> </a>';
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Plugin name. */
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= '<h2>' . sprintf( __( 'Source: %s' ), $plugin_name ) . '</h2>';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -415,29 +412,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= $removed;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content .= $return_to_top;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $section['removed'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content .= '<div class="privacy-text-actions">';
- $content .= '<button type="button" class="privacy-text-copy button">';
- $content .= $copy;
- $content .= '<span class="screen-reader-text">';
- /* translators: %s: Plugin name. */
- $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name );
- $content .= '</span>';
- $content .= '</button>';
- $content .= '</div>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '<div class="privacy-text-actions">';
+ $content .= '<button type="button" class="privacy-text-copy button">';
+ $content .= __( 'Copy this section to clipboard' );
+ $content .= '<span class="screen-reader-text">';
+ /* translators: %s: Plugin name. */
+ $content .= sprintf( __( 'Copy suggested policy text from %s.' ), $plugin_name );
+ $content .= '</span>';
+ $content .= '</button>';
+ $content .= '<span class="success" aria-hidden="true">' . __( 'Copied!' ) . '</span>';
+ $content .= '</div>';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $content .= "</div>\n"; // End of .privacy-text-section.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content .= '</div>'; // End of .privacy-text-section.
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( count( $toc ) > 2 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="privacy-text-box-toc">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="privacy-text-box-toc">
</ins><span class="cx" style="display: block; padding: 0 10px"> <p><?php _e( 'Table of Contents' ); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> <ol>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo implode( "\n", $toc ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php echo implode( $toc ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </ol>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2020-04-11 15:07:27 UTC (rev 47571)
+++ trunk/src/wp-includes/script-loader.php 2020-04-12 14:24:38 UTC (rev 47572)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1417,7 +1417,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->set_translations( 'site-health' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> did_action( 'init' ) && $scripts->localize(
</span><span class="cx" style="display: block; padding: 0 10px"> 'privacy-tools',
</span><span class="cx" style="display: block; padding: 0 10px"> 'privacyToolsL10n',
</span></span></pre>
</div>
</div>
</body>
</html>