I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/privacy-tools.js`.
This removes the usage of `wp_localize_script()` for passing translations to the script and instead adds the translatable strings in the script directly through the use of `wp.i18n` and its utilities. Props swissspidy, ocean90, afercia. See #20491. Fixes #50535. Built from https://develop.svn.wordpress.org/trunk@48274 git-svn-id: http://core.svn.wordpress.org/trunk@48043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8d11801c86
commit
07d2c8a4e9
|
@ -6,7 +6,7 @@
|
|||
|
||||
// Privacy request action handling.
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var strings = window.privacyToolsL10n || {},
|
||||
var __ = wp.i18n.__,
|
||||
copiedNoticeTimeout;
|
||||
|
||||
function setActionState( $action, state ) {
|
||||
|
@ -77,7 +77,7 @@ jQuery( document ).ready( function( $ ) {
|
|||
setExportProgress( 0 );
|
||||
|
||||
function onExportDoneSuccess( zipUrl ) {
|
||||
var summaryMessage = strings.emailSent;
|
||||
var summaryMessage = __( 'The personal data export link for this user was sent.' );
|
||||
|
||||
setActionState( $action, 'export-personal-data-success' );
|
||||
|
||||
|
@ -86,16 +86,19 @@ jQuery( document ).ready( function( $ ) {
|
|||
if ( 'undefined' !== typeof zipUrl ) {
|
||||
window.location = zipUrl;
|
||||
} else if ( ! sendAsEmail ) {
|
||||
onExportFailure( strings.noExportFile );
|
||||
onExportFailure( __( 'No personal data export file was generated.' ) );
|
||||
}
|
||||
|
||||
setTimeout( function() { $rowActions.removeClass( 'processing' ); }, 500 );
|
||||
}
|
||||
|
||||
function onExportFailure( errorMessage ) {
|
||||
var summaryMessage = __( 'An error occurred while attempting to export personal data.' );
|
||||
|
||||
setActionState( $action, 'export-personal-data-failed' );
|
||||
|
||||
if ( errorMessage ) {
|
||||
appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] );
|
||||
appendResultsAfterRow( $requestRow, 'notice-error', summaryMessage, [ errorMessage ] );
|
||||
}
|
||||
|
||||
setTimeout( function() { $rowActions.removeClass( 'processing' ); }, 500 );
|
||||
|
@ -175,23 +178,23 @@ jQuery( document ).ready( function( $ ) {
|
|||
setErasureProgress( 0 );
|
||||
|
||||
function onErasureDoneSuccess() {
|
||||
var summaryMessage = strings.noDataFound,
|
||||
var summaryMessage = __( 'No personal data was found for this user.' ),
|
||||
classes = 'notice-success';
|
||||
|
||||
setActionState( $action, 'remove-personal-data-success' );
|
||||
|
||||
if ( false === hasRemoved ) {
|
||||
if ( false === hasRetained ) {
|
||||
summaryMessage = strings.noDataFound;
|
||||
summaryMessage = __( 'No personal data was found for this user.' );
|
||||
} else {
|
||||
summaryMessage = strings.noneRemoved;
|
||||
summaryMessage = __( 'Personal data was found for this user but was not erased.' );
|
||||
classes = 'notice-warning';
|
||||
}
|
||||
} else {
|
||||
if ( false === hasRetained ) {
|
||||
summaryMessage = strings.foundAndRemoved;
|
||||
summaryMessage = __( 'All of the personal data found for this user was erased.' );
|
||||
} else {
|
||||
summaryMessage = strings.someNotRemoved;
|
||||
summaryMessage = __( 'Personal data was found for this user but some of the personal data found was not erased.' );
|
||||
classes = 'notice-warning';
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +204,11 @@ jQuery( document ).ready( function( $ ) {
|
|||
}
|
||||
|
||||
function onErasureFailure() {
|
||||
var summaryMessage = __( 'An error occurred while attempting to find and erase personal data.' );
|
||||
|
||||
setActionState( $action, 'remove-personal-data-failed' );
|
||||
appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] );
|
||||
|
||||
appendResultsAfterRow( $requestRow, 'notice-error', summaryMessage, [] );
|
||||
|
||||
setTimeout( function() { $rowActions.removeClass( 'processing' ); }, 500 );
|
||||
}
|
||||
|
@ -267,7 +273,6 @@ jQuery( document ).ready( function( $ ) {
|
|||
var $parent,
|
||||
$container,
|
||||
range,
|
||||
__ = wp.i18n.__,
|
||||
$target = $( event.target ),
|
||||
copiedNotice = $target.siblings( '.success' );
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
/*! This file is auto-generated */
|
||||
jQuery(document).ready(function(g){var d,h=window.privacyToolsL10n||{};function T(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function w(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";w(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){T(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(),w(r),m(0),T(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;T(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(){T(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(),w(r),v(0),T(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";T(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(clearTimeout(d),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.")),d=setTimeout(function(){r.removeClass("visible")},3e3)}catch(e){}})});
|
||||
jQuery(document).ready(function(h){var c,g=wp.i18n.__;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,a){var s="",n="request-results";T(e),a.length&&(h.each(a,function(e,t){s=s+"<li>"+t+"</li>"}),s="<ul>"+s+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(n+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(n+=" status-request-failed"),e.after(function(){return'<tr class="'+n+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+o+"</p>"+s+"</div></td></tr>"})}h(".export-personal-data-handle").click(function(e){var t=h(this),n=t.parents(".export-personal-data"),r=t.parents("tr"),a=r.find(".export-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),u=n.data("exporters-count"),l=!!n.data("send-as-email");function p(e){var t=g("An error occurred while attempting to export personal data.");w(n,"export-personal-data-failed"),e&&x(r,"notice-error",t,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";a.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.blur(),T(r),m(0),w(n,"export-personal-data-processing"),function o(a,s){h.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:a,id:c,page:s,security:d,sendAsEmail:l},method:"post"}).done(function(e){var t=e.data;e.success?t.done?(m(a),a<u?setTimeout(o(a+1,1)):setTimeout(function(){!function(e){var t=g("The personal data export link for this user was sent.");w(n,"export-personal-data-success"),x(r,"notice-success",t,[]),void 0!==e?window.location=e:l||p(g("No personal data export file was generated.")),setTimeout(function(){i.removeClass("processing")},500)}(t.url)},500)):setTimeout(o(a,s+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,o){setTimeout(function(){p(o)},500)})}(1,1)}),h(".remove-personal-data-handle").click(function(e){var t=h(this),n=t.parents(".remove-personal-data"),r=t.parents("tr"),a=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),u=n.data("erasers-count"),l=!1,p=!1,m=[];function f(){var e=g("An error occurred while attempting to find and erase personal data.");w(n,"remove-personal-data-failed"),x(r,"notice-error",e,[]),setTimeout(function(){i.removeClass("processing")},500)}function v(e){var t=0<u?e/u:0,o=Math.round(100*t).toString()+"%";a.html(o)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.blur(),T(r),v(0),w(n,"remove-personal-data-processing"),function o(a,s){h.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:a,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(a),a<u?setTimeout(o(a+1,1)):setTimeout(function(){!function(){var e=g("No personal data was found for this user."),t="notice-success";w(n,"remove-personal-data-success"),!1===l?!1===p?e=g("No personal data was found for this user."):(e=g("Personal data was found for this user but was not erased."),t="notice-warning"):!1===p?e=g("All of the personal data found for this user was erased."):(e=g("Personal data was found for this user but some of the personal data found was not erased."),t="notice-warning"),x(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)}()},500)):setTimeout(o(a,s+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),h(document).on("click",function(e){var t,o,a,s=h(e.target),n=s.siblings(".success");if(clearTimeout(c),s.is("button.privacy-text-copy")&&((o=(t=s.parent().parent()).find("div.wp-suggested-text")).length||(o=t.find("div.policy-text")),o.length))try{var r=document.documentElement.scrollTop,i=document.body.scrollTop;window.getSelection().removeAllRanges(),a=document.createRange(),o.addClass("hide-privacy-policy-tutorial"),a.selectNodeContents(o[0]),window.getSelection().addRange(a),document.execCommand("copy"),o.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges(),0<r&&r!==document.documentElement.scrollTop?document.documentElement.scrollTop=r:0<i&&i!==document.body.scrollTop&&(document.body.scrollTop=i),n.addClass("visible"),wp.a11y.speak(g("The section has been copied to your clipboard.")),c=setTimeout(function(){n.removeClass("visible")},3e3)}catch(e){}})});
|
|
@ -1205,8 +1205,9 @@ function wp_default_scripts( $scripts ) {
|
|||
|
||||
// To enqueue media-views or media-editor, call wp_enqueue_media().
|
||||
// Both rely on numerous settings, styles, and templates to operate correctly.
|
||||
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n', 'clipboard' ), false, 1 );
|
||||
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'clipboard' ), false, 1 );
|
||||
$scripts->set_translations( 'media-views' );
|
||||
|
||||
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
|
||||
$scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
|
||||
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
|
||||
|
@ -1379,24 +1380,11 @@ 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->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
||||
$scripts->set_translations( 'site-health' );
|
||||
|
||||
$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',
|
||||
array(
|
||||
'noDataFound' => __( 'No personal data was found for this user.' ),
|
||||
'foundAndRemoved' => __( 'All of the personal data found for this user was erased.' ),
|
||||
'noneRemoved' => __( 'Personal data was found for this user but was not erased.' ),
|
||||
'someNotRemoved' => __( 'Personal data was found for this user but some of the personal data found was not erased.' ),
|
||||
'removalError' => __( 'An error occurred while attempting to find and erase personal data.' ),
|
||||
'emailSent' => __( 'The personal data export link for this user was sent.' ),
|
||||
'noExportFile' => __( 'No personal data export file was generated.' ),
|
||||
'exportError' => __( 'An error occurred while attempting to export personal data.' ),
|
||||
)
|
||||
);
|
||||
$scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
|
||||
$scripts->set_translations( 'privacy-tools' );
|
||||
|
||||
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
|
||||
$scripts->set_translations( 'updates' );
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-48273';
|
||||
$wp_version = '5.5-alpha-48274';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue