mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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 #44588. Built from https://develop.svn.wordpress.org/trunk@47572 git-svn-id: http://core.svn.wordpress.org/trunk@47347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
48225beffb
commit
87b3b38242
@ -729,6 +729,18 @@ form#tags-filter {
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.privacy-text-actions .success {
|
||||
display: none;
|
||||
color: #40860a;
|
||||
float: left;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.privacy-text-actions .success.visible {
|
||||
display: inline-block;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.wp-privacy-policy-guide .policy-text h2 {
|
||||
margin: 1.2em 0 1em;
|
||||
padding: 0;
|
||||
|
2
wp-admin/css/edit-rtl.min.css
vendored
2
wp-admin/css/edit-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
@ -728,6 +728,18 @@ form#tags-filter {
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.privacy-text-actions .success {
|
||||
display: none;
|
||||
color: #40860a;
|
||||
float: right;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.privacy-text-actions .success.visible {
|
||||
display: inline-block;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.wp-privacy-policy-guide .policy-text h2 {
|
||||
margin: 1.2em 0 1em;
|
||||
padding: 0;
|
||||
|
2
wp-admin/css/edit.min.css
vendored
2
wp-admin/css/edit.min.css
vendored
File diff suppressed because one or more lines are too long
@ -372,12 +372,9 @@ final class WP_Privacy_Policy_Content {
|
||||
public static function privacy_policy_guide() {
|
||||
|
||||
$content_array = self::get_suggested_policy_text();
|
||||
|
||||
$content = '';
|
||||
$toc = array( '<li><a href="#wp-privacy-policy-guide-introduction">' . __( 'Introduction' ) . '</a></li>' );
|
||||
$date_format = __( 'F j, Y' );
|
||||
$copy = __( 'Copy this section to clipboard' );
|
||||
$return_to_top = '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>';
|
||||
|
||||
foreach ( $content_array as $section ) {
|
||||
$class = '';
|
||||
@ -385,7 +382,7 @@ final class WP_Privacy_Policy_Content {
|
||||
$removed = '';
|
||||
|
||||
if ( ! empty( $section['removed'] ) ) {
|
||||
$class = ' text-removed';
|
||||
$class = 'text-removed';
|
||||
$date = date_i18n( $date_format, $section['removed'] );
|
||||
/* translators: %s: Date of plugin deactivation. */
|
||||
$meta = sprintf( __( 'Removed %s.' ), $date );
|
||||
@ -394,7 +391,7 @@ final class WP_Privacy_Policy_Content {
|
||||
$removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' );
|
||||
$removed = '<div class="error inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
|
||||
} elseif ( ! empty( $section['updated'] ) ) {
|
||||
$class = ' text-updated';
|
||||
$class = 'text-updated';
|
||||
$date = date_i18n( $date_format, $section['updated'] );
|
||||
/* translators: %s: Date of privacy policy text update. */
|
||||
$meta = sprintf( __( 'Updated %s.' ), $date );
|
||||
@ -408,36 +405,37 @@ final class WP_Privacy_Policy_Content {
|
||||
$toc_id = 'wp-privacy-policy-guide-' . sanitize_title( $plugin_name );
|
||||
$toc[] = sprintf( '<li><a href="#%1$s">%2$s</a>' . $meta . '</li>', $toc_id, $plugin_name );
|
||||
|
||||
$content .= '<div class="privacy-text-section' . $class . '">';
|
||||
$content .= '<div class="privacy-text-section ' . $class . '">';
|
||||
$content .= '<a id="' . $toc_id . '"> </a>';
|
||||
/* translators: %s: Plugin name. */
|
||||
$content .= '<h2>' . sprintf( __( 'Source: %s' ), $plugin_name ) . '</h2>';
|
||||
$content .= $removed;
|
||||
|
||||
$content .= '<div class="policy-text">' . $section['policy_text'] . '</div>';
|
||||
$content .= $return_to_top;
|
||||
$content .= '<a href="#" class="return-to-top">' . __( '↑ Return to Top' ) . '</a>';
|
||||
|
||||
if ( empty( $section['removed'] ) ) {
|
||||
$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>';
|
||||
$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>';
|
||||
}
|
||||
|
||||
$content .= "</div>\n"; // End of .privacy-text-section.
|
||||
$content .= '</div>'; // End of .privacy-text-section.
|
||||
}
|
||||
|
||||
if ( count( $toc ) > 2 ) {
|
||||
?>
|
||||
<div class="privacy-text-box-toc">
|
||||
<div class="privacy-text-box-toc">
|
||||
<p><?php _e( 'Table of Contents' ); ?></p>
|
||||
<ol>
|
||||
<?php echo implode( "\n", $toc ); ?>
|
||||
<?php echo implode( $toc ); ?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -259,10 +259,14 @@ jQuery( document ).ready( function( $ ) {
|
||||
doNextErasure( 1, 1 );
|
||||
});
|
||||
|
||||
// Privacy policy page, copy button.
|
||||
// Privacy Policy page, copy action.
|
||||
$( document ).on( 'click', function( event ) {
|
||||
var $target = $( event.target );
|
||||
var $parent, $container, range;
|
||||
var $parent,
|
||||
$container,
|
||||
range,
|
||||
__ = wp.i18n.__,
|
||||
$target = $( event.target ),
|
||||
copiedNotice = $target.siblings( '.success' );
|
||||
|
||||
if ( $target.is( 'button.privacy-text-copy' ) ) {
|
||||
$parent = $target.parent().parent();
|
||||
@ -277,22 +281,35 @@ jQuery( document ).ready( function( $ ) {
|
||||
var documentPosition = document.documentElement.scrollTop,
|
||||
bodyPosition = document.body.scrollTop;
|
||||
|
||||
// Setup copy.
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
// Hide tutorial content to remove from copied content.
|
||||
range = document.createRange();
|
||||
$container.addClass( 'hide-privacy-policy-tutorial' );
|
||||
|
||||
// Copy action.
|
||||
range.selectNodeContents( $container[0] );
|
||||
window.getSelection().addRange( range );
|
||||
document.execCommand( 'copy' );
|
||||
|
||||
// Reset section.
|
||||
$container.removeClass( 'hide-privacy-policy-tutorial' );
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
// Return scroll position - see #49540.
|
||||
if ( documentPosition > 0 && documentPosition !== document.documentElement.scrollTop ) {
|
||||
document.documentElement.scrollTop = documentPosition;
|
||||
} else if ( bodyPosition > 0 && bodyPosition !== document.body.scrollTop ) {
|
||||
document.body.scrollTop = bodyPosition;
|
||||
}
|
||||
|
||||
// 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 );
|
||||
} catch ( er ) {}
|
||||
}
|
||||
}
|
||||
|
2
wp-admin/js/privacy-tools.min.js
vendored
2
wp-admin/js/privacy-tools.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
jQuery(document).ready(function(g){var h=window.privacyToolsL10n||{};function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function T(e,t,o,n){var a="",s="request-results";x(e),n.length&&(g.each(n,function(e,t){a=a+"<li>"+t+"</li>"}),a="<ul>"+a+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(s+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(s+=" status-request-failed"),e.after(function(){return'<tr class="'+s+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+o+"</p>"+a+"</div></td></tr>"})}g(".export-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".export-personal-data"),r=t.parents("tr"),n=r.find(".export-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("exporters-count"),l=!!s.data("send-as-email");function p(e){w(s,"export-personal-data-failed"),e&&T(r,"notice-error",h.exportError,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";n.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),s.blur(),x(r),m(0),w(s,"export-personal-data-processing"),function o(n,a){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:n,id:c,page:a,security:d,sendAsEmail:l},method:"post"}).done(function(e){var t=e.data;e.success?t.done?(m(n),n<u?setTimeout(o(n+1,1)):setTimeout(function(){!function(e){var t=h.emailSent;w(s,"export-personal-data-success"),T(r,"notice-success",t,[]),void 0!==e?window.location=e:l||p(h.noExportFile),setTimeout(function(){i.removeClass("processing")},500)}(t.url)},500)):setTimeout(o(n,a+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,o){setTimeout(function(){p(o)},500)})}(1,1)}),g(".remove-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".remove-personal-data"),r=t.parents("tr"),n=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("erasers-count"),l=!1,p=!1,m=[];function f(){w(s,"remove-personal-data-failed"),T(r,"notice-error",h.removalError,[]),setTimeout(function(){i.removeClass("processing")},500)}function v(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";n.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),s.blur(),x(r),v(0),w(s,"remove-personal-data-processing"),function o(n,a){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:n,id:c,page:a,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(l=l||t.items_removed),t.items_retained&&(p=p||t.items_retained),t.messages&&(m=m.concat(t.messages)),t.done?(v(n),n<u?setTimeout(o(n+1,1)):setTimeout(function(){!function(){var e=h.noDataFound,t="notice-success";w(s,"remove-personal-data-success"),!1===l?!1===p?e=h.noDataFound:(e=h.noneRemoved,t="notice-warning"):!1===p?e=h.foundAndRemoved:(e=h.someNotRemoved,t="notice-warning"),T(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)}()},500)):setTimeout(o(n,a+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),g(document).on("click",function(e){var t,o,n,a=g(e.target);if(a.is("button.privacy-text-copy")&&((o=(t=a.parent().parent()).find("div.wp-suggested-text")).length||(o=t.find("div.policy-text")),o.length))try{var s=document.documentElement.scrollTop,r=document.body.scrollTop;window.getSelection().removeAllRanges(),n=document.createRange(),o.addClass("hide-privacy-policy-tutorial"),n.selectNodeContents(o[0]),window.getSelection().addRange(n),document.execCommand("copy"),o.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges(),0<s&&s!==document.documentElement.scrollTop?document.documentElement.scrollTop=s:0<r&&r!==document.body.scrollTop&&(document.body.scrollTop=r)}catch(e){}})});
|
||||
jQuery(document).ready(function(g){var h=window.privacyToolsL10n||{};function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function T(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function x(e,t,o,n){var s="",a="request-results";T(e),n.length&&(g.each(n,function(e,t){s=s+"<li>"+t+"</li>"}),s="<ul>"+s+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(a+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(a+=" status-request-failed"),e.after(function(){return'<tr class="'+a+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+o+"</p>"+s+"</div></td></tr>"})}g(".export-personal-data-handle").click(function(e){var t=g(this),a=t.parents(".export-personal-data"),r=t.parents("tr"),n=r.find(".export-progress"),i=t.parents(".row-actions"),c=a.data("request-id"),d=a.data("nonce"),u=a.data("exporters-count"),l=!!a.data("send-as-email");function p(e){w(a,"export-personal-data-failed"),e&&x(r,"notice-error",h.exportError,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";n.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),a.blur(),T(r),m(0),w(a,"export-personal-data-processing"),function o(n,s){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:n,id:c,page:s,security:d,sendAsEmail:l},method:"post"}).done(function(e){var t=e.data;e.success?t.done?(m(n),n<u?setTimeout(o(n+1,1)):setTimeout(function(){!function(e){var t=h.emailSent;w(a,"export-personal-data-success"),x(r,"notice-success",t,[]),void 0!==e?window.location=e:l||p(h.noExportFile),setTimeout(function(){i.removeClass("processing")},500)}(t.url)},500)):setTimeout(o(n,s+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,o){setTimeout(function(){p(o)},500)})}(1,1)}),g(".remove-personal-data-handle").click(function(e){var t=g(this),a=t.parents(".remove-personal-data"),r=t.parents("tr"),n=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=a.data("request-id"),d=a.data("nonce"),u=a.data("erasers-count"),l=!1,p=!1,m=[];function f(){w(a,"remove-personal-data-failed"),x(r,"notice-error",h.removalError,[]),setTimeout(function(){i.removeClass("processing")},500)}function v(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";n.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),a.blur(),T(r),v(0),w(a,"remove-personal-data-processing"),function o(n,s){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:n,id:c,page:s,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(l=l||t.items_removed),t.items_retained&&(p=p||t.items_retained),t.messages&&(m=m.concat(t.messages)),t.done?(v(n),n<u?setTimeout(o(n+1,1)):setTimeout(function(){!function(){var e=h.noDataFound,t="notice-success";w(a,"remove-personal-data-success"),!1===l?!1===p?e=h.noDataFound:(e=h.noneRemoved,t="notice-warning"):!1===p?e=h.foundAndRemoved:(e=h.someNotRemoved,t="notice-warning"),x(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)}()},500)):setTimeout(o(n,s+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),g(document).on("click",function(e){var t,o,n,s=wp.i18n.__,a=g(e.target),r=a.siblings(".success");if(a.is("button.privacy-text-copy")&&((o=(t=a.parent().parent()).find("div.wp-suggested-text")).length||(o=t.find("div.policy-text")),o.length))try{var i=document.documentElement.scrollTop,c=document.body.scrollTop;window.getSelection().removeAllRanges(),n=document.createRange(),o.addClass("hide-privacy-policy-tutorial"),n.selectNodeContents(o[0]),window.getSelection().addRange(n),document.execCommand("copy"),o.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges(),0<i&&i!==document.documentElement.scrollTop?document.documentElement.scrollTop=i:0<c&&c!==document.body.scrollTop&&(document.body.scrollTop=c),r.addClass("visible"),wp.a11y.speak(s("The section has been copied to your clipboard.")),setTimeout(function(){r.removeClass("visible")},3e3)}catch(e){}})});
|
@ -1417,7 +1417,7 @@ function wp_default_scripts( $scripts ) {
|
||||
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
|
||||
$scripts->set_translations( 'site-health' );
|
||||
|
||||
$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );
|
||||
$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'privacy-tools',
|
||||
'privacyToolsL10n',
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47571';
|
||||
$wp_version = '5.5-alpha-47572';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user