From 14c1208dae6ab70992a2cd6731f251037c898eb5 Mon Sep 17 00:00:00 2001 From: Alkesh Miyani Date: Wed, 22 Jul 2026 16:41:06 +0530 Subject: [PATCH] Fix i18n gaps in WP-CLI messages and the Quick Create button title Wrap the `wp msls blog` command's success/error messages in esc_html__() so they can be translated, instead of hardcoded English. Fix the Quick Create button's title swap on translated sites: the button previously carried only its "Create..." title, and the JavaScript derived the "Edit..." title by regex-replacing the English word "Create", which silently breaks once that word is translated. Render both the create and edit titles server-side (the edit title as a new data-edit-title attribute) and have the JS read the localized edit title directly instead of doing English-text surgery on it. (cherry picked from commit 58cdee1459b18c6f674cad4e9a29fed05ab4a4c8) --- assets/js/msls-quick-create.js | 2 +- includes/Admin/Icon.php | 11 +++++++---- includes/Cli/Cli.php | 17 +++++++++++++++-- includes/Component/Component.php | 1 + src/msls-quick-create.js | 3 ++- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/assets/js/msls-quick-create.js b/assets/js/msls-quick-create.js index c6763a2e5..311ab2826 100644 --- a/assets/js/msls-quick-create.js +++ b/assets/js/msls-quick-create.js @@ -1 +1 @@ -jQuery(document).ready(function($){$(document).on("click",".msls-quick-create",function(){var $button=$(this);if($button.hasClass("msls-loading")){return}$button.addClass("msls-loading");$button.find(".dashicons").removeClass("dashicons-plus").addClass("dashicons-update");wp.apiFetch({path:"/msls/v1/create-translation",method:"POST",data:{source_post_id:parseInt($button.data("source-post-id"),10),source_blog_id:parseInt($button.data("source-blog-id"),10),target_blog_id:parseInt($button.data("target-blog-id"),10)}}).then(function(response){var isMetabox=$button.closest("#msls").length>0;var $link=$("").attr("href",response.edit_url).attr("title",$button.attr("title").replace(/Create/,"Edit")).html($button.html());if(isMetabox){$link.addClass("msls-edit-link").attr("target","_blank")}var successIcon=isMetabox?"dashicons-external":"dashicons-edit";$link.find(".dashicons").removeClass("dashicons-update dashicons-plus").addClass(successIcon);$button.replaceWith($link);var $container=$link.closest("li");if(!$container.length){return}var $hiddenInput=$container.find('input[type="hidden"][name^="msls_input_"]');if($hiddenInput.length){$hiddenInput.val(response.post_id)}var $titleInput=$container.find("input.msls_title");if($titleInput.length){$titleInput.val(response.post_title||"")}var $select=$container.find('select[name^="msls_input_"]');if($select.length){$select.append($("").attr("href",response.edit_url).attr("title",editTitle).html($button.html());if(isMetabox){$link.addClass("msls-edit-link").attr("target","_blank")}var successIcon=isMetabox?"dashicons-external":"dashicons-edit";$link.find(".dashicons").removeClass("dashicons-update dashicons-plus").addClass(successIcon);$button.replaceWith($link);var $container=$link.closest("li");if(!$container.length){return}var $hiddenInput=$container.find('input[type="hidden"][name^="msls_input_"]');if($hiddenInput.length){$hiddenInput.val(response.post_id)}var $titleInput=$container.find("input.msls_title");if($titleInput.length){$titleInput.val(response.post_title||"")}var $select=$container.find('select[name^="msls_input_"]');if($select.length){$select.append($("' ) .attr( 'href', response.edit_url ) - .attr( 'title', $button.attr( 'title' ).replace( /Create/, 'Edit' ) ) + .attr( 'title', editTitle ) .html( $button.html() ); if ( isMetabox ) {