I18N: Use `wp.i18n` for translatable strings in `wp-includes/js/wp-auth-check.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.
See #20491.
Fixes #50553.
Built from https://develop.svn.wordpress.org/trunk@48285


git-svn-id: http://core.svn.wordpress.org/trunk@48054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2020-07-03 19:05:03 +00:00
parent 8e43a329d4
commit 718626a8ce
4 changed files with 4 additions and 10 deletions

View File

@ -23,7 +23,7 @@
if ( form.length ) {
// Add unload confirmation to counter (frame-busting) JS redirects.
$(window).on( 'beforeunload.wp-auth-check', function(e) {
e.originalEvent.returnValue = window.authcheckL10n.beforeunload;
e.originalEvent.returnValue = wp.i18n.__( 'Your session has expired. You can log in again from this page or go to the login page.' );
});
frame = $('<iframe id="wp-auth-check-frame" frameborder="0">').attr( 'title', noframe.text() );

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
!function(h){var d;function s(){h(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(h(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),d.fadeOut(200,function(){d.addClass("hidden").css("display",""),h("#wp-auth-check-frame").remove(),h("body").removeClass("modal-open")})}h(document).on("heartbeat-tick.wp-auth-check",function(e,a){"wp-auth-check"in a&&(!a["wp-auth-check"]&&d.hasClass("hidden")?function(){var e,t=h("#wp-auth-check"),c=h("#wp-auth-check-form"),n=d.find(".wp-auth-fallback-expired"),o=!1;c.length&&(h(window).on("beforeunload.wp-auth-check",function(e){e.originalEvent.returnValue=window.authcheckL10n.beforeunload}),(e=h('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",n.text())).on("load",function(){var e,a;o=!0,c.removeClass("loading");try{e=(a=h(this).contents().find("body")).height()}catch(e){return d.addClass("fallback"),t.css("max-height",""),c.remove(),void n.focus()}e?a&&a.hasClass("interim-login-success")?s():t.css("max-height",e+40+"px"):a&&a.length||(d.addClass("fallback"),t.css("max-height",""),c.remove(),n.focus())}).attr("src",c.data("src")),c.append(e)),h("body").addClass("modal-open"),d.removeClass("hidden"),e?(e.focus(),setTimeout(function(){o||(d.addClass("fallback"),c.remove(),n.focus())},1e4)):n.focus()}():a["wp-auth-check"]&&!d.hasClass("hidden")&&s())}).ready(function(){(d=h("#wp-auth-check-wrap")).find(".wp-auth-check-close").on("click",function(){s()})})}(jQuery);
!function(h){var s;function i(){h(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(h(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),s.fadeOut(200,function(){s.addClass("hidden").css("display",""),h("#wp-auth-check-frame").remove(),h("body").removeClass("modal-open")})}h(document).on("heartbeat-tick.wp-auth-check",function(e,a){"wp-auth-check"in a&&(!a["wp-auth-check"]&&s.hasClass("hidden")?function(){var e,t=h("#wp-auth-check"),n=h("#wp-auth-check-form"),o=s.find(".wp-auth-fallback-expired"),c=!1;n.length&&(h(window).on("beforeunload.wp-auth-check",function(e){e.originalEvent.returnValue=wp.i18n.__("Your session has expired. You can log in again from this page or go to the login page.")}),(e=h('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",o.text())).on("load",function(){var e,a;c=!0,n.removeClass("loading");try{e=(a=h(this).contents().find("body")).height()}catch(e){return s.addClass("fallback"),t.css("max-height",""),n.remove(),void o.focus()}e?a&&a.hasClass("interim-login-success")?i():t.css("max-height",e+40+"px"):a&&a.length||(s.addClass("fallback"),t.css("max-height",""),n.remove(),o.focus())}).attr("src",n.data("src")),n.append(e)),h("body").addClass("modal-open"),s.removeClass("hidden"),e?(e.focus(),setTimeout(function(){c||(s.addClass("fallback"),n.remove(),o.focus())},1e4)):o.focus()}():a["wp-auth-check"]&&!s.hasClass("hidden")&&i())}).ready(function(){(s=h("#wp-auth-check-wrap")).find(".wp-auth-check-close").on("click",function(){i()})})}(jQuery);

View File

@ -699,13 +699,7 @@ function wp_default_scripts( $scripts ) {
);
$scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 );
did_action( 'init' ) && $scripts->localize(
'wp-auth-check',
'authcheckL10n',
array(
'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
)
);
$scripts->set_translations( 'wp-auth-check' );
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48284';
$wp_version = '5.5-alpha-48285';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.