From 31d93c553ac27016e59320feb906bbadae0bb950 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 6 Jul 2020 19:47:03 +0000 Subject: [PATCH] I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/tags.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 #50577. Built from https://develop.svn.wordpress.org/trunk@48347 git-svn-id: http://core.svn.wordpress.org/trunk@48116 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/tags.js | 6 +++--- wp-admin/js/tags.min.js | 2 +- wp-includes/script-loader.php | 9 +-------- wp-includes/version.php | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js index d652ad06d9..a0708b3f42 100644 --- a/wp-admin/js/tags.js +++ b/wp-admin/js/tags.js @@ -7,7 +7,7 @@ * @output wp-admin/js/tags.js */ - /* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */ + /* global ajaxurl, wpAjax, showNotice, validateForm */ jQuery(document).ready(function($) { @@ -55,11 +55,11 @@ jQuery(document).ready(function($) { $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove(); } else if ( '-1' == r ) { - $('#ajax-response').empty().append('

' + tagsl10n.noPerm + '

'); + $('#ajax-response').empty().append('

' + wp.i18n.__( 'Sorry, you are not allowed to do that.' ) + '

'); tr.children().css('backgroundColor', ''); } else { - $('#ajax-response').empty().append('

' + tagsl10n.broken + '

'); + $('#ajax-response').empty().append('

' + wp.i18n.__( 'Something went wrong.' ) + '

'); tr.children().css('backgroundColor', ''); } }); diff --git a/wp-admin/js/tags.min.js b/wp-admin/js/tags.min.js index ae4253c81c..daf01c125e 100644 --- a/wp-admin/js/tags.min.js +++ b/wp-admin/js/tags.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -jQuery(document).ready(function(i){var p=!1;i("#the-list").on("click",".delete-tag",function(){var t,e=i(this),n=e.parents("tr"),a=!0;return"undefined"!=showNotice&&(a=showNotice.warn()),a&&(t=e.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),i.post(ajaxurl,t,function(e){"1"==e?(i("#ajax-response").empty(),n.fadeOut("normal",function(){n.remove()}),i('select#parent option[value="'+t.match(/tag_ID=(\d+)/)[1]+'"]').remove(),i("a.tag-link-"+t.match(/tag_ID=(\d+)/)[1]).remove()):("-1"==e?i("#ajax-response").empty().append('

'+tagsl10n.noPerm+"

"):i("#ajax-response").empty().append('

'+tagsl10n.broken+"

"),n.children().css("backgroundColor",""))}),n.children().css("backgroundColor","#f33")),!1}),i("#edittag").on("click",".delete",function(e){if("undefined"==typeof showNotice)return!0;showNotice.warn()||e.preventDefault()}),i("#submit").click(function(){var o=i(this).parents("form");return validateForm(o)&&(p||(p=!0,o.find(".submit .spinner").addClass("is-active"),i.post(ajaxurl,i("#addtag").serialize(),function(e){var t,n,a,s,r;if(p=!1,o.find(".submit .spinner").removeClass("is-active"),i("#ajax-response").empty(),(t=wpAjax.parseAjaxResponse(e,"ajax-response"))&&!t.errors){if(0<(n=o.find("select#parent").val())&&0'+s+a.name+"")}i('input[type="text"]:visible, textarea:visible',o).val("")}}))),!1})}); \ No newline at end of file +jQuery(document).ready(function(i){var p=!1;i("#the-list").on("click",".delete-tag",function(){var t,e=i(this),n=e.parents("tr"),a=!0;return"undefined"!=showNotice&&(a=showNotice.warn()),a&&(t=e.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),i.post(ajaxurl,t,function(e){"1"==e?(i("#ajax-response").empty(),n.fadeOut("normal",function(){n.remove()}),i('select#parent option[value="'+t.match(/tag_ID=(\d+)/)[1]+'"]').remove(),i("a.tag-link-"+t.match(/tag_ID=(\d+)/)[1]).remove()):("-1"==e?i("#ajax-response").empty().append('

'+wp.i18n.__("Sorry, you are not allowed to do that.")+"

"):i("#ajax-response").empty().append('

'+wp.i18n.__("Something went wrong.")+"

"),n.children().css("backgroundColor",""))}),n.children().css("backgroundColor","#f33")),!1}),i("#edittag").on("click",".delete",function(e){if("undefined"==typeof showNotice)return!0;showNotice.warn()||e.preventDefault()}),i("#submit").click(function(){var o=i(this).parents("form");return validateForm(o)&&(p||(p=!0,o.find(".submit .spinner").addClass("is-active"),i.post(ajaxurl,i("#addtag").serialize(),function(e){var t,n,a,s,r;if(p=!1,o.find(".submit .spinner").removeClass("is-active"),i("#ajax-response").empty(),(t=wpAjax.parseAjaxResponse(e,"ajax-response"))&&!t.errors){if(0<(n=o.find("select#parent").val())&&0'+s+a.name+"")}i('input[type="text"]:visible, textarea:visible',o).val("")}}))),!1})}); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 7ebb7e3a43..e2c1956196 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -1193,14 +1193,7 @@ function wp_default_scripts( $scripts ) { if ( is_admin() ) { $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); - did_action( 'init' ) && $scripts->localize( - 'admin-tags', - 'tagsl10n', - array( - 'noPerm' => __( 'Sorry, you are not allowed to do that.' ), - 'broken' => __( 'Something went wrong.' ), - ) - ); + $scripts->set_translations( 'admin-tags' ); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 ); did_action( 'init' ) && $scripts->localize( diff --git a/wp-includes/version.php b/wp-includes/version.php index cff63ad52b..c9a5e0f79c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48346'; +$wp_version = '5.5-alpha-48347'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.