Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
124 lines
4.1 KiB
JavaScript
124 lines
4.1 KiB
JavaScript
(function ($) {
|
|
'use strict';
|
|
|
|
var root = document.querySelector('[data-jio-post-extension]');
|
|
if (!root || !window.wp || !wp.media) return;
|
|
|
|
function openMedia(button) {
|
|
var wrap = button.closest('.jio-post-extension__upload');
|
|
var input = wrap && wrap.querySelector('[data-media-input]');
|
|
if (!input) return;
|
|
|
|
var library = button.getAttribute('data-library') || 'image';
|
|
var frame = wp.media({
|
|
title: library === 'video' ? '选择视频' : '选择图像',
|
|
library: { type: library },
|
|
multiple: false
|
|
});
|
|
frame.on('select', function () {
|
|
var item = frame.state().get('selection').first().toJSON();
|
|
input.value = item.url || '';
|
|
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
});
|
|
frame.open();
|
|
}
|
|
|
|
function renderGallery() {
|
|
var input = root.querySelector('[data-gallery-input]');
|
|
var preview = root.querySelector('[data-gallery-preview]');
|
|
if (!input || !preview) return;
|
|
|
|
preview.innerHTML = '';
|
|
var ids = input.value.split(',').map(function (id) { return parseInt(id, 10); }).filter(Boolean);
|
|
ids.forEach(function (id) {
|
|
wp.media.attachment(id).fetch().then(function () {
|
|
var data = wp.media.attachment(id).toJSON();
|
|
var img = document.createElement('img');
|
|
img.src = (data.sizes && data.sizes.medium ? data.sizes.medium.url : data.url) || '';
|
|
img.alt = data.alt || '';
|
|
preview.appendChild(img);
|
|
});
|
|
});
|
|
}
|
|
|
|
function openGallery() {
|
|
var input = root.querySelector('[data-gallery-input]');
|
|
if (!input) return;
|
|
var frame = wp.media({ title: '添加图像', library: { type: 'image' }, multiple: true });
|
|
frame.on('open', function () {
|
|
input.value.split(',').map(function (id) { return parseInt(id, 10); }).filter(Boolean).forEach(function (id) {
|
|
frame.state().get('selection').add(wp.media.attachment(id));
|
|
});
|
|
});
|
|
frame.on('select', function () {
|
|
input.value = frame.state().get('selection').map(function (item) { return item.id; }).join(',');
|
|
renderGallery();
|
|
});
|
|
frame.open();
|
|
}
|
|
|
|
function syncVideoDependencies() {
|
|
var input = root.querySelector('input[name="jio_post_extension[featured_video]"]');
|
|
root.querySelectorAll('[data-video-dependent]').forEach(function (field) {
|
|
field.hidden = !input || !input.value.trim();
|
|
});
|
|
}
|
|
|
|
root.addEventListener('click', function (event) {
|
|
var mediaButton = event.target.closest('[data-media-select]');
|
|
if (mediaButton) {
|
|
event.preventDefault();
|
|
openMedia(mediaButton);
|
|
return;
|
|
}
|
|
|
|
var clear = event.target.closest('[data-media-clear]');
|
|
if (clear) {
|
|
event.preventDefault();
|
|
var wrap = clear.closest('.jio-post-extension__upload');
|
|
var input = wrap && wrap.querySelector('[data-media-input]');
|
|
if (input) {
|
|
input.value = '';
|
|
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest('[data-gallery-select]')) {
|
|
event.preventDefault();
|
|
openGallery();
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest('[data-gallery-clear]')) {
|
|
event.preventDefault();
|
|
var galleryInput = root.querySelector('[data-gallery-input]');
|
|
if (galleryInput) galleryInput.value = '';
|
|
renderGallery();
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest('[data-episode-add]')) {
|
|
event.preventDefault();
|
|
var list = root.querySelector('[data-episode-list]');
|
|
var template = root.querySelector('[data-episode-template]');
|
|
if (!list || !template) return;
|
|
var index = list.querySelectorAll('[data-episode-row]').length;
|
|
list.insertAdjacentHTML('beforeend', template.innerHTML.replaceAll('__INDEX__', String(index)));
|
|
return;
|
|
}
|
|
|
|
var remove = event.target.closest('[data-episode-remove]');
|
|
if (remove) {
|
|
event.preventDefault();
|
|
var row = remove.closest('[data-episode-row]');
|
|
if (row) row.remove();
|
|
}
|
|
});
|
|
|
|
root.addEventListener('input', syncVideoDependencies);
|
|
root.addEventListener('change', syncVideoDependencies);
|
|
renderGallery();
|
|
syncVideoDependencies();
|
|
})(jQuery);
|