Plugin Directory

Changeset 3399970


Ignore:
Timestamp:
11/20/2025 06:49:11 PM (4 months ago)
Author:
fishdan
Message:

Release 0.2.8

Location:
fishdan-jsonmaker/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fishdan-jsonmaker/trunk/jsonmaker.php

    r3399881 r3399970  
    44 * Plugin URI: https://www.fishdan.com/jsonmaker
    55 * Description: Manage a hierarchical collection of titled links that can be edited from a shortcode and fetched as JSON.
    6  * Version: 0.2.7
     6 * Version: 0.2.8
    77 * Requires at least: 6.0
    88 * Requires PHP: 7.4
     
    2020
    2121if (! defined('JSONMAKER_VERSION')) {
    22     define('JSONMAKER_VERSION', '0.2.7');
     22    define('JSONMAKER_VERSION', '0.2.8');
    2323}
    2424
     
    679679        $title_key = $this->normalize_title_key($title);
    680680
    681         if ($title_key !== '' && isset($used_titles[$title_key])) {
    682             $error_code = 'import_duplicate_title';
    683 
    684             return null;
    685         }
    686 
    687681        if ($title_key !== '') {
    688682            $used_titles[$title_key] = true;
     
    11341128        }
    11351129        $toolbar_button_id = 'jsonmaker-import-toolbar';
    1136         $default_extension_id = 'hdailbkmbdcililnbemepacdkfdkbhco';
    11371130        echo '<div class="col-12">';
    11381131        echo '<div class="d-flex align-items-center justify-content-between gap-2 mb-2 flex-wrap">';
     
    11411134        echo '</div>';
    11421135        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) . '" />';
    11451136        echo '<div class="form-text text-danger mt-1 d-none" id="jsonmaker-import-extension-status"></div>';
    11461137        echo '</div>';
     
    24042395            "\t\treturn;",
    24052396            "\t}",
    2406             "\tconst extensionInput = document.getElementById('jsonmaker-import-extension-id');",
    24072397            "\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');",
    24102399            "\tif (statusEl) {",
    24112400            "\t\tstatusEl.classList.add('d-none');",
    24122401            "\t\tstatusEl.textContent = '';",
    24132402            "\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;",
    24192407            "\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;",
    24272410            "\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');",
    24332415            "\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.');",
    24352417            "\t\t\t\tstatusEl.classList.remove('d-none');",
    24362418            "\t\t\t}",
    24372419            "\t\t\treturn;",
    24382420            "\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 || '';",
    24482422            "\t\ttextarea.dispatchEvent(new Event('input', { bubbles: true }));",
    2449             "\t\tconst replaceRadio = document.getElementById('jsonmaker-import-mode-replace');",
    24502423            "\t\tif (replaceRadio) {",
    24512424            "\t\t\treplaceRadio.checked = true;",
     
    24562429            "\t\t\tstatusEl.textContent = '';",
    24572430            "\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);",
    24592447            "});"
    24602448        ];
  • fishdan-jsonmaker/trunk/readme.txt

    r3399881 r3399970  
    44Tested up to: 6.9
    55Requires PHP: 7.4
    6 Stable tag: 0.2.7
     6Stable tag: 0.2.8
    77License: MIT
    88License URI: https://opensource.org/licenses/MIT
     
    4444
    4545== 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.
    4650
    4751= 0.2.7 =
Note: See TracChangeset for help on using the changeset viewer.