Changeset 3399970
- Timestamp:
- 11/20/2025 06:49:11 PM (4 months ago)
- Location:
- fishdan-jsonmaker/trunk
- Files:
-
- 2 edited
-
jsonmaker.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fishdan-jsonmaker/trunk/jsonmaker.php
r3399881 r3399970 4 4 * Plugin URI: https://www.fishdan.com/jsonmaker 5 5 * Description: Manage a hierarchical collection of titled links that can be edited from a shortcode and fetched as JSON. 6 * Version: 0.2. 76 * Version: 0.2.8 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 20 20 21 21 if (! defined('JSONMAKER_VERSION')) { 22 define('JSONMAKER_VERSION', '0.2. 7');22 define('JSONMAKER_VERSION', '0.2.8'); 23 23 } 24 24 … … 679 679 $title_key = $this->normalize_title_key($title); 680 680 681 if ($title_key !== '' && isset($used_titles[$title_key])) {682 $error_code = 'import_duplicate_title';683 684 return null;685 }686 687 681 if ($title_key !== '') { 688 682 $used_titles[$title_key] = true; … … 1134 1128 } 1135 1129 $toolbar_button_id = 'jsonmaker-import-toolbar'; 1136 $default_extension_id = 'hdailbkmbdcililnbemepacdkfdkbhco';1137 1130 echo '<div class="col-12">'; 1138 1131 echo '<div class="d-flex align-items-center justify-content-between gap-2 mb-2 flex-wrap">'; … … 1141 1134 echo '</div>'; 1142 1135 echo '<textarea id="' . esc_attr($textarea_id) . '" class="form-control" name="jsonmaker_payload" rows="10" required></textarea>'; 1143 echo '<div class="form-text mt-2">' . esc_html__('Optional: set your Chrome extension ID if the import button fails. Leave blank to use the Chrome Web Store ID.', 'fishdan-jsonmaker') . '</div>';1144 echo '<input type="text" class="form-control mt-2" id="jsonmaker-import-extension-id" placeholder="' . esc_attr($default_extension_id) . '" />';1145 1136 echo '<div class="form-text text-danger mt-1 d-none" id="jsonmaker-import-extension-status"></div>'; 1146 1137 echo '</div>'; … … 2404 2395 "\t\treturn;", 2405 2396 "\t}", 2406 "\tconst extensionInput = document.getElementById('jsonmaker-import-extension-id');",2407 2397 "\tconst statusEl = document.getElementById('jsonmaker-import-extension-status');", 2408 "\tconst defaultExtensionId = 'hdailbkmbdcililnbemepacdkfdkbhco';", 2409 "\tconst extensionId = extensionInput && extensionInput.value ? extensionInput.value.trim() : defaultExtensionId;", 2398 "\tconst replaceRadio = document.getElementById('jsonmaker-import-mode-replace');", 2410 2399 "\tif (statusEl) {", 2411 2400 "\t\tstatusEl.classList.add('d-none');", 2412 2401 "\t\tstatusEl.textContent = '';", 2413 2402 "\t}", 2414 "\tif (!extensionId) {", 2415 "\t\tconsole.error('export failed: missing extension id');", 2416 "\t\tif (statusEl) {", 2417 "\t\t\tstatusEl.textContent = 'Export failed: missing extension ID';", 2418 "\t\t\tstatusEl.classList.remove('d-none');", 2403 "\tlet responded = false;", 2404 "\tconst handleExportResponse = function (responseEvent) {", 2405 "\t\tif (responseEvent.source !== window) {", 2406 "\t\t\treturn;", 2419 2407 "\t\t}", 2420 "\t\treturn;", 2421 "\t}", 2422 "\tif (typeof chrome === 'undefined' || !chrome.runtime || !chrome.runtime.sendMessage) {", 2423 "\t\tconsole.error('export failed');", 2424 "\t\tif (statusEl) {", 2425 "\t\t\tstatusEl.textContent = 'Export failed: Chrome runtime not available in this context. Make sure the extension can run on this page.';", 2426 "\t\t\tstatusEl.classList.remove('d-none');", 2408 "\t\tif (!responseEvent.data || responseEvent.data.type !== 'SUBSCRIBED_TOOLBAR_EXPORT_RESULT') {", 2409 "\t\t\treturn;", 2427 2410 "\t\t}", 2428 "\t\treturn;", 2429 "\t}", 2430 "\tchrome.runtime.sendMessage(extensionId, { type: 'EXPORT_SUBSCRIBED_FOLDER' }, {}, function (res) {", 2431 "\t\tif (chrome.runtime && chrome.runtime.lastError) {", 2432 "\t\t\tconsole.error(chrome.runtime.lastError.message || 'export failed');", 2411 "\t\twindow.removeEventListener('message', handleExportResponse);", 2412 "\t\tresponded = true;", 2413 "\t\tif (!responseEvent.data.ok) {", 2414 "\t\t\tconsole.error(responseEvent.data.error || 'export failed');", 2433 2415 "\t\t\tif (statusEl) {", 2434 "\t\t\t\tstatusEl.textContent = 'Export failed: ' + ( chrome.runtime.lastError.message || 'extension not reachable. Check host permissions and ID.');",2416 "\t\t\t\tstatusEl.textContent = 'Export failed: ' + (responseEvent.data.error || 'extension did not return data. Check host permissions.');", 2435 2417 "\t\t\t\tstatusEl.classList.remove('d-none');", 2436 2418 "\t\t\t}", 2437 2419 "\t\t\treturn;", 2438 2420 "\t\t}", 2439 "\t\tif (!res || res.ok !== true) {", 2440 "\t\t\tconsole.error((res && res.error) ? res.error : 'export failed');", 2441 "\t\t\tif (statusEl) {", 2442 "\t\t\t\tstatusEl.textContent = 'Export failed: ' + ((res && res.error) ? res.error : 'extension did not return data.');", 2443 "\t\t\t\tstatusEl.classList.remove('d-none');", 2444 "\t\t\t}", 2445 "\t\t\treturn;", 2446 "\t\t}", 2447 "\t\ttextarea.value = res.json || '';", 2421 "\t\ttextarea.value = responseEvent.data.json || '';", 2448 2422 "\t\ttextarea.dispatchEvent(new Event('input', { bubbles: true }));", 2449 "\t\tconst replaceRadio = document.getElementById('jsonmaker-import-mode-replace');",2450 2423 "\t\tif (replaceRadio) {", 2451 2424 "\t\t\treplaceRadio.checked = true;", … … 2456 2429 "\t\t\tstatusEl.textContent = '';", 2457 2430 "\t\t}", 2458 "\t});", 2431 "\t};", 2432 "\twindow.addEventListener('message', handleExportResponse);", 2433 "\tif (typeof window.postMessage !== 'function') {", 2434 "\t\tif (statusEl) {", 2435 "\t\t\tstatusEl.textContent = 'Export failed: window.postMessage not available in this context.';", 2436 "\t\t\tstatusEl.classList.remove('d-none');", 2437 "\t\t}", 2438 "\t\treturn;", 2439 "\t}", 2440 "\twindow.postMessage({ type: 'SUBSCRIBED_TOOLBAR_EXPORT' }, '*');", 2441 "\tsetTimeout(function () {", 2442 "\t\tif (!responded && statusEl) {", 2443 "\t\t\tstatusEl.textContent = 'Export failed: extension did not respond. Check that host permissions are granted and the extension is running.';", 2444 "\t\t\tstatusEl.classList.remove('d-none');", 2445 "\t\t}", 2446 "\t}, 2000);", 2459 2447 "});" 2460 2448 ]; -
fishdan-jsonmaker/trunk/readme.txt
r3399881 r3399970 4 4 Tested up to: 6.9 5 5 Requires PHP: 7.4 6 Stable tag: 0.2. 76 Stable tag: 0.2.8 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 44 44 45 45 == Changelog == 46 47 = 0.2.8 = 48 * Removed the optional extension ID text field from the toolbar import UX now that the browser postMessage flow handles extension discovery automatically. 49 * Relaxed import validation to allow repeating node titles (unique slugs are still generated) so toolbar exports with duplicate titles no longer fail. 46 50 47 51 = 0.2.7 =
Note: See TracChangeset
for help on using the changeset viewer.