Changeset 3399881
- Timestamp:
- 11/20/2025 03:57:03 PM (6 weeks ago)
- Location:
- fishdan-jsonmaker/trunk
- Files:
-
- 2 edited
-
jsonmaker.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fishdan-jsonmaker/trunk/jsonmaker.php
r3399816 r3399881 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. 66 * Version: 0.2.7 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. 6');22 define('JSONMAKER_VERSION', '0.2.7'); 23 23 } 24 24 … … 1133 1133 echo '</div>'; 1134 1134 } 1135 $toolbar_button_id = 'jsonmaker-import-toolbar'; 1136 $default_extension_id = 'hdailbkmbdcililnbemepacdkfdkbhco'; 1135 1137 echo '<div class="col-12">'; 1136 echo '<label for="' . esc_attr($textarea_id) . '" class="form-label">' . esc_html__('JSON payload', 'fishdan-jsonmaker') . '</label>'; 1138 echo '<div class="d-flex align-items-center justify-content-between gap-2 mb-2 flex-wrap">'; 1139 echo '<label for="' . esc_attr($textarea_id) . '" class="form-label mb-0">' . esc_html__('JSON payload', 'fishdan-jsonmaker') . '</label>'; 1140 echo '<button type="button" class="btn btn-outline-secondary btn-sm" id="' . esc_attr($toolbar_button_id) . '">' . esc_html__('Import current toolbar', 'fishdan-jsonmaker') . '</button>'; 1141 echo '</div>'; 1137 1142 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 echo '<div class="form-text text-danger mt-1 d-none" id="jsonmaker-import-extension-status"></div>'; 1138 1146 echo '</div>'; 1139 1147 echo '<div class="col-12 d-flex gap-2">'; … … 2385 2393 "\t\t}", 2386 2394 "\t}", 2395 "});", 2396 "document.addEventListener('click', function (event) {", 2397 "\tconst importButton = event.target.closest('#jsonmaker-import-toolbar');", 2398 "\tif (!importButton) {", 2399 "\t\treturn;", 2400 "\t}", 2401 "\tevent.preventDefault();", 2402 "\tconst textarea = document.getElementById('jsonmaker-import-payload');", 2403 "\tif (!textarea) {", 2404 "\t\treturn;", 2405 "\t}", 2406 "\tconst extensionInput = document.getElementById('jsonmaker-import-extension-id');", 2407 "\tconst statusEl = document.getElementById('jsonmaker-import-extension-status');", 2408 "\tconst defaultExtensionId = 'hdailbkmbdcililnbemepacdkfdkbhco';", 2409 "\tconst extensionId = extensionInput && extensionInput.value ? extensionInput.value.trim() : defaultExtensionId;", 2410 "\tif (statusEl) {", 2411 "\t\tstatusEl.classList.add('d-none');", 2412 "\t\tstatusEl.textContent = '';", 2413 "\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');", 2419 "\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');", 2427 "\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');", 2433 "\t\t\tif (statusEl) {", 2434 "\t\t\t\tstatusEl.textContent = 'Export failed: ' + (chrome.runtime.lastError.message || 'extension not reachable. Check host permissions and ID.');", 2435 "\t\t\t\tstatusEl.classList.remove('d-none');", 2436 "\t\t\t}", 2437 "\t\t\treturn;", 2438 "\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 || '';", 2448 "\t\ttextarea.dispatchEvent(new Event('input', { bubbles: true }));", 2449 "\t\tconst replaceRadio = document.getElementById('jsonmaker-import-mode-replace');", 2450 "\t\tif (replaceRadio) {", 2451 "\t\t\treplaceRadio.checked = true;", 2452 "\t\t\treplaceRadio.dispatchEvent(new Event('change', { bubbles: true }));", 2453 "\t\t}", 2454 "\t\tif (statusEl) {", 2455 "\t\t\tstatusEl.classList.add('d-none');", 2456 "\t\t\tstatusEl.textContent = '';", 2457 "\t\t}", 2458 "\t});", 2387 2459 "});" 2388 2460 ]; -
fishdan-jsonmaker/trunk/readme.txt
r3399816 r3399881 4 4 Tested up to: 6.9 5 5 Requires PHP: 7.4 6 Stable tag: 0.2. 66 Stable tag: 0.2.7 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 44 44 45 45 == Changelog == 46 47 = 0.2.7 = 48 * Added “Import current toolbar” button that can pull JSON directly from the Subscribed Toolbar extension. 49 * Optional extension ID field plus visible error feedback when the extension isn’t reachable. 50 * Successful extension imports now auto-select “Replace entire tree” to overwrite the current tree. 46 51 47 52 = 0.2.6 =
Note: See TracChangeset
for help on using the changeset viewer.