PluginProbe
AI Builder – Generate pages, blocks, images & translate with AI / 2.7.10
AI Builder – Generate pages, blocks, images & translate with AI v2.7.10
2.8.0 2.7.10 2.7.9 2.7.8 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 All 123 releases
← All changes | assets/js/pattern-translation.js +26 -2 2.1.8 → 2.7.10 View file →
@@ -79,8 +79,30 @@
79 79 document.body.appendChild(button);
80 80 }
81 81 }
82 82
83 + // Same visibility logic as the chat widget:
84 + // hide the floating button on the pattern selection screen (p=/pattern)
85 + // and only show it when a specific template part is being edited.
86 + function shouldShowPatternTranslateButton() {
87 + const isSiteEditor = window.location.pathname.includes('site-editor.php');
88 + if (!isSiteEditor) {
89 + return true; // Always allow outside Site Editor (for safety/future use)
90 + }
91 +
92 + const urlParams = new URLSearchParams(window.location.search);
93 + const pParam = urlParams.get('p');
94 +
95 + // Do not show on:
96 + // 1. No "p" parameter
97 + // 2. p === '/pattern' (pattern chooser screen)
98 + if (!pParam || pParam === '/pattern') {
99 + return false;
100 + }
101 +
102 + return true;
103 + }
104 +
83 105 function getEditedPostContext() {
84 106 const store = select('core/edit-site');
85 107 if (!store || typeof store.getEditedPostId !== 'function') {
86 108 return {};
@@ -177,10 +199,12 @@
177 199 if (!button) return;
178 200
179 201 const { id, type } = getEditedPostContext();
180 202 const isPart = id && type === 'wp_template_part';
181 - button.disabled = !isPart;
182 - button.style.display = isPart ? '' : 'none';
203 + const shouldShow = isPart && shouldShowPatternTranslateButton();
204 +
205 + button.disabled = !shouldShow;
206 + button.style.display = shouldShow ? '' : 'none';
183 207 }
184 208
185 209 document.addEventListener('DOMContentLoaded', () => {
186 210 console.log('[AI Builder] Pattern translation script loaded');