refactor: rename the theme brand and every identifier from AKSRT to Jio
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>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -8,8 +8,8 @@ defined('ABSPATH') || exit;
|
||||
* Lazy widget form endpoint and admin-only assets.
|
||||
*/
|
||||
final class AdminFormController {
|
||||
public const AJAX_ACTION = 'aksrt_widget_form';
|
||||
private const NONCE_ACTION = 'aksrt_widget_form';
|
||||
public const AJAX_ACTION = 'jio_widget_form';
|
||||
private const NONCE_ACTION = 'jio_widget_form';
|
||||
|
||||
public static function register_hooks(): void {
|
||||
add_action('wp_ajax_' . self::AJAX_ACTION, [self::class, 'ajax_form']);
|
||||
@@ -26,13 +26,13 @@ final class AdminFormController {
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
wp_enqueue_script('jquery-ui-sortable');
|
||||
wp_enqueue_style('aksrt-widget-admin', AKSRT_URI . '/assets/widgets/admin.css', ['wp-color-picker'], AKSRT_VERSION);
|
||||
wp_enqueue_style('aksrt-widget-preview', AKSRT_URI . '/assets/widgets/frontend.css', [], AKSRT_VERSION);
|
||||
aksrt_icon_picker_assets(['wp-color-picker']);
|
||||
wp_enqueue_script('aksrt-widget-admin-core', AKSRT_URI . '/assets/widgets/admin-core.js', [], AKSRT_VERSION, true);
|
||||
wp_enqueue_script('aksrt-widget-admin', AKSRT_URI . '/assets/widgets/admin.js', ['jquery', 'jquery-ui-sortable', 'wp-color-picker', 'aksrt-widget-admin-core'], AKSRT_VERSION, true);
|
||||
wp_enqueue_script('aksrt-widget-admin-transfer', AKSRT_URI . '/assets/widgets/admin-transfer.js', ['jquery', 'aksrt-widget-admin'], AKSRT_VERSION, true);
|
||||
wp_localize_script('aksrt-widget-admin', 'aksrtWidgetAdmin', [
|
||||
wp_enqueue_style('jio-widget-admin', JIO_URI . '/assets/widgets/admin.css', ['wp-color-picker'], JIO_VERSION);
|
||||
wp_enqueue_style('jio-widget-preview', JIO_URI . '/assets/widgets/frontend.css', [], JIO_VERSION);
|
||||
jio_icon_picker_assets(['wp-color-picker']);
|
||||
wp_enqueue_script('jio-widget-admin-core', JIO_URI . '/assets/widgets/admin-core.js', [], JIO_VERSION, true);
|
||||
wp_enqueue_script('jio-widget-admin', JIO_URI . '/assets/widgets/admin.js', ['jquery', 'jquery-ui-sortable', 'wp-color-picker', 'jio-widget-admin-core'], JIO_VERSION, true);
|
||||
wp_enqueue_script('jio-widget-admin-transfer', JIO_URI . '/assets/widgets/admin-transfer.js', ['jquery', 'jio-widget-admin'], JIO_VERSION, true);
|
||||
wp_localize_script('jio-widget-admin', 'jioWidgetAdmin', [
|
||||
'ajaxUrl' => admin_url('admin-ajax.php'),
|
||||
'action' => self::AJAX_ACTION,
|
||||
'nonce' => wp_create_nonce(self::NONCE_ACTION),
|
||||
@@ -44,55 +44,55 @@ final class AdminFormController {
|
||||
/** @return array<string,string> */
|
||||
private static function i18n(): array {
|
||||
return [
|
||||
'loading' => __('正在加载模块配置…', 'aksrt'),
|
||||
'error' => __('加载失败,请刷新页面后重试', 'aksrt'),
|
||||
'confirmImportReplace' => __('将覆盖当前容器中已有的全部模块,导入内容将替换该侧栏;确定继续?', 'aksrt'),
|
||||
'confirmImportAppend' => __('将在当前容器已有模块列表末尾追加导入内容,不会删除原有模块;确定继续?', 'aksrt'),
|
||||
'importModeLabel' => __('导入方式', 'aksrt'),
|
||||
'importModeReplace' => __('覆盖(替换现有)', 'aksrt'),
|
||||
'importModeAppend' => __('追加(保留现有)', 'aksrt'),
|
||||
'loadingExport' => __('正在生成 JSON…', 'aksrt'),
|
||||
'loadingImport' => __('正在导入…', 'aksrt'),
|
||||
'copyDone' => __('已复制', 'aksrt'),
|
||||
'copyFail' => __('复制失败,请手动全选复制', 'aksrt'),
|
||||
'exportTitle' => __('导出 JSON(可复制)', 'aksrt'),
|
||||
'importTitle' => __('导入 JSON(粘贴后确认)', 'aksrt'),
|
||||
'importHint' => __('将导出得到的 JSON 粘贴到下方文本框以导入。注意:不同主题版本或非同站的的模块导入后可能会出现错误,此时可以重新配置一下有错误的模块,即可恢复正常', 'aksrt'),
|
||||
'exportHint' => __('以下为当前容器模块数据,可直接全选复制保存。', 'aksrt'),
|
||||
'close' => __('关闭', 'aksrt'),
|
||||
'copy' => __('复制全部', 'aksrt'),
|
||||
'submitImport' => __('确认导入', 'aksrt'),
|
||||
'reloadPage' => __('刷新页面', 'aksrt'),
|
||||
'templateModalTitle' => __('从模板导入', 'aksrt'),
|
||||
'templateHint' => __('使用模板可快速配置网站布局,选择对应的模板点击导入即可。', 'aksrt') . '<div class="aksrt-wie-remind"><b>' . __('注意事项:', 'aksrt') . '</b>' . __('1.导入模板必须对容器位置对应,例如不能将侧边栏模板导入到全宽度中!', 'aksrt') . '<br>' . __('2.导入模板需已经有对应的内容,例如:导入文章相关的模板,那么至少已经有多篇文章和文章分类', 'aksrt') . '</div>',
|
||||
'templateLoadingList' => __('正在加载模板列表…', 'aksrt'),
|
||||
'templateEmpty' => __('暂无可用模板。', 'aksrt'),
|
||||
'templateSubmit' => __('导入所选模板', 'aksrt'),
|
||||
'confirmTemplate' => __('确定导入模板「{title}」吗?导入方式:{mode}', 'aksrt'),
|
||||
'templatePick' => __('请选择一个模板。', 'aksrt'),
|
||||
'exportFailed' => __('导出失败', 'aksrt'),
|
||||
'importSuccess' => __('导入成功', 'aksrt'),
|
||||
'importFailed' => __('导入失败', 'aksrt'),
|
||||
'pasteJsonFirst' => __('请先粘贴 JSON', 'aksrt'),
|
||||
'exportModules' => __('导出模块', 'aksrt'),
|
||||
'importModules' => __('导入模块', 'aksrt'),
|
||||
'importTemplate' => __('模板导入', 'aksrt'),
|
||||
'removeModule' => __('移出模块', 'aksrt'),
|
||||
'networkError' => __('网络错误,请刷新页面后重试', 'aksrt'),
|
||||
'loading' => __('正在加载模块配置…', 'jio'),
|
||||
'error' => __('加载失败,请刷新页面后重试', 'jio'),
|
||||
'confirmImportReplace' => __('将覆盖当前容器中已有的全部模块,导入内容将替换该侧栏;确定继续?', 'jio'),
|
||||
'confirmImportAppend' => __('将在当前容器已有模块列表末尾追加导入内容,不会删除原有模块;确定继续?', 'jio'),
|
||||
'importModeLabel' => __('导入方式', 'jio'),
|
||||
'importModeReplace' => __('覆盖(替换现有)', 'jio'),
|
||||
'importModeAppend' => __('追加(保留现有)', 'jio'),
|
||||
'loadingExport' => __('正在生成 JSON…', 'jio'),
|
||||
'loadingImport' => __('正在导入…', 'jio'),
|
||||
'copyDone' => __('已复制', 'jio'),
|
||||
'copyFail' => __('复制失败,请手动全选复制', 'jio'),
|
||||
'exportTitle' => __('导出 JSON(可复制)', 'jio'),
|
||||
'importTitle' => __('导入 JSON(粘贴后确认)', 'jio'),
|
||||
'importHint' => __('将导出得到的 JSON 粘贴到下方文本框以导入。注意:不同主题版本或非同站的的模块导入后可能会出现错误,此时可以重新配置一下有错误的模块,即可恢复正常', 'jio'),
|
||||
'exportHint' => __('以下为当前容器模块数据,可直接全选复制保存。', 'jio'),
|
||||
'close' => __('关闭', 'jio'),
|
||||
'copy' => __('复制全部', 'jio'),
|
||||
'submitImport' => __('确认导入', 'jio'),
|
||||
'reloadPage' => __('刷新页面', 'jio'),
|
||||
'templateModalTitle' => __('从模板导入', 'jio'),
|
||||
'templateHint' => __('使用模板可快速配置网站布局,选择对应的模板点击导入即可。', 'jio') . '<div class="jio-wie-remind"><b>' . __('注意事项:', 'jio') . '</b>' . __('1.导入模板必须对容器位置对应,例如不能将侧边栏模板导入到全宽度中!', 'jio') . '<br>' . __('2.导入模板需已经有对应的内容,例如:导入文章相关的模板,那么至少已经有多篇文章和文章分类', 'jio') . '</div>',
|
||||
'templateLoadingList' => __('正在加载模板列表…', 'jio'),
|
||||
'templateEmpty' => __('暂无可用模板。', 'jio'),
|
||||
'templateSubmit' => __('导入所选模板', 'jio'),
|
||||
'confirmTemplate' => __('确定导入模板「{title}」吗?导入方式:{mode}', 'jio'),
|
||||
'templatePick' => __('请选择一个模板。', 'jio'),
|
||||
'exportFailed' => __('导出失败', 'jio'),
|
||||
'importSuccess' => __('导入成功', 'jio'),
|
||||
'importFailed' => __('导入失败', 'jio'),
|
||||
'pasteJsonFirst' => __('请先粘贴 JSON', 'jio'),
|
||||
'exportModules' => __('导出模块', 'jio'),
|
||||
'importModules' => __('导入模块', 'jio'),
|
||||
'importTemplate' => __('模板导入', 'jio'),
|
||||
'removeModule' => __('移出模块', 'jio'),
|
||||
'networkError' => __('网络错误,请刷新页面后重试', 'jio'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function ajax_form(): void {
|
||||
check_ajax_referer(self::NONCE_ACTION, 'nonce');
|
||||
if (!current_user_can('edit_theme_options')) {
|
||||
wp_send_json_error(['message' => __('权限不足。', 'aksrt')], 403);
|
||||
wp_send_json_error(['message' => __('权限不足。', 'jio')], 403);
|
||||
}
|
||||
|
||||
$id_base = isset($_POST['id_base']) ? sanitize_key(wp_unslash($_POST['id_base'])) : '';
|
||||
$number = isset($_POST['widget_number']) ? absint($_POST['widget_number']) : 0;
|
||||
$definition = WidgetRegistry::get_by_id_base($id_base);
|
||||
if (!$definition || $number < 1) {
|
||||
wp_send_json_error(['message' => __('无效的小工具实例。', 'aksrt')], 400);
|
||||
wp_send_json_error(['message' => __('无效的小工具实例。', 'jio')], 400);
|
||||
}
|
||||
|
||||
$widget = new SchemaWidget($definition);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Registers the isolated widget bundle and optional interaction libraries. */
|
||||
final class AssetManager {
|
||||
private const STYLE_HANDLE = 'aksrt-widget-system';
|
||||
private const SCRIPT_HANDLE = 'aksrt-widgets';
|
||||
private const STYLE_HANDLE = 'jio-widget-system';
|
||||
private const SCRIPT_HANDLE = 'jio-widgets';
|
||||
|
||||
private static bool $registered = false;
|
||||
private static bool $configured = false;
|
||||
@@ -24,7 +24,7 @@ final class AssetManager {
|
||||
public static function enqueue_for(WidgetDefinition $definition): void {
|
||||
self::register();
|
||||
if ($definition->slug() === 'post_pay') {
|
||||
wp_enqueue_style('aksrt-pay-box');
|
||||
wp_enqueue_style('jio-pay-box');
|
||||
}
|
||||
foreach ($definition->assets() as $asset) {
|
||||
self::enqueue_optional($asset);
|
||||
@@ -33,14 +33,14 @@ final class AssetManager {
|
||||
wp_enqueue_script(self::SCRIPT_HANDLE);
|
||||
if (!self::$configured) {
|
||||
$config = [
|
||||
'restUrl' => esc_url_raw(rest_url('aksrt/v1/widgets/')),
|
||||
'restUrl' => esc_url_raw(rest_url('jio/v1/widgets/')),
|
||||
'i18n' => [
|
||||
'loading' => __('正在加载…', 'aksrt'),
|
||||
'error' => __('加载失败,请重试。', 'aksrt'),
|
||||
'retry' => __('重试', 'aksrt'),
|
||||
'loading' => __('正在加载…', 'jio'),
|
||||
'error' => __('加载失败,请重试。', 'jio'),
|
||||
'retry' => __('重试', 'jio'),
|
||||
],
|
||||
];
|
||||
wp_add_inline_script(self::SCRIPT_HANDLE, 'window.aksrtWidgets=' . wp_json_encode($config) . ';', 'before');
|
||||
wp_add_inline_script(self::SCRIPT_HANDLE, 'window.jioWidgets=' . wp_json_encode($config) . ';', 'before');
|
||||
self::$configured = true;
|
||||
}
|
||||
}
|
||||
@@ -54,17 +54,17 @@ final class AssetManager {
|
||||
$css = $root . '/assets/widgets/frontend.css';
|
||||
$pay_css = $root . '/assets/css/frontend/pay-box.css';
|
||||
$js = $root . '/assets/widgets/frontend.js';
|
||||
wp_register_style(self::STYLE_HANDLE, $uri . '/assets/widgets/frontend.css', ['aksrt-public'], is_file($css) ? (string) filemtime($css) : null);
|
||||
wp_register_style('aksrt-pay-box', $uri . '/assets/css/frontend/pay-box.css', ['aksrt-public'], is_file($pay_css) ? (string) filemtime($pay_css) : null);
|
||||
wp_register_style(self::STYLE_HANDLE, $uri . '/assets/widgets/frontend.css', ['jio-public'], is_file($css) ? (string) filemtime($css) : null);
|
||||
wp_register_style('jio-pay-box', $uri . '/assets/css/frontend/pay-box.css', ['jio-public'], is_file($pay_css) ? (string) filemtime($pay_css) : null);
|
||||
$yiyan_js = $root . '/assets/js/yiyan.js';
|
||||
wp_register_script('aksrt-yiyan', $uri . '/assets/js/yiyan.js', ['loader_js'], is_file($yiyan_js) ? (string) filemtime($yiyan_js) : null, true);
|
||||
wp_register_script(self::SCRIPT_HANDLE, $uri . '/assets/widgets/frontend.js', ['loader_js', 'aksrt-yiyan'], is_file($js) ? (string) filemtime($js) : null, true);
|
||||
wp_register_script('jio-yiyan', $uri . '/assets/js/yiyan.js', ['loader_js'], is_file($yiyan_js) ? (string) filemtime($yiyan_js) : null, true);
|
||||
wp_register_script(self::SCRIPT_HANDLE, $uri . '/assets/widgets/frontend.js', ['loader_js', 'jio-yiyan'], is_file($js) ? (string) filemtime($js) : null, true);
|
||||
$third_party = $uri . '/assets/widgets/third-party/';
|
||||
wp_register_script('aksrt-widget-hls', $third_party . 'hls.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('aksrt-widget-flv', $third_party . 'flv.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('aksrt-widget-dash', $third_party . 'dash.all.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('aksrt-widget-dplayer', $third_party . 'DPlayer.min.js', ['aksrt-widget-hls', 'aksrt-widget-flv', 'aksrt-widget-dash'], 'reference-pinned', true);
|
||||
wp_register_script('aksrt-widget-tilt', $third_party . 'vanilla-tilt.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('jio-widget-hls', $third_party . 'hls.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('jio-widget-flv', $third_party . 'flv.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('jio-widget-dash', $third_party . 'dash.all.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('jio-widget-dplayer', $third_party . 'DPlayer.min.js', ['jio-widget-hls', 'jio-widget-flv', 'jio-widget-dash'], 'reference-pinned', true);
|
||||
wp_register_script('jio-widget-tilt', $third_party . 'vanilla-tilt.min.js', [], 'reference-pinned', true);
|
||||
self::$registered = true;
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ final class AssetManager {
|
||||
if ($asset === 'swiper') {
|
||||
// legacy main.js owns the single Swiper runtime and discovers .new-swiper.
|
||||
} elseif ($asset === 'dplayer') {
|
||||
wp_enqueue_script('aksrt-widget-dplayer');
|
||||
wp_enqueue_script('jio-widget-dplayer');
|
||||
} elseif (in_array($asset, ['hls', 'flv', 'dash'], true)) {
|
||||
wp_enqueue_script('aksrt-widget-' . $asset);
|
||||
wp_enqueue_script('jio-widget-' . $asset);
|
||||
} elseif ($asset === 'tilt') {
|
||||
wp_enqueue_script('aksrt-widget-tilt');
|
||||
wp_enqueue_script('jio-widget-tilt');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -79,10 +79,10 @@ final class FieldSchema {
|
||||
case 'upload':
|
||||
return esc_url_raw((string) $value);
|
||||
case 'color':
|
||||
return \AKSRT\Core\Color::sanitize($value, true);
|
||||
return \Jio\Core\Color::sanitize($value, true);
|
||||
case 'icon':
|
||||
return function_exists('aksrt_sanitize_icon_value')
|
||||
? aksrt_sanitize_icon_value((string) $value)
|
||||
return function_exists('jio_sanitize_icon_value')
|
||||
? jio_sanitize_icon_value((string) $value)
|
||||
: sanitize_text_field((string) $value);
|
||||
case 'textarea':
|
||||
if (($field['sanitize'] ?? '') === 'rich_html') {
|
||||
@@ -115,8 +115,8 @@ final class FieldSchema {
|
||||
* would strip the exact markup legacy/Zibll renders verbatim.
|
||||
*/
|
||||
private static function rich_inline_html(string $value): string {
|
||||
return function_exists('aksrt_icon_card_kses')
|
||||
? aksrt_icon_card_kses($value)
|
||||
return function_exists('jio_icon_card_kses')
|
||||
? jio_icon_card_kses($value)
|
||||
: wp_kses_post($value);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ final class FieldSchema {
|
||||
private static function background($value): array {
|
||||
$value = is_array($value) ? $value : [];
|
||||
return [
|
||||
'color' => \AKSRT\Core\Color::sanitize($value['color'] ?? '', true),
|
||||
'color' => \Jio\Core\Color::sanitize($value['color'] ?? '', true),
|
||||
'image' => esc_url_raw((string) ($value['image'] ?? '')),
|
||||
'position' => self::allow((string) ($value['position'] ?? 'center center'), ['center center', 'top center', 'bottom center', 'center left', 'center right'], 'center center'),
|
||||
'repeat' => self::allow((string) ($value['repeat'] ?? 'no-repeat'), ['no-repeat', 'repeat', 'repeat-x', 'repeat-y'], 'no-repeat'),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -9,7 +9,7 @@ defined('ABSPATH') || exit;
|
||||
*/
|
||||
final class FormRenderer {
|
||||
public static function render(SchemaWidget $widget, array $fields, array $instance): void {
|
||||
echo '<div class="aksrt-widget-form" data-aksrt-widget-form="1">';
|
||||
echo '<div class="jio-widget-form" data-jio-widget-form="1">';
|
||||
foreach ($fields as $field) {
|
||||
self::field($widget, $field, $instance[(string) ($field['id'] ?? '')] ?? ($field['default'] ?? ''), '');
|
||||
}
|
||||
@@ -38,10 +38,10 @@ final class FormRenderer {
|
||||
}
|
||||
echo '>';
|
||||
if (!empty($field['label'])) {
|
||||
echo '<label class="aksrt-widget-field__label" for="' . esc_attr($field_id) . '">' . esc_html((string) $field['label']) . '</label>';
|
||||
echo '<label class="jio-widget-field__label" for="' . esc_attr($field_id) . '">' . esc_html((string) $field['label']) . '</label>';
|
||||
}
|
||||
if (!empty($field['subtitle'])) {
|
||||
echo '<p class="aksrt-widget-field__subtitle">' . esc_html((string) $field['subtitle']) . '</p>';
|
||||
echo '<p class="jio-widget-field__subtitle">' . esc_html((string) $field['subtitle']) . '</p>';
|
||||
}
|
||||
if (!empty($field['description'])) {
|
||||
echo '<p class="description">' . wp_kses_post((string) $field['description']) . '</p>';
|
||||
@@ -79,10 +79,10 @@ final class FormRenderer {
|
||||
self::upload($field_id, $field_name, (string) $value, (string) ($field['library'] ?? ''));
|
||||
break;
|
||||
case 'color':
|
||||
echo '<input class="widefat aksrt-widget-color" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '">';
|
||||
echo '<input class="widefat jio-widget-color" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '">';
|
||||
break;
|
||||
case 'icon':
|
||||
echo aksrt_icon_picker_field($field_name, $field_id, (string) $value);
|
||||
echo jio_icon_picker_field($field_name, $field_id, (string) $value);
|
||||
break;
|
||||
case 'link':
|
||||
self::link($widget, $key, is_array($value) ? $value : []);
|
||||
@@ -112,14 +112,14 @@ final class FormRenderer {
|
||||
$class = self::field_class($field, $type);
|
||||
if ($type === 'submessage') {
|
||||
$style = in_array($field['style'] ?? '', ['success', 'info', 'warning', 'danger'], true) ? $field['style'] : 'normal';
|
||||
$class .= ' aksrt-widget-field--submessage-' . $style;
|
||||
$class .= ' jio-widget-field--submessage-' . $style;
|
||||
}
|
||||
echo '<div class="' . esc_attr($class) . '">' . wp_kses_post($content) . '</div>';
|
||||
}
|
||||
|
||||
/** Reference CSF row classes: type modifier plus schema `class` (e.g. compact) and `inline`. */
|
||||
private static function field_class(array $field, string $type): string {
|
||||
$classes = ['aksrt-widget-field', 'aksrt-widget-field--' . $type];
|
||||
$classes = ['jio-widget-field', 'jio-widget-field--' . $type];
|
||||
foreach (preg_split('/\s+/', trim((string) ($field['class'] ?? ''))) ?: [] as $extra) {
|
||||
if ($extra !== '') {
|
||||
$classes[] = 'is-' . sanitize_html_class($extra);
|
||||
@@ -133,11 +133,11 @@ final class FormRenderer {
|
||||
|
||||
private static function switcher(string $id, string $name, bool $value): void {
|
||||
echo '<input type="hidden" name="' . esc_attr($name) . '" value="0">';
|
||||
echo '<label class="aksrt-widget-switch"><input type="checkbox" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="1" ' . checked($value, true, false) . '><span aria-hidden="true"></span></label>';
|
||||
echo '<label class="jio-widget-switch"><input type="checkbox" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="1" ' . checked($value, true, false) . '><span aria-hidden="true"></span></label>';
|
||||
}
|
||||
|
||||
private static function radios(string $id, string $name, array $options, string $value, string $type): void {
|
||||
echo '<div class="aksrt-widget-choices aksrt-widget-choices--' . esc_attr($type) . '">';
|
||||
echo '<div class="jio-widget-choices jio-widget-choices--' . esc_attr($type) . '">';
|
||||
foreach ($options as $key => $label) {
|
||||
$option_id = $id . '-' . sanitize_html_class((string) $key);
|
||||
$image = is_array($label) ? (string) ($label['image'] ?? $label['url'] ?? '') : (string) $label;
|
||||
@@ -146,7 +146,7 @@ final class FormRenderer {
|
||||
if ($type === 'image_select' && filter_var($image, FILTER_VALIDATE_URL)) {
|
||||
$body = '<img src="' . esc_url($image) . '" alt="' . esc_attr($text) . '"><small>' . esc_html($text) . '</small>';
|
||||
} elseif ($type === 'palette') {
|
||||
$body = '<span class="aksrt-widget-palette-choice"><i aria-hidden="true" style="background:' . esc_attr(self::palette_color((string) $key)) . '"></i><small>' . esc_html($text) . '</small></span>';
|
||||
$body = '<span class="jio-widget-palette-choice"><i aria-hidden="true" style="background:' . esc_attr(self::palette_color((string) $key)) . '"></i><small>' . esc_html($text) . '</small></span>';
|
||||
} else {
|
||||
$body = esc_html($text);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ final class FormRenderer {
|
||||
$step = ' step="' . esc_attr((string) ($field['step'] ?? 1)) . '"';
|
||||
$input_type = $type === 'slider' ? 'range' : 'number';
|
||||
$unit = trim((string) ($field['unit'] ?? ''));
|
||||
echo '<div class="aksrt-widget-number"><input class="widefat" type="' . esc_attr($input_type) . '" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="' . esc_attr((string) $value) . '"' . $min . $max . $step . '><output>' . esc_html((string) $value) . '</output>' . ($unit !== '' ? '<span class="aksrt-widget-number__unit">' . esc_html($unit) . '</span>' : '') . '</div>';
|
||||
echo '<div class="jio-widget-number"><input class="widefat" type="' . esc_attr($input_type) . '" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="' . esc_attr((string) $value) . '"' . $min . $max . $step . '><output>' . esc_html((string) $value) . '</output>' . ($unit !== '' ? '<span class="jio-widget-number__unit">' . esc_html($unit) . '</span>' : '') . '</div>';
|
||||
}
|
||||
|
||||
private static function terms(string $id, string $name, array $field, $value): void {
|
||||
@@ -216,48 +216,48 @@ final class FormRenderer {
|
||||
foreach ($terms as $term) {
|
||||
$by_id[(int) $term->term_id] = $term;
|
||||
}
|
||||
echo '<div class="aksrt-widget-terms" data-aksrt-terms="' . esc_attr($taxonomy) . '">';
|
||||
echo '<input type="hidden" class="aksrt-widget-terms__value" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="' . esc_attr(implode(',', $selected)) . '">';
|
||||
echo '<div class="aksrt-widget-terms__selected">';
|
||||
echo '<div class="jio-widget-terms" data-jio-terms="' . esc_attr($taxonomy) . '">';
|
||||
echo '<input type="hidden" class="jio-widget-terms__value" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="' . esc_attr(implode(',', $selected)) . '">';
|
||||
echo '<div class="jio-widget-terms__selected">';
|
||||
foreach ($selected as $term_id) {
|
||||
if (!isset($by_id[$term_id])) {
|
||||
continue;
|
||||
}
|
||||
echo '<span class="aksrt-widget-terms__chip" data-term-id="' . esc_attr((string) $term_id) . '"><span class="dashicons dashicons-move" aria-hidden="true"></span>' . esc_html((string) $by_id[$term_id]->name) . '<button type="button" class="button-link-delete aksrt-widget-terms__remove" aria-label="' . esc_attr__('移除', 'aksrt') . '">×</button></span>';
|
||||
echo '<span class="jio-widget-terms__chip" data-term-id="' . esc_attr((string) $term_id) . '"><span class="dashicons dashicons-move" aria-hidden="true"></span>' . esc_html((string) $by_id[$term_id]->name) . '<button type="button" class="button-link-delete jio-widget-terms__remove" aria-label="' . esc_attr__('移除', 'jio') . '">×</button></span>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<input type="search" class="widefat aksrt-widget-terms__search" placeholder="' . esc_attr__('输入关键词筛选', 'aksrt') . '" aria-label="' . esc_attr__('筛选可选分类', 'aksrt') . '">';
|
||||
echo '<div class="aksrt-widget-terms__options">';
|
||||
echo '<input type="search" class="widefat jio-widget-terms__search" placeholder="' . esc_attr__('输入关键词筛选', 'jio') . '" aria-label="' . esc_attr__('筛选可选分类', 'jio') . '">';
|
||||
echo '<div class="jio-widget-terms__options">';
|
||||
foreach ($terms as $term) {
|
||||
$term_id = (int) $term->term_id;
|
||||
echo '<label class="aksrt-widget-terms__option" data-term-name="' . esc_attr((string) $term->name) . '"><input type="checkbox" value="' . esc_attr((string) $term_id) . '" ' . checked(in_array($term_id, $selected, true), true, false) . '> ' . esc_html((string) $term->name) . '</label>';
|
||||
echo '<label class="jio-widget-terms__option" data-term-name="' . esc_attr((string) $term->name) . '"><input type="checkbox" value="' . esc_attr((string) $term_id) . '" ' . checked(in_array($term_id, $selected, true), true, false) . '> ' . esc_html((string) $term->name) . '</label>';
|
||||
}
|
||||
echo '</div></div>';
|
||||
}
|
||||
|
||||
private static function upload(string $id, string $name, string $value, string $library = ''): void {
|
||||
$library = in_array($library, ['image', 'video'], true) ? $library : '';
|
||||
echo '<div class="aksrt-widget-upload" data-media-library="' . esc_attr($library) . '">';
|
||||
echo '<div class="jio-widget-upload" data-media-library="' . esc_attr($library) . '">';
|
||||
// 参考主题:视频上传字段不展示预览图(视频 URL 作为 img src 会得到破图)。
|
||||
if ($value !== '' && $library !== 'video') {
|
||||
echo '<img src="' . esc_url($value) . '" alt="">';
|
||||
}
|
||||
echo '<input class="widefat" type="url" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" value="' . esc_attr($value) . '">';
|
||||
echo '<button type="button" class="button aksrt-widget-upload__choose">' . esc_html($library === 'video' ? __('选择视频', 'aksrt') : __('选择图片', 'aksrt')) . '</button> <button type="button" class="button-link-delete aksrt-widget-upload__remove">' . esc_html__('移除', 'aksrt') . '</button></div>';
|
||||
echo '<button type="button" class="button jio-widget-upload__choose">' . esc_html($library === 'video' ? __('选择视频', 'jio') : __('选择图片', 'jio')) . '</button> <button type="button" class="button-link-delete jio-widget-upload__remove">' . esc_html__('移除', 'jio') . '</button></div>';
|
||||
}
|
||||
|
||||
private static function link(SchemaWidget $widget, string $key, array $value): void {
|
||||
echo '<div class="aksrt-widget-link">';
|
||||
echo '<div class="jio-widget-link">';
|
||||
self::plain_input($widget, $key . '[url]', (string) ($value['url'] ?? ''), 'url', 'URL');
|
||||
self::plain_input($widget, $key . '[text]', (string) ($value['text'] ?? ''), 'text', '链接文字');
|
||||
$name = $widget->get_field_name($key . '[target]');
|
||||
echo '<label><input type="checkbox" name="' . esc_attr($name) . '" value="_blank" ' . checked(($value['target'] ?? '') === '_blank', true, false) . '> ' . esc_html__('新窗口打开', 'aksrt') . '</label></div>';
|
||||
echo '<label><input type="checkbox" name="' . esc_attr($name) . '" value="_blank" ' . checked(($value['target'] ?? '') === '_blank', true, false) . '> ' . esc_html__('新窗口打开', 'jio') . '</label></div>';
|
||||
}
|
||||
|
||||
private static function spacing(SchemaWidget $widget, string $key, array $value, array $edges = []): void {
|
||||
$all = ['top' => 'dashicons-arrow-up-alt', 'right' => 'dashicons-arrow-right-alt', 'bottom' => 'dashicons-arrow-down-alt', 'left' => 'dashicons-arrow-left-alt'];
|
||||
$visible = $edges ? array_intersect_key($all, array_flip($edges)) : $all;
|
||||
echo '<div class="aksrt-widget-spacing aksrt-widget-spacing--' . count($visible) . '">';
|
||||
echo '<div class="jio-widget-spacing jio-widget-spacing--' . count($visible) . '">';
|
||||
foreach ($visible as $edge => $icon) {
|
||||
echo '<label><span class="dashicons ' . esc_attr($icon) . '" aria-hidden="true"></span>';
|
||||
self::plain_input($widget, $key . '[' . $edge . ']', (string) ($value[$edge] ?? ''), 'number', 'px');
|
||||
@@ -267,8 +267,8 @@ final class FormRenderer {
|
||||
}
|
||||
|
||||
private static function background(SchemaWidget $widget, string $key, array $value): void {
|
||||
echo '<div class="aksrt-widget-background">';
|
||||
self::plain_input($widget, $key . '[color]', (string) ($value['color'] ?? ''), 'text', '背景颜色', 'widefat aksrt-widget-color');
|
||||
echo '<div class="jio-widget-background">';
|
||||
self::plain_input($widget, $key . '[color]', (string) ($value['color'] ?? ''), 'text', '背景颜色', 'widefat jio-widget-color');
|
||||
self::plain_input($widget, $key . '[image]', (string) ($value['image'] ?? ''), 'url', '背景图片 URL');
|
||||
foreach ([
|
||||
'position' => ['center center' => '居中', 'top center' => '顶部', 'bottom center' => '底部', 'center left' => '左侧', 'center right' => '右侧'],
|
||||
@@ -288,22 +288,22 @@ final class FormRenderer {
|
||||
|
||||
private static function group(SchemaWidget $widget, array $field, array $rows, string $key): void {
|
||||
$token = '__index_' . substr(md5($key), 0, 8) . '__';
|
||||
$button_title = (string) ($field['button_title'] ?? __('添加项目', 'aksrt'));
|
||||
echo '<div class="aksrt-widget-repeater" data-index-token="' . esc_attr($token) . '" data-item-label="' . esc_attr((string) ($field['item_label'] ?? $field['label'] ?? __('项目', 'aksrt'))) . '" data-min-items="' . esc_attr((string) ($field['min_items'] ?? 0)) . '" data-max-items="' . esc_attr((string) ($field['max_items'] ?? 50)) . '"><div class="aksrt-widget-repeater__rows">';
|
||||
$button_title = (string) ($field['button_title'] ?? __('添加项目', 'jio'));
|
||||
echo '<div class="jio-widget-repeater" data-index-token="' . esc_attr($token) . '" data-item-label="' . esc_attr((string) ($field['item_label'] ?? $field['label'] ?? __('项目', 'jio'))) . '" data-min-items="' . esc_attr((string) ($field['min_items'] ?? 0)) . '" data-max-items="' . esc_attr((string) ($field['max_items'] ?? 50)) . '"><div class="jio-widget-repeater__rows">';
|
||||
foreach ($rows as $index => $row) {
|
||||
self::group_row($widget, $field, is_array($row) ? $row : [], $key, (string) $index);
|
||||
}
|
||||
echo '</div><template class="aksrt-widget-repeater__template">';
|
||||
echo '</div><template class="jio-widget-repeater__template">';
|
||||
self::group_row($widget, $field, [], $key, $token);
|
||||
echo '</template><button type="button" class="button aksrt-widget-repeater__add">' . esc_html($button_title) . '</button></div>';
|
||||
echo '</template><button type="button" class="button jio-widget-repeater__add">' . esc_html($button_title) . '</button></div>';
|
||||
}
|
||||
|
||||
private static function group_row(SchemaWidget $widget, array $field, array $row, string $key, string $index): void {
|
||||
$prefix = (string) ($field['item_label'] ?? $field['label'] ?? __('项目', 'aksrt'));
|
||||
$prefix = (string) ($field['item_label'] ?? $field['label'] ?? __('项目', 'jio'));
|
||||
$number = ctype_digit($index) ? ((int) $index + 1) : 0;
|
||||
$title = $prefix . $number;
|
||||
if (!empty($row['title'])) $title .= ':' . strip_tags((string) $row['title']);
|
||||
echo '<details class="aksrt-widget-repeater__row" data-row-index="' . esc_attr(ctype_digit($index) ? $index : '0') . '"><summary class="aksrt-widget-repeater__bar"><span class="dashicons dashicons-move" aria-hidden="true"></span><strong class="aksrt-widget-repeater__title" data-title-prefix="' . esc_attr($prefix) . '">' . esc_html($title) . '</strong><button type="button" class="button-link-delete aksrt-widget-repeater__remove">' . esc_html__('删除', 'aksrt') . '</button></summary><div class="aksrt-widget-repeater__fields">';
|
||||
echo '<details class="jio-widget-repeater__row" data-row-index="' . esc_attr(ctype_digit($index) ? $index : '0') . '"><summary class="jio-widget-repeater__bar"><span class="dashicons dashicons-move" aria-hidden="true"></span><strong class="jio-widget-repeater__title" data-title-prefix="' . esc_attr($prefix) . '">' . esc_html($title) . '</strong><button type="button" class="button-link-delete jio-widget-repeater__remove">' . esc_html__('删除', 'jio') . '</button></summary><div class="jio-widget-repeater__fields">';
|
||||
foreach ((array) ($field['fields'] ?? []) as $child) {
|
||||
$child_id = (string) ($child['id'] ?? '');
|
||||
self::field($widget, $child, $row[$child_id] ?? ($child['default'] ?? ''), $key . '[' . $index . ']');
|
||||
@@ -312,7 +312,7 @@ final class FormRenderer {
|
||||
}
|
||||
|
||||
private static function nested(SchemaWidget $widget, array $field, array $value, string $key): void {
|
||||
echo '<details class="aksrt-widget-nested"><summary>' . esc_html((string) ($field['label'] ?? '更多设置')) . '</summary><div class="aksrt-widget-nested__body">';
|
||||
echo '<details class="jio-widget-nested"><summary>' . esc_html((string) ($field['label'] ?? '更多设置')) . '</summary><div class="jio-widget-nested__body">';
|
||||
foreach ((array) ($field['fields'] ?? []) as $child) {
|
||||
$child_id = (string) ($child['id'] ?? '');
|
||||
self::field($widget, $child, $value[$child_id] ?? ($child['default'] ?? ''), $key);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -56,33 +56,33 @@ final class FrontendRenderer {
|
||||
echo (string) ($args['after_widget'] ?? '');
|
||||
return;
|
||||
}
|
||||
$classes = ['aksrt-widget', 'aksrt-panel-wrap', 'aksrt-widget--' . $definition->slug(), 'aksrt-widget--' . $definition->size()];
|
||||
$classes = ['jio-widget', 'jio-panel-wrap', 'jio-widget--' . $definition->slug(), 'jio-widget--' . $definition->size()];
|
||||
if ($definition->size() === 'sidebar') {
|
||||
$classes[] = 'aksrt-panel';
|
||||
$classes[] = 'jio-panel';
|
||||
}
|
||||
$device_class = WidgetVisibility::device_class($instance);
|
||||
if ($device_class !== '') {
|
||||
$classes[] = $device_class;
|
||||
}
|
||||
if (!empty($instance['sidebar_affix'])) {
|
||||
$classes[] = 'aksrt-widget--affix';
|
||||
$classes[] = 'jio-widget--affix';
|
||||
}
|
||||
if (!empty($instance['animation_in'])) {
|
||||
$classes[] = 'aksrt-widget--animate';
|
||||
$classes[] = 'aksrt-widget--animate-' . sanitize_html_class((string) $instance['animation_in']);
|
||||
$classes[] = 'jio-widget--animate';
|
||||
$classes[] = 'jio-widget--animate-' . sanitize_html_class((string) $instance['animation_in']);
|
||||
}
|
||||
if (!empty($instance['animation_repeat'])) {
|
||||
$classes[] = 'aksrt-widget--animate-repeat';
|
||||
$classes[] = 'jio-widget--animate-repeat';
|
||||
}
|
||||
|
||||
$style = self::style($instance);
|
||||
echo (string) ($args['before_widget'] ?? '<section>'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="' . esc_attr(implode(' ', $classes)) . '" data-aksrt-widget="' . esc_attr($definition->slug()) . '" data-widget-id="' . esc_attr((string) $widget->id) . '"' . ($style !== '' ? ' style="' . esc_attr($style) . '"' : '') . '>';
|
||||
echo '<div class="' . esc_attr(implode(' ', $classes)) . '" data-jio-widget="' . esc_attr($definition->slug()) . '" data-widget-id="' . esc_attr((string) $widget->id) . '"' . ($style !== '' ? ' style="' . esc_attr($style) . '"' : '') . '>';
|
||||
if ($definition->size() !== 'sidebar') {
|
||||
echo '<div class="aksrt-widget__inner container">';
|
||||
echo '<div class="jio-widget__inner container">';
|
||||
}
|
||||
echo self::title($instance); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="aksrt-widget__content">' . $content . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="jio-widget__content">' . $content . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
if ($definition->size() !== 'sidebar') {
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -91,16 +91,16 @@ final class FrontendRenderer {
|
||||
}
|
||||
|
||||
private static function render_reference_widget(WidgetDefinition $definition, array $instance, SchemaWidget $widget, string $content): void {
|
||||
$classes = ['zib-widget-wrap', 'aksrt-' . str_replace('_', '-', $definition->slug()) . '-wrap'];
|
||||
$classes = ['zib-widget-wrap', 'jio-' . str_replace('_', '-', $definition->slug()) . '-wrap'];
|
||||
if (in_array($definition->slug(), ['user_card', 'author_card'], true)) {
|
||||
$classes[] = 'aksrt-user-widget-wrap';
|
||||
$classes[] = 'jio-user-widget-wrap';
|
||||
}
|
||||
$device_class = WidgetVisibility::device_class($instance);
|
||||
if ($device_class !== '') {
|
||||
$classes[] = $device_class;
|
||||
}
|
||||
if (!empty($instance['sidebar_affix'])) {
|
||||
$classes[] = 'aksrt-widget--affix';
|
||||
$classes[] = 'jio-widget--affix';
|
||||
}
|
||||
|
||||
$content_classes = ['widget-content'];
|
||||
@@ -113,7 +113,7 @@ final class FrontendRenderer {
|
||||
|
||||
$style = self::style($instance);
|
||||
$affix_attr = !empty($instance['sidebar_affix']) ? ' data-affix="true"' : '';
|
||||
echo '<div class="' . esc_attr(implode(' ', $classes)) . '" data-aksrt-widget="' . esc_attr($definition->slug()) . '" data-widget-id="' . esc_attr((string) $widget->id) . '"' . $affix_attr . ($style !== '' ? ' style="' . esc_attr($style) . '"' : '') . '>';
|
||||
echo '<div class="' . esc_attr(implode(' ', $classes)) . '" data-jio-widget="' . esc_attr($definition->slug()) . '" data-widget-id="' . esc_attr((string) $widget->id) . '"' . $affix_attr . ($style !== '' ? ' style="' . esc_attr($style) . '"' : '') . '>';
|
||||
echo '<div class="widget-container"><div>';
|
||||
echo self::reference_title($instance); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="' . esc_attr(implode(' ', $content_classes)) . '">' . $content . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -131,11 +131,11 @@ final class FrontendRenderer {
|
||||
$safe_highlight = esc_html($highlight);
|
||||
$safe_title = str_replace($safe_highlight, '<mark class="' . esc_attr((string) ($instance['title_highlight_color'] ?? 'focus-color')) . '">' . $safe_highlight . '</mark>', $safe_title);
|
||||
}
|
||||
$html = '<header class="aksrt-widget__header' . (($instance['title_style'] ?? '') === 'big' ? ' aksrt-widget__header--big' : '') . '"><div><h2 class="aksrt-widget__title">' . nl2br($safe_title) . '</h2>';
|
||||
$html = '<header class="jio-widget__header' . (($instance['title_style'] ?? '') === 'big' ? ' jio-widget__header--big' : '') . '"><div><h2 class="jio-widget__title">' . nl2br($safe_title) . '</h2>';
|
||||
if (!empty($instance['subtitle'])) {
|
||||
$html .= '<p class="aksrt-widget__subtitle">' . nl2br(wp_kses_post((string) $instance['subtitle'])) . '</p>';
|
||||
$html .= '<p class="jio-widget__subtitle">' . nl2br(wp_kses_post((string) $instance['subtitle'])) . '</p>';
|
||||
}
|
||||
$html .= '</div><nav class="aksrt-widget__title-links" aria-label="' . esc_attr__('模块链接', 'aksrt') . '">';
|
||||
$html .= '</div><nav class="jio-widget__title-links" aria-label="' . esc_attr__('模块链接', 'jio') . '">';
|
||||
foreach (['title_link', 'title_link2', 'title_link3'] as $index => $key) {
|
||||
$link = RendererHelpers::link((array) ($instance[$key] ?? []));
|
||||
if ($link['url'] !== '' && $link['text'] !== '') {
|
||||
@@ -159,7 +159,7 @@ final class FrontendRenderer {
|
||||
return '<div class="big-title-wrap"><h2 class="big-title">' . $title . '</h2>' . ($subtitle ? '<p class="big-title-sub muted-2-color">' . $subtitle . '</p>' : '') . ($links ? '<div class="flex jc big-title-buts">' . $links . '</div>' : '') . '</div>';
|
||||
}
|
||||
$link = RendererHelpers::link((array) ($instance['title_link'] ?? []));
|
||||
$more = $link['url'] ? '<div class="pull-right em09 mt3"><a class="muted-2-color" href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) . '>' . esc_html($link['text'] ?: __('更多', 'aksrt')) . '</a></div>' : '';
|
||||
$more = $link['url'] ? '<div class="pull-right em09 mt3"><a class="muted-2-color" href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) . '>' . esc_html($link['text'] ?: __('更多', 'jio')) . '</a></div>' : '';
|
||||
return '<div class="box-body notop"><div class="title-theme">' . $title . ($subtitle ? '<small class="ml10">' . $subtitle . '</small>' : '') . $more . '</div></div>';
|
||||
}
|
||||
|
||||
@@ -169,17 +169,17 @@ final class FrontendRenderer {
|
||||
foreach (['top', 'right', 'bottom', 'left'] as $edge) {
|
||||
$value = $instance[$key][$edge] ?? '';
|
||||
if ($value !== '' && is_numeric($value)) {
|
||||
$properties[] = '--aksrt-widget-' . $prefix . '-' . $edge . ':' . (float) $value . 'px';
|
||||
$properties[] = '--jio-widget-' . $prefix . '-' . $edge . ':' . (float) $value . 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (['light', 'dark'] as $mode) {
|
||||
$background = (array) ($instance['layout_bg'][$mode] ?? []);
|
||||
if (!empty($background['color'])) {
|
||||
$properties[] = '--aksrt-widget-bg-' . $mode . ':' . (string) $background['color'];
|
||||
$properties[] = '--jio-widget-bg-' . $mode . ':' . (string) $background['color'];
|
||||
}
|
||||
if (!empty($background['image'])) {
|
||||
$properties[] = '--aksrt-widget-bg-image-' . $mode . ':url(' . esc_url_raw((string) $background['image']) . ')';
|
||||
$properties[] = '--jio-widget-bg-image-' . $mode . ':url(' . esc_url_raw((string) $background['image']) . ')';
|
||||
}
|
||||
}
|
||||
return implode(';', $properties);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -89,9 +89,9 @@ final class PostQuery {
|
||||
private static function apply_order(array &$args, string $orderby, string $order): void {
|
||||
$args['order'] = strtoupper($order) === 'ASC' ? 'ASC' : 'DESC';
|
||||
$meta = [
|
||||
'views' => class_exists('AKSRT\\Core\\DomainModel') ? \AKSRT\Core\DomainModel::POST_VIEW_COUNT_KEY : 'aksrt_post_views',
|
||||
'like' => '_aksrt_like_count',
|
||||
'favorite' => '_aksrt_favorite_count',
|
||||
'views' => class_exists('Jio\\Core\\DomainModel') ? \Jio\Core\DomainModel::POST_VIEW_COUNT_KEY : 'jio_post_views',
|
||||
'like' => '_jio_like_count',
|
||||
'favorite' => '_jio_favorite_count',
|
||||
];
|
||||
if (isset($meta[$orderby])) {
|
||||
$args['meta_key'] = $meta[$orderby];
|
||||
@@ -112,13 +112,13 @@ final class PostQuery {
|
||||
$map = ['1' => 'reading', '2' => 'download', '5' => 'gallery', '6' => 'video', 'reading' => 'reading', 'download' => 'download', 'gallery' => 'gallery', 'video' => 'video', 'vip' => 'vip'];
|
||||
$values = array_values(array_unique(array_filter(array_map(static fn($value): string => $map[(string) $value] ?? '', $values))));
|
||||
if (!$values) return;
|
||||
$type_key = class_exists('AKSRT\\Core\\DomainModel') ? \AKSRT\Core\DomainModel::PAY_TYPE_KEY : '_aksrt_pay_type';
|
||||
$meta_key = class_exists('AKSRT\\Core\\DomainModel') ? \AKSRT\Core\DomainModel::PAY_META_KEY : '_aksrt_pay';
|
||||
$type_key = class_exists('Jio\\Core\\DomainModel') ? \Jio\Core\DomainModel::PAY_TYPE_KEY : '_jio_pay_type';
|
||||
$meta_key = class_exists('Jio\\Core\\DomainModel') ? \Jio\Core\DomainModel::PAY_META_KEY : '_jio_pay';
|
||||
$pay_query = [
|
||||
'relation' => 'OR',
|
||||
['key' => $type_key, 'value' => $values, 'compare' => 'IN'],
|
||||
];
|
||||
// Some AKSRT installations only have the structured pay array. LIKE
|
||||
// Some Jio installations only have the structured pay array. LIKE
|
||||
// accepts one scalar per clause, so emit a clause for each allowed type.
|
||||
foreach ($values as $value) {
|
||||
$pay_query[] = ['key' => $meta_key, 'value' => '"' . $value . '"', 'compare' => 'LIKE'];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -37,7 +37,7 @@ final class PostRenderer {
|
||||
|
||||
public static function items(\WP_Query $query, array $instance, string $slug, int $page = 1): string {
|
||||
if (!$query->have_posts()) {
|
||||
return function_exists('aksrt_widget_ajax_null') ? aksrt_widget_ajax_null() : RendererHelpers::empty_state(__('暂无内容', 'aksrt'));
|
||||
return function_exists('jio_widget_ajax_null') ? jio_widget_ajax_null() : RendererHelpers::empty_state(__('暂无内容', 'jio'));
|
||||
}
|
||||
$mode = self::style($instance, $slug);
|
||||
$mini_opt = (array) ($instance['mini_opt'] ?? []);
|
||||
@@ -60,7 +60,7 @@ final class PostRenderer {
|
||||
return self::oneline($query, $config, $mode);
|
||||
}
|
||||
if ($mode === 'mini') {
|
||||
return aksrt_render_mini_list($query, array_merge($config, ['class' => 'ajax-item']), false);
|
||||
return jio_render_mini_list($query, array_merge($config, ['class' => 'ajax-item']), false);
|
||||
}
|
||||
if ($mode === 'list') {
|
||||
// Zibll suppresses archive-only thumb variants in widget list mode.
|
||||
@@ -69,7 +69,7 @@ final class PostRenderer {
|
||||
}
|
||||
// The .widget-ajaxpager container rendered by the caller is the ajax
|
||||
// target, so item markup goes in without the page-level list wrapper.
|
||||
return aksrt_render_post_list(array_merge($config, ['skip_wrapper' => true]), $query, false);
|
||||
return jio_render_post_list(array_merge($config, ['skip_wrapper' => true]), $query, false);
|
||||
}
|
||||
|
||||
private static function oneline(\WP_Query $query, array $config, string $style): string {
|
||||
@@ -77,8 +77,8 @@ final class PostRenderer {
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
if ($style === 'mini') {
|
||||
$data = aksrt_renderer_collect_post_data($config);
|
||||
$items .= $data ? aksrt_renderer_mini($data, array_merge($config, [
|
||||
$data = jio_renderer_collect_post_data($config);
|
||||
$items .= $data ? jio_renderer_mini($data, array_merge($config, [
|
||||
'class' => 'posts-item',
|
||||
'show_thumb' => true,
|
||||
'show_meta' => true,
|
||||
@@ -90,7 +90,7 @@ final class PostRenderer {
|
||||
$item_config['is_mult_thumb'] = 'disable';
|
||||
$item_config['is_no_thumb'] = 'disable';
|
||||
}
|
||||
$items .= aksrt_render_post($item_config);
|
||||
$items .= jio_render_post($item_config);
|
||||
}
|
||||
}
|
||||
wp_reset_postdata();
|
||||
@@ -117,7 +117,7 @@ final class PostRenderer {
|
||||
$mobile = wp_is_mobile();
|
||||
$mid_size = $mobile ? 0 : 2;
|
||||
if ($page > 1) {
|
||||
$links .= self::page_link($page - 1, '<i class="fa fas fa-angle-left em12" aria-hidden="true"></i><span class="hide-sm ml6">' . esc_html__('上一页', 'aksrt') . '</span>', 'prev');
|
||||
$links .= self::page_link($page - 1, '<i class="fa fas fa-angle-left em12" aria-hidden="true"></i><span class="hide-sm ml6">' . esc_html__('上一页', 'jio') . '</span>', 'prev');
|
||||
}
|
||||
$dots = false;
|
||||
for ($number = 1; $number <= $max_pages; $number++) {
|
||||
@@ -135,17 +135,17 @@ final class PostRenderer {
|
||||
}
|
||||
}
|
||||
if ($page < $max_pages) {
|
||||
$links .= self::page_link($page + 1, '<span class="hide-sm mr6">' . esc_html__('下一页', 'aksrt') . '</span><i class="fa fas fa-angle-right em12" aria-hidden="true"></i>', 'next');
|
||||
$links .= self::page_link($page + 1, '<span class="hide-sm mr6">' . esc_html__('下一页', 'jio') . '</span><i class="fa fas fa-angle-right em12" aria-hidden="true"></i>', 'next');
|
||||
}
|
||||
if ($max_pages > ($mobile ? 4 : 8)) {
|
||||
$links .= '<span class="pag-jump page-numbers"><input autocomplete="off" min="1" max="' . $max_pages . '" current="' . $page . '" type="' . ($mobile ? 'number' : 'text') . '" inputmode="numeric" class="form-control jump-input" data-widget-jump aria-label="' . esc_attr__('跳转页码', 'aksrt') . '"><span class="hi de-sm mr6 jump-text">' . esc_html__('跳转', 'aksrt') . '</span><button type="button" class="jump-icon fa fas fa-angle-double-right em12" data-widget-jump-go aria-label="' . esc_attr__('跳转', 'aksrt') . '"></button></span>';
|
||||
$links .= '<span class="pag-jump page-numbers"><input autocomplete="off" min="1" max="' . $max_pages . '" current="' . $page . '" type="' . ($mobile ? 'number' : 'text') . '" inputmode="numeric" class="form-control jump-input" data-widget-jump aria-label="' . esc_attr__('跳转页码', 'jio') . '"><span class="hi de-sm mr6 jump-text">' . esc_html__('跳转', 'jio') . '</span><button type="button" class="jump-icon fa fas fa-angle-double-right em12" data-widget-jump-go aria-label="' . esc_attr__('跳转', 'jio') . '"></button></span>';
|
||||
}
|
||||
return '<div class="pagenav ajax-pag" role="navigation" aria-label="' . esc_attr__('文章分页', 'aksrt') . '">' . $links . '</div>';
|
||||
return '<div class="pagenav ajax-pag" role="navigation" aria-label="' . esc_attr__('文章分页', 'jio') . '">' . $links . '</div>';
|
||||
}
|
||||
if ($page >= $max_pages) {
|
||||
return '';
|
||||
}
|
||||
return '<div class="text-center theme-pagination ajax-pag"><div no-scroll="true" ajaxpager-target=".widget-ajaxpager" class="next-page"><a role="button" tabindex="0" href="#next" data-next-page="' . (int) ($page + 1) . '">' . esc_html__('加载更多', 'aksrt') . '</a></div></div>';
|
||||
return '<div class="text-center theme-pagination ajax-pag"><div no-scroll="true" ajaxpager-target=".widget-ajaxpager" class="next-page"><a role="button" tabindex="0" href="#next" data-next-page="' . (int) ($page + 1) . '">' . esc_html__('加载更多', 'jio') . '</a></div></div>';
|
||||
}
|
||||
|
||||
private static function page_link(int $page, string $label, string $class = ''): string {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -24,7 +24,7 @@ final class RendererHelpers {
|
||||
if ($url === '') {
|
||||
return '';
|
||||
}
|
||||
return '<img' . aksrt_get_lazy_attr($key, $url, $class, $lazy_src) . ' alt="' . esc_attr($alt) . '">';
|
||||
return '<img' . jio_get_lazy_attr($key, $url, $class, $lazy_src) . ' alt="' . esc_attr($alt) . '">';
|
||||
}
|
||||
|
||||
public static function lines(string $value): array {
|
||||
@@ -33,10 +33,10 @@ final class RendererHelpers {
|
||||
}
|
||||
|
||||
public static function empty_state(string $message): string {
|
||||
if (function_exists('aksrt_get_widget_null')) {
|
||||
return aksrt_get_widget_null($message);
|
||||
if (function_exists('jio_get_widget_null')) {
|
||||
return jio_get_widget_null($message);
|
||||
}
|
||||
return '<div class="aksrt-widget__empty" role="status">' . esc_html($message) . '</div>';
|
||||
return '<div class="jio-widget__empty" role="status">' . esc_html($message) . '</div>';
|
||||
}
|
||||
|
||||
public static function card_media(array $item, string $class = ''): string {
|
||||
@@ -44,24 +44,24 @@ final class RendererHelpers {
|
||||
$link = self::link((array) ($item['link'] ?? []));
|
||||
$media = '';
|
||||
if (!empty($item['image_dark'])) {
|
||||
$media .= self::image((string) $item['image_dark'], $title, 'aksrt-media-card__image aksrt-media-card__image--dark');
|
||||
$media .= self::image((string) $item['image_dark'], $title, 'jio-media-card__image jio-media-card__image--dark');
|
||||
}
|
||||
$media .= self::image((string) ($item['image'] ?? ''), $title, 'aksrt-media-card__image');
|
||||
$media .= self::image((string) ($item['image'] ?? ''), $title, 'jio-media-card__image');
|
||||
if (!empty($item['video'])) {
|
||||
$video = esc_url((string) $item['video']);
|
||||
$video_attr = aksrt_is_lazy('lazy_other')
|
||||
? ' class="aksrt-media-card__video lazyload" src="" data-src="' . $video . '"'
|
||||
: ' class="aksrt-media-card__video" src="' . $video . '"';
|
||||
$video_attr = jio_is_lazy('lazy_other')
|
||||
? ' class="jio-media-card__video lazyload" src="" data-src="' . $video . '"'
|
||||
: ' class="jio-media-card__video" src="' . $video . '"';
|
||||
$media .= '<video' . $video_attr . ' muted loop playsinline preload="metadata"></video>';
|
||||
}
|
||||
$body = '<span class="aksrt-media-card__body"><strong>' . esc_html($title) . '</strong>';
|
||||
$body = '<span class="jio-media-card__body"><strong>' . esc_html($title) . '</strong>';
|
||||
if (!empty($item['description'])) {
|
||||
$body .= '<small>' . esc_html((string) $item['description']) . '</small>';
|
||||
}
|
||||
$body .= '</span>';
|
||||
$tag = $link['url'] !== '' ? 'a' : 'div';
|
||||
$attrs = $link['url'] !== '' ? ' href="' . $link['url'] . '"' . self::link_attrs($link) : '';
|
||||
return '<' . $tag . ' class="aksrt-media-card ' . esc_attr($class) . '"' . $attrs . '><span class="aksrt-media-card__media">' . $media . '</span>' . $body . '</' . $tag . '>';
|
||||
return '<' . $tag . ' class="jio-media-card ' . esc_attr($class) . '"' . $attrs . '><span class="jio-media-card__media">' . $media . '</span>' . $body . '</' . $tag . '>';
|
||||
}
|
||||
|
||||
public static function ids(string $value): array {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
use AKSRT\WidgetSystem\Renderers\ContentRenderer;
|
||||
use AKSRT\WidgetSystem\Renderers\GeneralRenderer;
|
||||
use AKSRT\WidgetSystem\Renderers\KnowledgeProductRenderer;
|
||||
use AKSRT\WidgetSystem\Renderers\SliderRenderer;
|
||||
use AKSRT\WidgetSystem\Renderers\UserRenderer;
|
||||
use Jio\WidgetSystem\Renderers\ContentRenderer;
|
||||
use Jio\WidgetSystem\Renderers\GeneralRenderer;
|
||||
use Jio\WidgetSystem\Renderers\KnowledgeProductRenderer;
|
||||
use Jio\WidgetSystem\Renderers\SliderRenderer;
|
||||
use Jio\WidgetSystem\Renderers\UserRenderer;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem\Renderers;
|
||||
namespace Jio\WidgetSystem\Renderers;
|
||||
|
||||
use AKSRT\WidgetSystem\PostRenderer;
|
||||
use AKSRT\WidgetSystem\RendererHelpers;
|
||||
use Jio\WidgetSystem\PostRenderer;
|
||||
use Jio\WidgetSystem\RendererHelpers;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -19,7 +19,7 @@ final class ContentRenderer {
|
||||
case 'post_pay': return self::post_pay($instance);
|
||||
case 'tab_posts': return self::tab_posts($instance, $context);
|
||||
case 'posts': return self::posts($instance, $context, 'posts');
|
||||
case 'hot_posts': return function_exists('aksrt_widget_hot_posts') ? aksrt_widget_hot_posts($instance) : '';
|
||||
case 'hot_posts': return function_exists('jio_widget_hot_posts') ? jio_widget_hot_posts($instance) : '';
|
||||
case 'oneline_posts': return self::posts($instance, $context, 'oneline_posts');
|
||||
}
|
||||
return '';
|
||||
@@ -30,8 +30,8 @@ final class ContentRenderer {
|
||||
$style = $instance['style'];
|
||||
if ($slug === 'oneline_posts') {
|
||||
// Reference parity: the swiper row is fully rendered server-side.
|
||||
$query = \AKSRT\WidgetSystem\PostQuery::build(array_merge($instance, ['paginate' => '']), 1, []);
|
||||
return \AKSRT\WidgetSystem\PostRenderer::items($query, $instance, 'oneline_posts');
|
||||
$query = \Jio\WidgetSystem\PostQuery::build(array_merge($instance, ['paginate' => '']), 1, []);
|
||||
return \Jio\WidgetSystem\PostRenderer::items($query, $instance, 'oneline_posts');
|
||||
}
|
||||
$inner = self::ajaxpager($instance, $slug, $widget_id, 1, '');
|
||||
$html = '<div class="widget-main-post mb20 style-' . esc_attr($style) . '">';
|
||||
@@ -48,7 +48,7 @@ final class ContentRenderer {
|
||||
$attrs .= ' data-segment="' . esc_attr($segment) . '"';
|
||||
}
|
||||
$lazy = ($instance['load_mode'] ?? '') === 'ajax';
|
||||
$loader = '<div class="post_ajax_loader' . ($lazy ? ' is-loading' : '') . '" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . self::placeholder($instance) . '</div>';
|
||||
$loader = '<div class="post_ajax_loader' . ($lazy ? ' is-loading' : '') . '" role="status" aria-label="' . esc_attr__('正在加载', 'jio') . '">' . self::placeholder($instance) . '</div>';
|
||||
if ($lazy) {
|
||||
// lazySizes reveals the pager; the widget client owns its request.
|
||||
return '<div class="widget-ajaxpager lazyload" data-widget-lazy' . $attrs . ' aria-live="polite" aria-busy="true">' . $loader . '</div>';
|
||||
@@ -65,12 +65,12 @@ final class ContentRenderer {
|
||||
$count = max(1, (int) ($instance['count'] ?? 6));
|
||||
if ($style === 'mini') {
|
||||
$mini_opt = (array) ($instance['mini_opt'] ?? []);
|
||||
return aksrt_render_placeholder(
|
||||
return jio_render_placeholder(
|
||||
in_array('show_thumb', $mini_opt, true) ? 'mini_thumb' : 'mini',
|
||||
$count
|
||||
);
|
||||
}
|
||||
return aksrt_render_placeholder($style === 'card' ? 'card' : 'list', $count);
|
||||
return jio_render_placeholder($style === 'card' ? 'card' : 'list', $count);
|
||||
}
|
||||
|
||||
private static function tab_posts(array $instance, array $context): string {
|
||||
@@ -83,11 +83,11 @@ final class ContentRenderer {
|
||||
$buttons = '';
|
||||
$panels = '';
|
||||
$key = sanitize_html_class($widget_id) ?: 'preview';
|
||||
$panel_id = 'aksrt-tab-panel-' . $key;
|
||||
$panel_id = 'jio-tab-panel-' . $key;
|
||||
$visible_index = 0;
|
||||
foreach ($tabs as $index => $tab) {
|
||||
if (!is_array($tab) || trim((string) ($tab['title'] ?? '')) === '') continue;
|
||||
$tab_id = 'aksrt-tab-' . $key . '-' . $visible_index;
|
||||
$tab_id = 'jio-tab-' . $key . '-' . $visible_index;
|
||||
$selected = $visible_index === 0;
|
||||
$buttons .= '<li class="' . ($selected ? 'active' : '') . '"><a href="#' . esc_attr($panel_id . '-' . $visible_index) . '" role="tab" id="' . esc_attr($tab_id) . '" aria-controls="' . esc_attr($panel_id . '-' . $visible_index) . '" aria-selected="' . ($selected ? 'true' : 'false') . '" tabindex="' . ($selected ? '0' : '-1') . '" data-segment="' . (int) $index . '">' . wp_kses_post((string) $tab['title']) . '</a></li>';
|
||||
if ($selected) {
|
||||
@@ -96,7 +96,7 @@ final class ContentRenderer {
|
||||
// Inactive panes load lazily through the REST client on switch,
|
||||
// so the pane ships pre-filled with the skeleton. 显隐交给
|
||||
// .is-loading,内联 display:none 会让 REST 客户端无法展开骨架。
|
||||
$body = '<div class="widget-ajaxpager" data-widget-items data-widget="tab_posts" data-instance="' . esc_attr($widget_id) . '" data-page="1" data-segment="' . (int) $index . '" aria-live="polite" aria-busy="false"><div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . self::placeholder($instance) . '</div></div>';
|
||||
$body = '<div class="widget-ajaxpager" data-widget-items data-widget="tab_posts" data-instance="' . esc_attr($widget_id) . '" data-page="1" data-segment="' . (int) $index . '" aria-live="polite" aria-busy="false"><div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'jio') . '">' . self::placeholder($instance) . '</div></div>';
|
||||
}
|
||||
$panels .= '<div class="tab-pane fade' . ($selected ? ' active in' : '') . '" id="' . esc_attr($panel_id . '-' . $visible_index) . '" role="tabpanel" aria-labelledby="' . esc_attr($tab_id) . '">' . $body . '</div>';
|
||||
$visible_index++;
|
||||
@@ -124,8 +124,8 @@ final class ContentRenderer {
|
||||
$html = '';
|
||||
foreach ($terms as $term) {
|
||||
$count = (int) $term->count;
|
||||
$name = aksrt_widget_str_cut((string) $term->name, 16);
|
||||
$description = aksrt_widget_str_cut((string) $term->description, 24);
|
||||
$name = jio_widget_str_cut((string) $term->name, 16);
|
||||
$description = jio_widget_str_cut((string) $term->description, 24);
|
||||
$href = get_term_link($term);
|
||||
if (is_wp_error($href)) {
|
||||
continue;
|
||||
@@ -134,21 +134,21 @@ final class ContentRenderer {
|
||||
$card = [
|
||||
'type' => (string) ($instance['type'] ?? 'style-1'),
|
||||
'class' => 'mb10',
|
||||
'img' => aksrt_widget_term_cover_url((int) $term->term_id),
|
||||
'img' => jio_widget_term_cover_url((int) $term->term_id),
|
||||
'alt' => $name . '-' . $description,
|
||||
'link' => ['url' => esc_url((string) $href), 'target' => $target_blank],
|
||||
'text1' => $name,
|
||||
'text2' => $description,
|
||||
'text3' => $icon . $count . __('篇文章', 'aksrt'),
|
||||
'text3' => $icon . $count . __('篇文章', 'jio'),
|
||||
'height_scale' => (int) ($instance['height_scale'] ?? 60),
|
||||
'mask_opacity' => (int) ($instance['mask_opacity'] ?? 10),
|
||||
];
|
||||
$type = (string) $card['type'];
|
||||
if ($type === 'style-2' || $type === 'style-4') {
|
||||
$card['text3'] = '<item data-toggle="tooltip" title="' . esc_attr(sprintf(__('共%d篇文章', 'aksrt'), $count)) . '">' . $icon . $count . '</item>';
|
||||
$card['text3'] = '<item data-toggle="tooltip" title="' . esc_attr(sprintf(__('共%d篇文章', 'jio'), $count)) . '">' . $icon . $count . '</item>';
|
||||
} elseif ($type === 'style-3') {
|
||||
$card['text1'] = $icon . $name;
|
||||
$card['text3'] = '<i class="fa mr6 fa-file-alt" aria-hidden="true"></i>' . $count . __('篇文章', 'aksrt');
|
||||
$card['text3'] = '<i class="fa mr6 fa-file-alt" aria-hidden="true"></i>' . $count . __('篇文章', 'jio');
|
||||
}
|
||||
|
||||
$attr = '';
|
||||
@@ -163,7 +163,7 @@ final class ContentRenderer {
|
||||
if ($is_row) {
|
||||
$col_class .= ' ' . $row_class;
|
||||
}
|
||||
$html .= '<div class="' . esc_attr(trim($col_class)) . '"' . $attr . '>' . aksrt_graphic_card($card) . '</div>';
|
||||
$html .= '<div class="' . esc_attr(trim($col_class)) . '"' . $attr . '>' . jio_graphic_card($card) . '</div>';
|
||||
}
|
||||
return '<div class="' . ($is_row ? 'mb10' : 'mb20') . '">' . ($is_row ? '<div class="row gutters-5">' : '') . $html . ($is_row ? '</div>' : '') . '</div>';
|
||||
}
|
||||
@@ -179,7 +179,7 @@ final class ContentRenderer {
|
||||
$animation = (string) ($instance['obs_animation'] ?? '');
|
||||
$html = '';
|
||||
foreach ($term_ids as $key => $term_id) {
|
||||
$card = aksrt_widget_term_aggregation([
|
||||
$card = jio_widget_term_aggregation([
|
||||
'term_id' => (int) $term_id,
|
||||
'target_blank' => !empty($instance['target_blank']),
|
||||
'orderby' => (string) ($instance['orderby'] ?? 'modified'),
|
||||
@@ -211,14 +211,14 @@ final class ContentRenderer {
|
||||
|
||||
private static function post_pay(array $instance): string {
|
||||
$post = get_post();
|
||||
if (!$post instanceof \WP_Post || !function_exists('aksrt_get_pay_meta')) {
|
||||
if (!$post instanceof \WP_Post || !function_exists('jio_get_pay_meta')) {
|
||||
return '';
|
||||
}
|
||||
$meta = aksrt_get_pay_meta($post);
|
||||
$meta = jio_get_pay_meta($post);
|
||||
if (($meta['pay_type'] ?? 'no') === 'no') {
|
||||
return '';
|
||||
}
|
||||
return aksrt_get_paywall_html($post, [
|
||||
return jio_get_paywall_html($post, [
|
||||
'layout' => 'widget',
|
||||
'theme' => (string) $instance['theme'],
|
||||
]);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem\Renderers;
|
||||
namespace Jio\WidgetSystem\Renderers;
|
||||
|
||||
use AKSRT\WidgetSystem\RendererHelpers;
|
||||
use AKSRT\WidgetSystem\PostQuery;
|
||||
use Jio\WidgetSystem\RendererHelpers;
|
||||
use Jio\WidgetSystem\PostQuery;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -18,7 +18,7 @@ final class GeneralRenderer {
|
||||
$action = esc_url(home_url('/'));
|
||||
$placeholder = esc_attr((string) $i['placeholder']);
|
||||
$style = sanitize_html_class((string) $i['search_style']);
|
||||
return '<form class="aksrt-widget-search aksrt-widget-search--' . $style . '" role="search" method="get" action="' . $action . '"><label><span class="screen-reader-text">' . esc_html__('搜索:', 'aksrt') . '</span><input type="search" name="s" placeholder="' . $placeholder . '" autocomplete="off"></label><button type="submit" aria-label="' . esc_attr__('搜索', 'aksrt') . '"><i class="fa fas fa-search" aria-hidden="true"></i><span>' . esc_html__('搜索', 'aksrt') . '</span></button></form>';
|
||||
return '<form class="jio-widget-search jio-widget-search--' . $style . '" role="search" method="get" action="' . $action . '"><label><span class="screen-reader-text">' . esc_html__('搜索:', 'jio') . '</span><input type="search" name="s" placeholder="' . $placeholder . '" autocomplete="off"></label><button type="submit" aria-label="' . esc_attr__('搜索', 'jio') . '"><i class="fa fas fa-search" aria-hidden="true"></i><span>' . esc_html__('搜索', 'jio') . '</span></button></form>';
|
||||
}
|
||||
|
||||
private static function render_posts_toc(array $i): string {
|
||||
@@ -34,8 +34,8 @@ final class GeneralRenderer {
|
||||
}
|
||||
|
||||
private static function render_quote(array $i): string {
|
||||
return function_exists('aksrt_get_yiyan_markup')
|
||||
? aksrt_get_yiyan_markup(['class' => 'aksrt-widget-quote'])
|
||||
return function_exists('jio_get_yiyan_markup')
|
||||
? jio_get_yiyan_markup(['class' => 'jio-widget-quote'])
|
||||
: '';
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ final class GeneralRenderer {
|
||||
'class' => $class,
|
||||
];
|
||||
$item = '';
|
||||
if ($cover && function_exists('aksrt_icon_cover_card')) {
|
||||
$item = aksrt_icon_cover_card($args);
|
||||
} elseif (!$cover && function_exists('aksrt_icon_card')) {
|
||||
$item = aksrt_icon_card($args);
|
||||
if ($cover && function_exists('jio_icon_cover_card')) {
|
||||
$item = jio_icon_cover_card($args);
|
||||
} elseif (!$cover && function_exists('jio_icon_card')) {
|
||||
$item = jio_icon_card($args);
|
||||
} else {
|
||||
$item = '';
|
||||
}
|
||||
@@ -93,27 +93,27 @@ final class GeneralRenderer {
|
||||
private static function render_video(array $i): string {
|
||||
$url = esc_url((string) $i['url']);
|
||||
if ($url === '') {
|
||||
return RendererHelpers::empty_state(__('请配置视频地址', 'aksrt'));
|
||||
return RendererHelpers::empty_state(__('请配置视频地址', 'jio'));
|
||||
}
|
||||
$ratio = (string) $i['ratio'];
|
||||
if (aksrt_is_lazy('lazy_other')) {
|
||||
if (jio_is_lazy('lazy_other')) {
|
||||
$video_attr = ' class="lazyload" src="" data-src="' . $url . '"';
|
||||
$poster_attr = !empty($i['poster']) ? ' data-poster="' . esc_url((string) $i['poster']) . '"' : '';
|
||||
} else {
|
||||
$video_attr = ' src="' . $url . '"';
|
||||
$poster_attr = !empty($i['poster']) ? ' poster="' . esc_url((string) $i['poster']) . '"' : '';
|
||||
}
|
||||
return '<div class="aksrt-widget-video aksrt-widget-video--' . esc_attr(str_replace(':', '-', $ratio)) . '" data-video-url="' . $url . '" data-video-poster="' . esc_url((string) $i['poster']) . '" data-autoplay="' . (!empty($i['autoplay']) ? '1' : '0') . '" data-muted="' . (!empty($i['muted']) ? '1' : '0') . '"><video controls playsinline preload="metadata"' . $video_attr . $poster_attr . (!empty($i['autoplay']) ? ' autoplay' : '') . (!empty($i['muted']) ? ' muted' : '') . '></video><p class="aksrt-widget-media-error" role="alert" aria-live="assertive" hidden>' . esc_html__('视频加载失败,请稍后重试。', 'aksrt') . '</p></div>';
|
||||
return '<div class="jio-widget-video jio-widget-video--' . esc_attr(str_replace(':', '-', $ratio)) . '" data-video-url="' . $url . '" data-video-poster="' . esc_url((string) $i['poster']) . '" data-autoplay="' . (!empty($i['autoplay']) ? '1' : '0') . '" data-muted="' . (!empty($i['muted']) ? '1' : '0') . '"><video controls playsinline preload="metadata"' . $video_attr . $poster_attr . (!empty($i['autoplay']) ? ' autoplay' : '') . (!empty($i['muted']) ? ' muted' : '') . '></video><p class="jio-widget-media-error" role="alert" aria-live="assertive" hidden>' . esc_html__('视频加载失败,请稍后重试。', 'jio') . '</p></div>';
|
||||
}
|
||||
|
||||
private static function render_embed(array $i): string {
|
||||
if (empty($i['url'])) {
|
||||
return RendererHelpers::empty_state(__('请配置嵌入地址', 'aksrt'));
|
||||
return RendererHelpers::empty_state(__('请配置嵌入地址', 'jio'));
|
||||
}
|
||||
$src_attr = aksrt_is_lazy('lazy_other')
|
||||
$src_attr = jio_is_lazy('lazy_other')
|
||||
? ' class="lazyload" src="" data-src="' . esc_url((string) $i['url']) . '"'
|
||||
: ' src="' . esc_url((string) $i['url']) . '"';
|
||||
return '<div class="aksrt-widget-embed" style="--aksrt-embed-ratio:' . esc_attr((string) (float) $i['ratio']) . '%"><iframe' . $src_attr . ' referrerpolicy="strict-origin-when-cross-origin"' . (!empty($i['allow_fullscreen']) ? ' allowfullscreen' : '') . ' title="' . esc_attr__('嵌入内容', 'aksrt') . '"></iframe></div>';
|
||||
return '<div class="jio-widget-embed" style="--jio-embed-ratio:' . esc_attr((string) (float) $i['ratio']) . '%"><iframe' . $src_attr . ' referrerpolicy="strict-origin-when-cross-origin"' . (!empty($i['allow_fullscreen']) ? ' allowfullscreen' : '') . ' title="' . esc_attr__('嵌入内容', 'jio') . '"></iframe></div>';
|
||||
}
|
||||
|
||||
private static function render_media_cards(array $i): string {
|
||||
@@ -144,7 +144,7 @@ final class GeneralRenderer {
|
||||
}
|
||||
$title = (string) ($cover['title'] ?? '');
|
||||
$link = RendererHelpers::link((array) ($cover['link'] ?? []));
|
||||
$card = aksrt_graphic_card([
|
||||
$card = jio_graphic_card([
|
||||
'class' => 'noshadow mb10',
|
||||
'img' => (string) ($cover['image'] ?? ''),
|
||||
'video' => (string) ($cover['video'] ?? ''),
|
||||
@@ -214,7 +214,7 @@ final class GeneralRenderer {
|
||||
$partners = array_values(array_filter((array) $i['partners'], 'is_array'));
|
||||
if (!$partners) {
|
||||
return function_exists('is_super_admin') && is_super_admin()
|
||||
? '<div class="c-red muted-box mb20"><b>' . esc_html__('[合作伙伴]横向滚动合作伙伴模块:', 'aksrt') . '</b>' . esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'aksrt') . '</div>'
|
||||
? '<div class="c-red muted-box mb20"><b>' . esc_html__('[合作伙伴]横向滚动合作伙伴模块:', 'jio') . '</b>' . esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'jio') . '</div>'
|
||||
: '';
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ final class GeneralRenderer {
|
||||
if ($image === '' && $title === '') {
|
||||
return '';
|
||||
}
|
||||
$img_tag = $image !== '' ? '<img class="zps-img" src="' . $image . '" alt="' . esc_attr($title !== '' ? $title : __('合作伙伴', 'aksrt')) . '">' : '';
|
||||
$img_tag = $image !== '' ? '<img class="zps-img" src="' . $image . '" alt="' . esc_attr($title !== '' ? $title : __('合作伙伴', 'jio')) . '">' : '';
|
||||
|
||||
$inner = '';
|
||||
if ($style_type === 'logo') {
|
||||
@@ -295,8 +295,8 @@ final class GeneralRenderer {
|
||||
|
||||
$link = RendererHelpers::link((array) ($partner['link'] ?? []));
|
||||
$url = $link['url'] !== '' ? $link['url'] : 'javascript:void(0)';
|
||||
if ($go_link && $url !== 'javascript:void(0)' && function_exists('aksrt_go_link')) {
|
||||
$url = esc_url(aksrt_go_link($link['url'], true));
|
||||
if ($go_link && $url !== 'javascript:void(0)' && function_exists('jio_go_link')) {
|
||||
$url = esc_url(jio_go_link($link['url'], true));
|
||||
}
|
||||
$target = $link['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '';
|
||||
$base_class = 'zps-item flex ac shrink0';
|
||||
@@ -321,7 +321,7 @@ final class GeneralRenderer {
|
||||
$wrap_class = 'zib-combo-info-card row gutters-' . (int) ($is_mobile ? $i['m_gap'] : $i['pc_gap']);
|
||||
$wrap_class .= !empty($i['top_band']) ? ' zci-has-band' : '';
|
||||
|
||||
$default_cta = (string) ($i['cta_text'] !== '' ? $i['cta_text'] : __('立即体验', 'aksrt'));
|
||||
$default_cta = (string) ($i['cta_text'] !== '' ? $i['cta_text'] : __('立即体验', 'jio'));
|
||||
$default_cta_color = (string) ($i['cta_color'] ?? '');
|
||||
$auto_palette = ['blue', 'cyan', 'green', 'yellow', 'pink', 'purple'];
|
||||
$auto_idx = 0;
|
||||
@@ -374,7 +374,7 @@ final class GeneralRenderer {
|
||||
$icon_html = '';
|
||||
$icon_image = esc_url((string) $card['icon_image']);
|
||||
if ($icon_image !== '') {
|
||||
$icon_html = '<div class="zci-icon flex jc shrink0 mb20"><img src="' . $icon_image . '" alt="' . esc_attr($title !== '' ? $title : __('图标', 'aksrt')) . '"></div>';
|
||||
$icon_html = '<div class="zci-icon flex jc shrink0 mb20"><img src="' . $icon_image . '" alt="' . esc_attr($title !== '' ? $title : __('图标', 'jio')) . '"></div>';
|
||||
} elseif (!empty($card['icon'])) {
|
||||
$icon_html = '<div class="zci-icon flex jc shrink0 mb20">' . self::icon_markup((string) $card['icon']) . '</div>';
|
||||
}
|
||||
@@ -402,8 +402,8 @@ final class GeneralRenderer {
|
||||
$cta_color = trim((string) ($card['cta_color'] ?? '')) !== '' ? trim((string) $card['cta_color']) : $default_cta_color;
|
||||
$link = RendererHelpers::link((array) ($card['link'] ?? []));
|
||||
$url = $link['url'];
|
||||
if ($url !== '' && $go_link && function_exists('aksrt_go_link')) {
|
||||
$url = esc_url(aksrt_go_link($link['url'], true));
|
||||
if ($url !== '' && $go_link && function_exists('jio_go_link')) {
|
||||
$url = esc_url(jio_go_link($link['url'], true));
|
||||
}
|
||||
$target = $link['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '';
|
||||
$cta_html = $cta_text !== '' && $url !== ''
|
||||
@@ -419,7 +419,7 @@ final class GeneralRenderer {
|
||||
}
|
||||
|
||||
private static function render_text_title(array $i): string {
|
||||
return '<div class="aksrt-widget-text-title is-' . esc_attr((string) $i['alignment']) . '"><h2>' . nl2br(esc_html((string) $i['heading'])) . '</h2><p>' . nl2br(esc_html((string) $i['description'])) . '</p></div>';
|
||||
return '<div class="jio-widget-text-title is-' . esc_attr((string) $i['alignment']) . '"><h2>' . nl2br(esc_html((string) $i['heading'])) . '</h2><p>' . nl2br(esc_html((string) $i['description'])) . '</p></div>';
|
||||
}
|
||||
|
||||
private static function render_buttons(array $i): string {
|
||||
@@ -436,7 +436,7 @@ final class GeneralRenderer {
|
||||
if (!is_array($item) || trim((string) ($item['text'] ?? '')) === '') continue;
|
||||
$link = RendererHelpers::link((array) ($item['link'] ?? []));
|
||||
$url = $link['url'] !== '' ? $link['url'] : 'javascript:void(0)';
|
||||
if (!empty($i['go_link']) && $link['url'] !== '' && function_exists('aksrt_go_link')) $url = esc_url(aksrt_go_link($link['url'], true));
|
||||
if (!empty($i['go_link']) && $link['url'] !== '' && function_exists('jio_go_link')) $url = esc_url(jio_go_link($link['url'], true));
|
||||
$target = $link['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '';
|
||||
$color = sanitize_html_class((string) ($item['color'] ?? ''));
|
||||
$item_class = trim($button_class . ' ' . $color);
|
||||
@@ -455,7 +455,7 @@ final class GeneralRenderer {
|
||||
}
|
||||
|
||||
private static function render_layout_gap(array $i): string {
|
||||
return '<div class="aksrt-widget-gap" aria-hidden="true" style="--aksrt-gap:' . (float) $i['pc_gap'] . 'px;--aksrt-gap-m:' . (float) $i['m_gap'] . 'px"></div>';
|
||||
return '<div class="jio-widget-gap" aria-hidden="true" style="--jio-gap:' . (float) $i['pc_gap'] . 'px;--jio-gap-m:' . (float) $i['m_gap'] . 'px"></div>';
|
||||
}
|
||||
|
||||
private static function render_tag_cloud(array $i): string {
|
||||
@@ -466,12 +466,12 @@ final class GeneralRenderer {
|
||||
}
|
||||
$terms = get_terms($args);
|
||||
if (is_wp_error($terms) || !$terms) {
|
||||
return RendererHelpers::empty_state(__('暂无标签', 'aksrt'));
|
||||
return RendererHelpers::empty_state(__('暂无标签', 'jio'));
|
||||
}
|
||||
if ($i['orderby'] === 'rand') {
|
||||
shuffle($terms);
|
||||
}
|
||||
$html = '<div class="aksrt-widget-tag-cloud">';
|
||||
$html = '<div class="jio-widget-tag-cloud">';
|
||||
foreach (array_slice($terms, 0, (int) $i['number']) as $term) {
|
||||
$url = get_term_link($term);
|
||||
if (!is_wp_error($url)) {
|
||||
@@ -482,15 +482,15 @@ final class GeneralRenderer {
|
||||
}
|
||||
|
||||
private static function render_recent_comments(array $i): string {
|
||||
$list = function_exists('aksrt_widget_comments_list') ? aksrt_widget_comments_list($i) : '';
|
||||
$list = function_exists('jio_widget_comments_list') ? jio_widget_comments_list($i) : '';
|
||||
if ($list === '') {
|
||||
return RendererHelpers::empty_state(__('暂无评论', 'aksrt'));
|
||||
return RendererHelpers::empty_state(__('暂无评论', 'jio'));
|
||||
}
|
||||
return '<div class="box-body comment-mini-lists zib-widget">' . $list . '</div>';
|
||||
}
|
||||
|
||||
private static function render_links(array $i): string {
|
||||
$html = '<div class="aksrt-widget-links aksrt-widget-links--' . esc_attr((string) $i['style']) . '">';
|
||||
$html = '<div class="jio-widget-links jio-widget-links--' . esc_attr((string) $i['style']) . '">';
|
||||
foreach (array_slice((array) $i['links'], 0, (int) $i['limit']) as $item) {
|
||||
$link = RendererHelpers::link((array) ($item['link'] ?? []));
|
||||
if ($link['url']) {
|
||||
@@ -511,10 +511,10 @@ final class GeneralRenderer {
|
||||
if ($posts_query && method_exists($posts_query, 'have_posts')) {
|
||||
while ($posts_query->have_posts()) {
|
||||
$posts_query->the_post();
|
||||
$subtitle = class_exists('AKSRT\\Core\\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta_value(get_the_ID(), 'subtitle', '') : '';
|
||||
$subtitle = class_exists('Jio\\Core\\PostMetaBox') ? \Jio\Core\PostMetaBox::get_meta_value(get_the_ID(), 'subtitle', '') : '';
|
||||
$title = trim(wp_strip_all_tags(get_the_title())) . trim(wp_strip_all_tags((string) $subtitle));
|
||||
if (!empty($i['desc_s'])) {
|
||||
$description = class_exists('AKSRT\\Core\\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta_value(get_the_ID(), 'description', '') : '';
|
||||
$description = class_exists('Jio\\Core\\PostMetaBox') ? \Jio\Core\PostMetaBox::get_meta_value(get_the_ID(), 'description', '') : '';
|
||||
if (trim((string) $description) === '') $description = get_the_excerpt();
|
||||
$title .= ': ' . wp_html_excerpt(wp_strip_all_tags((string) $description), 160, '...');
|
||||
}
|
||||
@@ -543,6 +543,6 @@ final class GeneralRenderer {
|
||||
}
|
||||
|
||||
private static function icon_markup(string $icon): string {
|
||||
return aksrt_icon_markup($icon);
|
||||
return jio_icon_markup($icon);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem\Renderers;
|
||||
namespace Jio\WidgetSystem\Renderers;
|
||||
|
||||
use AKSRT\WidgetSystem\RendererHelpers;
|
||||
use Jio\WidgetSystem\RendererHelpers;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -22,34 +22,34 @@ final class KnowledgeProductRenderer {
|
||||
}
|
||||
|
||||
private static function pricing(array $i): string {
|
||||
$html = '<div class="aksrt-widget-grid aksrt-pricing" style="--aksrt-cols:' . (int) $i['pc_row'] . ';--aksrt-cols-m:' . (int) $i['m_row'] . '">';
|
||||
$html = '<div class="jio-widget-grid jio-pricing" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
||||
foreach ((array) $i['plans'] as $plan) {
|
||||
if (!is_array($plan)) {
|
||||
continue;
|
||||
}
|
||||
$url = '';
|
||||
$label = __('立即了解', 'aksrt');
|
||||
$label = __('立即了解', 'jio');
|
||||
if (($plan['cta_type'] ?? 'link') === 'post' && !empty($plan['post_id'])) {
|
||||
$url = (string) get_permalink((int) $plan['post_id']);
|
||||
$label = __('查看付费内容', 'aksrt');
|
||||
$label = __('查看付费内容', 'jio');
|
||||
} elseif (($plan['cta_type'] ?? 'link') === 'vip') {
|
||||
$url = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('vip') : home_url('/');
|
||||
$url = function_exists('jio_get_user_center_url') ? jio_get_user_center_url('vip') : home_url('/');
|
||||
$url = add_query_arg('level', (int) ($plan['vip_level'] ?? 1), $url);
|
||||
$label = __('开通会员', 'aksrt');
|
||||
$label = __('开通会员', 'jio');
|
||||
} else {
|
||||
$link = RendererHelpers::link((array) ($plan['link'] ?? []));
|
||||
$url = $link['url'];
|
||||
$label = $link['text'] ?: $label;
|
||||
}
|
||||
$html .= '<article class="aksrt-pricing-card' . (!empty($plan['featured']) ? ' is-featured' : '') . '">';
|
||||
$html .= '<article class="jio-pricing-card' . (!empty($plan['featured']) ? ' is-featured' : '') . '">';
|
||||
if (!empty($plan['featured'])) {
|
||||
$html .= '<span class="aksrt-pricing-card__badge">' . esc_html__('推荐', 'aksrt') . '</span>';
|
||||
$html .= '<span class="jio-pricing-card__badge">' . esc_html__('推荐', 'jio') . '</span>';
|
||||
}
|
||||
$html .= '<h3>' . esc_html((string) ($plan['title'] ?? '')) . '</h3><div class="aksrt-pricing-card__price">' . esc_html((string) ($plan['price'] ?? '')) . '</div><p>' . esc_html((string) ($plan['description'] ?? '')) . '</p><ul>';
|
||||
$html .= '<h3>' . esc_html((string) ($plan['title'] ?? '')) . '</h3><div class="jio-pricing-card__price">' . esc_html((string) ($plan['price'] ?? '')) . '</div><p>' . esc_html((string) ($plan['description'] ?? '')) . '</p><ul>';
|
||||
foreach (RendererHelpers::lines((string) ($plan['features'] ?? '')) as $feature) {
|
||||
$html .= '<li><i class="fa fas fa-check" aria-hidden="true"></i>' . esc_html($feature) . '</li>';
|
||||
}
|
||||
$html .= '</ul>' . ($url !== '' ? '<a class="aksrt-widget-button" href="' . esc_url($url) . '">' . esc_html($label) . '</a>' : '') . '</article>';
|
||||
$html .= '</ul>' . ($url !== '' ? '<a class="jio-widget-button" href="' . esc_url($url) . '">' . esc_html($label) . '</a>' : '') . '</article>';
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
@@ -61,36 +61,36 @@ final class KnowledgeProductRenderer {
|
||||
continue;
|
||||
}
|
||||
$rating = max(1, min(5, (int) ($item['rating'] ?? 5)));
|
||||
$slides .= '<div class="swiper-slide"><article class="aksrt-review-card"><div class="aksrt-review-card__rating" aria-label="' . esc_attr(sprintf(__('%d 星评价', 'aksrt'), $rating)) . '">' . str_repeat('<i class="fa fas fa-star" aria-hidden="true"></i>', $rating) . '</div><blockquote>' . esc_html((string) ($item['description'] ?? '')) . '</blockquote><footer>' . RendererHelpers::image((string) ($item['image'] ?? ''), '', 'aksrt-review-card__avatar') . '<span><strong>' . esc_html((string) ($item['title'] ?? '')) . '</strong><small>' . esc_html((string) ($item['value'] ?? '')) . '</small></span></footer></article></div>';
|
||||
$slides .= '<div class="swiper-slide"><article class="jio-review-card"><div class="jio-review-card__rating" aria-label="' . esc_attr(sprintf(__('%d 星评价', 'jio'), $rating)) . '">' . str_repeat('<i class="fa fas fa-star" aria-hidden="true"></i>', $rating) . '</div><blockquote>' . esc_html((string) ($item['description'] ?? '')) . '</blockquote><footer>' . RendererHelpers::image((string) ($item['image'] ?? ''), '', 'jio-review-card__avatar') . '<span><strong>' . esc_html((string) ($item['title'] ?? '')) . '</strong><small>' . esc_html((string) ($item['value'] ?? '')) . '</small></span></footer></article></div>';
|
||||
}
|
||||
return '<div class="new-swiper aksrt-widget-swiper aksrt-reviews" data-aksrt-swiper="cards"><div class="swiper-wrapper">' . $slides . '</div><div class="swiper-pagination"></div></div>';
|
||||
return '<div class="new-swiper jio-widget-swiper jio-reviews" data-jio-swiper="cards"><div class="swiper-wrapper">' . $slides . '</div><div class="swiper-pagination"></div></div>';
|
||||
}
|
||||
|
||||
private static function faq(array $i): string {
|
||||
$html = '<div class="aksrt-faq">';
|
||||
$html = '<div class="jio-faq">';
|
||||
if (!empty($i['search'])) {
|
||||
$html .= '<label class="aksrt-faq__search"><i class="fa fas fa-search" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__('搜索常见问题', 'aksrt') . '</span><input type="search" placeholder="' . esc_attr__('搜索问题', 'aksrt') . '"></label>';
|
||||
$html .= '<label class="jio-faq__search"><i class="fa fas fa-search" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__('搜索常见问题', 'jio') . '</span><input type="search" placeholder="' . esc_attr__('搜索问题', 'jio') . '"></label>';
|
||||
}
|
||||
$html .= '<div class="aksrt-faq__items">';
|
||||
$html .= '<div class="jio-faq__items">';
|
||||
foreach ((array) $i['items'] as $index => $item) {
|
||||
$id = 'aksrt-faq-' . $index . '-' . wp_rand(1000, 9999);
|
||||
$html .= '<section class="aksrt-faq__item" data-search="' . esc_attr(wp_strip_all_tags((string) ($item['question'] ?? '') . ' ' . (string) ($item['answer'] ?? ''))) . '"><button type="button" aria-expanded="false" aria-controls="' . esc_attr($id) . '"><span>' . esc_html((string) ($item['question'] ?? '')) . '</span><i class="fa fas fa-plus" aria-hidden="true"></i></button><div id="' . esc_attr($id) . '" hidden>' . wp_kses_post((string) ($item['answer'] ?? '')) . '</div></section>';
|
||||
$id = 'jio-faq-' . $index . '-' . wp_rand(1000, 9999);
|
||||
$html .= '<section class="jio-faq__item" data-search="' . esc_attr(wp_strip_all_tags((string) ($item['question'] ?? '') . ' ' . (string) ($item['answer'] ?? ''))) . '"><button type="button" aria-expanded="false" aria-controls="' . esc_attr($id) . '"><span>' . esc_html((string) ($item['question'] ?? '')) . '</span><i class="fa fas fa-plus" aria-hidden="true"></i></button><div id="' . esc_attr($id) . '" hidden>' . wp_kses_post((string) ($item['answer'] ?? '')) . '</div></section>';
|
||||
}
|
||||
return $html . '</div></div>';
|
||||
}
|
||||
|
||||
private static function stats(array $i): string {
|
||||
$html = '<div class="aksrt-widget-grid aksrt-stats" style="--aksrt-cols:' . (int) $i['pc_row'] . ';--aksrt-cols-m:' . (int) $i['m_row'] . '">';
|
||||
$html = '<div class="jio-widget-grid jio-stats" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
||||
foreach ((array) $i['items'] as $item) {
|
||||
$html .= '<article class="aksrt-stat"><strong data-count-up="' . esc_attr((string) ($item['value'] ?? '')) . '">' . esc_html((string) ($item['value'] ?? '')) . '</strong><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p></article>';
|
||||
$html .= '<article class="jio-stat"><strong data-count-up="' . esc_attr((string) ($item['value'] ?? '')) . '">' . esc_html((string) ($item['value'] ?? '')) . '</strong><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p></article>';
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
|
||||
private static function highlights(array $i): string {
|
||||
$html = '<div class="aksrt-widget-grid aksrt-highlights" style="--aksrt-cols:' . (int) $i['pc_row'] . ';--aksrt-cols-m:' . (int) $i['m_row'] . '">';
|
||||
$html = '<div class="jio-widget-grid jio-highlights" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
||||
foreach ((array) $i['items'] as $index => $item) {
|
||||
$html .= RendererHelpers::card_media((array) $item, 'aksrt-highlight aksrt-highlight--' . (($index % 5 === 0) ? 'large' : 'normal'));
|
||||
$html .= RendererHelpers::card_media((array) $item, 'jio-highlight jio-highlight--' . (($index % 5 === 0) ? 'large' : 'normal'));
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
@@ -99,22 +99,22 @@ final class KnowledgeProductRenderer {
|
||||
$tabs = $panels = '';
|
||||
$key = sanitize_html_class((string) ($context['widget_id'] ?? 'preview')) ?: 'preview';
|
||||
foreach ((array) $i['items'] as $index => $item) {
|
||||
$tab_id = 'aksrt-feature-' . $key . '-tab-' . $index;
|
||||
$panel_id = 'aksrt-feature-' . $key . '-panel-' . $index;
|
||||
$tab_id = 'jio-feature-' . $key . '-tab-' . $index;
|
||||
$panel_id = 'jio-feature-' . $key . '-panel-' . $index;
|
||||
$tabs .= '<button type="button" role="tab" id="' . esc_attr($tab_id) . '" aria-controls="' . esc_attr($panel_id) . '" data-feature-index="' . $index . '" aria-selected="' . ($index === 0 ? 'true' : 'false') . '" tabindex="' . ($index === 0 ? '0' : '-1') . '">' . esc_html((string) ($item['title'] ?? '')) . '</button>';
|
||||
$features = '';
|
||||
foreach (RendererHelpers::lines((string) ($item['features'] ?? '')) as $feature) {
|
||||
$features .= '<li>' . esc_html($feature) . '</li>';
|
||||
}
|
||||
$panels .= '<article role="tabpanel" id="' . esc_attr($panel_id) . '" aria-labelledby="' . esc_attr($tab_id) . '" tabindex="0" data-feature-panel="' . $index . '"' . ($index ? ' hidden' : '') . '><div class="aksrt-feature-intro__media">' . RendererHelpers::card_media((array) $item) . '</div><div class="aksrt-feature-intro__copy"><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p><ul>' . $features . '</ul></div></article>';
|
||||
$panels .= '<article role="tabpanel" id="' . esc_attr($panel_id) . '" aria-labelledby="' . esc_attr($tab_id) . '" tabindex="0" data-feature-panel="' . $index . '"' . ($index ? ' hidden' : '') . '><div class="jio-feature-intro__media">' . RendererHelpers::card_media((array) $item) . '</div><div class="jio-feature-intro__copy"><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p><ul>' . $features . '</ul></div></article>';
|
||||
}
|
||||
return '<div class="aksrt-feature-intro"><div class="aksrt-feature-intro__tabs" role="tablist" aria-label="' . esc_attr__('知识产品亮点', 'aksrt') . '">' . $tabs . '</div><div class="aksrt-feature-intro__panels">' . $panels . '</div></div>';
|
||||
return '<div class="jio-feature-intro"><div class="jio-feature-intro__tabs" role="tablist" aria-label="' . esc_attr__('知识产品亮点', 'jio') . '">' . $tabs . '</div><div class="jio-feature-intro__panels">' . $panels . '</div></div>';
|
||||
}
|
||||
|
||||
private static function tilt(array $i): string {
|
||||
$html = '<div class="aksrt-widget-grid aksrt-tilt-cases" style="--aksrt-cols:' . (int) $i['pc_row'] . ';--aksrt-cols-m:' . (int) $i['m_row'] . '">';
|
||||
$html = '<div class="jio-widget-grid jio-tilt-cases" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
||||
foreach ((array) $i['items'] as $item) {
|
||||
$html .= '<div class="aksrt-tilt-case" data-aksrt-tilt data-tilt-max="9" data-tilt-speed="500">' . RendererHelpers::card_media((array) $item) . '</div>';
|
||||
$html .= '<div class="jio-tilt-case" data-jio-tilt data-tilt-max="9" data-tilt-speed="500">' . RendererHelpers::card_media((array) $item) . '</div>';
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem\Renderers;
|
||||
namespace Jio\WidgetSystem\Renderers;
|
||||
|
||||
use AKSRT\WidgetSystem\RendererHelpers;
|
||||
use Jio\WidgetSystem\RendererHelpers;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -17,7 +17,7 @@ final class SliderRenderer {
|
||||
if (!$slides) {
|
||||
// 参考主题幻灯片(新):无可显示内容时仅向超级管理员提示。
|
||||
if (function_exists('is_super_admin') && is_super_admin()) {
|
||||
return '<div class="c-red muted-box mb20"><b>[' . esc_html__('幻灯片(新)', 'aksrt') . ']' . esc_html__('幻灯片模块:', 'aksrt') . '</b>' . esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'aksrt') . '</div>';
|
||||
return '<div class="c-red muted-box mb20"><b>[' . esc_html__('幻灯片(新)', 'jio') . ']' . esc_html__('幻灯片模块:', 'jio') . '</b>' . esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'jio') . '</div>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -27,8 +27,8 @@ final class SliderRenderer {
|
||||
private static function slider(array $slides, array $option, bool $with_margin = false): string {
|
||||
$option = array_merge(['direction' => 'horizontal', 'loop' => true, 'button' => true, 'pagination' => true, 'effect' => 'slide', 'scale_height' => true, 'scale' => 35, 'auto_height' => false, 'max_height' => 500, 'min_height' => 180, 'pc_height' => 400, 'm_height' => 200, 'spacebetween' => 15, 'speed' => 0, 'autoplay' => true, 'interval' => 4], $option);
|
||||
$is_mobile = function_exists('wp_is_mobile') && wp_is_mobile();
|
||||
$lazy = aksrt_is_lazy('lazy_sider');
|
||||
$lazy_src = aksrt_get_lazy_thumb('lg');
|
||||
$lazy = jio_is_lazy('lazy_sider');
|
||||
$lazy_src = jio_get_lazy_thumb('lg');
|
||||
$items = ''; $count = 0;
|
||||
foreach ($slides as $slide) {
|
||||
if (!is_array($slide)) continue;
|
||||
@@ -44,7 +44,7 @@ final class SliderRenderer {
|
||||
$media = '<video autoplay="" loop="" muted="" class="fit-cover radius8' . ($lazy ? ' lazyload' : '') . '"' . ($lazy ? ' data-src="' . esc_url($video) . '" src=""' : ' src="' . esc_url($video) . '"') . $poster . '></video><div class="absolute"></div>';
|
||||
}
|
||||
if ($media === '' && $background !== '') {
|
||||
$alt = (string) (($slide['text']['title'] ?? '') ?: ($slide['link']['text'] ?? '') ?: __('幻灯片', 'aksrt'));
|
||||
$alt = (string) (($slide['text']['title'] ?? '') ?: ($slide['link']['text'] ?? '') ?: __('幻灯片', 'jio'));
|
||||
$media = '<img class="radius8' . ($lazy ? ' lazyload swiper-lazy' : '') . '" ' . ($lazy ? 'data-src="' . esc_url($background) . '" src="' . esc_url($lazy_src) . '"' : 'src="' . esc_url($background) . '"') . ' alt="' . esc_attr($alt) . '">';
|
||||
}
|
||||
if ($media === '') continue;
|
||||
@@ -58,7 +58,7 @@ final class SliderRenderer {
|
||||
$scale = (float) ($layer['parallax_scale'] ?? 100) / 100;
|
||||
$parallax_attr .= ($scale && $scale !== 1.0) ? ' data-swiper-parallax-scale="' . esc_attr((string) $scale) . '"' : '';
|
||||
$class = !empty($layer['free_size']) ? ' slide-layer text-' . esc_attr((string) ($layer['align'] ?? 'center')) : '';
|
||||
$layers .= '<div class="absolute' . $class . '"' . $parallax_attr . '><img class="radius8' . ($lazy ? ' lazyload swiper-lazy' : '') . '" ' . ($lazy ? 'data-src="' . esc_url((string) $layer['image']) . '" src="' . esc_url($lazy_src) . '"' : 'src="' . esc_url((string) $layer['image']) . '"') . ' alt="' . esc_attr((string) (($slide['text']['title'] ?? '') ?: __('幻灯片', 'aksrt'))) . '"></div>';
|
||||
$layers .= '<div class="absolute' . $class . '"' . $parallax_attr . '><img class="radius8' . ($lazy ? ' lazyload swiper-lazy' : '') . '" ' . ($lazy ? 'data-src="' . esc_url((string) $layer['image']) . '" src="' . esc_url($lazy_src) . '"' : 'src="' . esc_url((string) $layer['image']) . '"') . ' alt="' . esc_attr((string) (($slide['text']['title'] ?? '') ?: __('幻灯片', 'jio'))) . '"></div>';
|
||||
}
|
||||
$text = (array) ($slide['text'] ?? []); $copy = '';
|
||||
if (!empty($text['title'])) { $style = ''; if (!empty($text['text_size_pc'])) $style .= '--text-size-pc:' . (int) $text['text_size_pc'] . 'px;'; if (!empty($text['text_size_m'])) $style .= '--text-size-m:' . (int) $text['text_size_m'] . 'px;'; $copy = '<div class="abs-center slide-text ' . esc_attr((string) ($text['text_align'] ?? 'left-bottom')) . '"' . ($style ? ' style="' . esc_attr($style) . '"' : '') . '><div class="slide-title">' . wp_kses_post((string) $text['title']) . '</div>' . (!empty($text['desc']) ? '<div class="slide-desc">' . wp_kses_post((string) $text['desc']) . '</div>' : '') . '</div>'; if (!empty($text['parallax'])) $copy = '<div class="absolute" data-swiper-parallax="' . (int) $text['parallax'] . '">' . $copy . '</div>'; }
|
||||
@@ -152,13 +152,13 @@ final class SliderRenderer {
|
||||
if (($is_mobile && $hide === 'm') || (!$is_mobile && $hide === 'pc')) continue;
|
||||
$title = (string) ($cover['title'] ?? '');
|
||||
$link = RendererHelpers::link((array) ($cover['link'] ?? []));
|
||||
$card = aksrt_graphic_card([
|
||||
$card = jio_graphic_card([
|
||||
'class' => 'noshadow mb10',
|
||||
'img' => (string) ($cover['image'] ?? ''),
|
||||
'video' => (string) ($cover['video'] ?? ''),
|
||||
'alt' => wp_strip_all_tags($title),
|
||||
'link' => ['url' => $link['url'], 'target' => $link['target']],
|
||||
'lazy' => aksrt_is_lazy('lazy_cover'),
|
||||
'lazy' => jio_is_lazy('lazy_cover'),
|
||||
'more' => trim($title) !== '' ? '<div class="abs-center text-center graphic-text this-font">' . wp_kses_post($title) . '</div>' : '',
|
||||
'height_scale' => 0,
|
||||
'mask_opacity' => (int) ($instance['mask_opacity'] ?? 0),
|
||||
@@ -173,7 +173,7 @@ final class SliderRenderer {
|
||||
if ($slider !== '') {
|
||||
$html .= '<div class="slider-col mb20' . $animation_class . '">' . $slider . '</div>';
|
||||
} elseif (function_exists('is_super_admin') && is_super_admin()) {
|
||||
$html .= '<div class="slider-col mb20"><div class="alert alert-warning">' . esc_html__('当前模块下没有可显示的幻灯片,请添加幻灯片或移除此模块', 'aksrt') . '</div></div>';
|
||||
$html .= '<div class="slider-col mb20"><div class="alert alert-warning">' . esc_html__('当前模块下没有可显示的幻灯片,请添加幻灯片或移除此模块', 'jio') . '</div></div>';
|
||||
}
|
||||
$html .= '<div class="cover-col mb10">' . $cover_html . '</div>';
|
||||
return $html . '</div>';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem\Renderers;
|
||||
namespace Jio\WidgetSystem\Renderers;
|
||||
|
||||
use AKSRT\WidgetSystem\RendererHelpers;
|
||||
use Jio\WidgetSystem\RendererHelpers;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -20,7 +20,7 @@ final class UserRenderer {
|
||||
}
|
||||
|
||||
private static function user_card(array $i): string {
|
||||
if (class_exists('AKSRT\\Settings\\Settings') && \AKSRT\Settings\Settings::close_sign()) {
|
||||
if (class_exists('Jio\\Settings\\Settings') && \Jio\Settings\Settings::close_sign()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -79,20 +79,20 @@ final class UserRenderer {
|
||||
private static function guest_card(array $i): string {
|
||||
$title = trim((string) ($i['loged_title'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = __('Hi!请登录', 'aksrt');
|
||||
$title = __('Hi!请登录', 'jio');
|
||||
}
|
||||
|
||||
$cover = !isset($i['show_img_bg']) || !empty($i['show_img_bg'])
|
||||
? self::cover(0, 'lazy_other')
|
||||
: '';
|
||||
$avatar = '<span class="avatar-img avatar-lg"><img alt="' . esc_attr__('默认头像', 'aksrt') . '" class="fit-cover avatar" src="' . esc_url(aksrt_get_default_avatar_url()) . '"></span>';
|
||||
$avatar = '<span class="avatar-img avatar-lg"><img alt="' . esc_attr__('默认头像', 'jio') . '" class="fit-cover avatar" src="' . esc_url(jio_get_default_avatar_url()) . '"></span>';
|
||||
|
||||
$buttons = '<a href="javascript:;" class="signin-loader but jb-blue padding-lg"><i class="fa fas fa-fw fa-sign-in-alt" aria-hidden="true"></i>' . esc_html__('登录', 'aksrt') . '</a>';
|
||||
$registration_enabled = class_exists('AKSRT\\Settings\\Settings')
|
||||
? \AKSRT\Settings\Settings::registration_enabled()
|
||||
$buttons = '<a href="javascript:;" class="signin-loader but jb-blue padding-lg"><i class="fa fas fa-fw fa-sign-in-alt" aria-hidden="true"></i>' . esc_html__('登录', 'jio') . '</a>';
|
||||
$registration_enabled = class_exists('Jio\\Settings\\Settings')
|
||||
? \Jio\Settings\Settings::registration_enabled()
|
||||
: (bool) get_option('users_can_register');
|
||||
if ($registration_enabled) {
|
||||
$buttons .= '<a href="javascript:;" class="signup-loader ml10 but jb-yellow padding-lg">' . aksrt_renderer_svg_icon('signup') . esc_html__('注册', 'aksrt') . '</a>';
|
||||
$buttons .= '<a href="javascript:;" class="signup-loader ml10 but jb-yellow padding-lg">' . jio_renderer_svg_icon('signup') . esc_html__('注册', 'jio') . '</a>';
|
||||
}
|
||||
|
||||
return '<div class="mb20"><div class="user-card zib-widget widget">' . $cover
|
||||
@@ -108,15 +108,15 @@ final class UserRenderer {
|
||||
}
|
||||
|
||||
private static function social_login(): string {
|
||||
if (!class_exists('AKSRT\\Auth\\OAuth')) {
|
||||
if (!class_exists('Jio\\Auth\\OAuth')) {
|
||||
return '';
|
||||
}
|
||||
$items = \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data();
|
||||
$items = \Jio\Auth\OAuth::get_instance()->get_auth_providers_data();
|
||||
if ($items === []) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '<div class="social-separator separator muted-3-color em09 mt20 mb20">' . esc_html__('社交账号登录', 'aksrt') . '</div><div class="social_loginbar">';
|
||||
$html = '<div class="social-separator separator muted-3-color em09 mt20 mb20">' . esc_html__('社交账号登录', 'jio') . '</div><div class="social_loginbar">';
|
||||
foreach ($items as $item) {
|
||||
$name = sanitize_html_class((string) ($item['name'] ?? ''));
|
||||
$style_name = str_starts_with($name, 'clogin_') ? substr($name, 7) : $name;
|
||||
@@ -125,17 +125,17 @@ final class UserRenderer {
|
||||
if ($name === '' || $style_name === '' || $label === '' || $url === '') {
|
||||
continue;
|
||||
}
|
||||
$html .= '<a rel="nofollow" href="' . esc_url($url) . '" class="social-login-item ' . esc_attr($style_name) . ' toggle-radius" data-provider="' . esc_attr($name) . '" aria-label="' . esc_attr(sprintf(__('%s登录', 'aksrt'), $label)) . '" title="' . esc_attr(sprintf(__('%s登录', 'aksrt'), $label)) . '">' . (string) ($item['icon'] ?? '') . '</a>';
|
||||
$html .= '<a rel="nofollow" href="' . esc_url($url) . '" class="social-login-item ' . esc_attr($style_name) . ' toggle-radius" data-provider="' . esc_attr($name) . '" aria-label="' . esc_attr(sprintf(__('%s登录', 'jio'), $label)) . '" title="' . esc_attr(sprintf(__('%s登录', 'jio'), $label)) . '">' . (string) ($item['icon'] ?? '') . '</a>';
|
||||
}
|
||||
return $html . '</div>';
|
||||
}
|
||||
|
||||
private static function cover(int $user_id, string $lazy_type): string {
|
||||
$cover_url = aksrt_get_user_cover_url($user_id);
|
||||
$cover_url = jio_get_user_cover_url($user_id);
|
||||
if ($cover_url === '') {
|
||||
return '';
|
||||
}
|
||||
return '<div class="user-cover graphic" style="padding-bottom: 50%;"><img' . aksrt_get_lazy_attr($lazy_type, $cover_url, 'fit-cover', aksrt_get_lazy_thumb()) . ' alt="' . esc_attr__('用户封面', 'aksrt') . '"></div>';
|
||||
return '<div class="user-cover graphic" style="padding-bottom: 50%;"><img' . jio_get_lazy_attr($lazy_type, $cover_url, 'fit-cover', jio_get_lazy_thumb()) . ' alt="' . esc_attr__('用户封面', 'jio') . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,19 +152,19 @@ final class UserRenderer {
|
||||
'show_button' => true,
|
||||
'button_1' => 'post',
|
||||
'button_1_class' => 'jb-pink',
|
||||
'button_1_text' => __('发布文章', 'aksrt'),
|
||||
'button_1_text' => __('发布文章', 'jio'),
|
||||
'button_2' => 'center',
|
||||
'button_2_class' => 'jb-blue',
|
||||
'button_2_text' => __('用户中心', 'aksrt'),
|
||||
'button_2_text' => __('用户中心', 'jio'),
|
||||
'limit' => 6,
|
||||
'orderby' => 'views',
|
||||
'post_type' => 'post',
|
||||
'post_style' => 'card',
|
||||
]);
|
||||
|
||||
// 会员/禁封徽章不再挂头像角标,改由名字行的会员位出图(aksrt_get_user_name)。
|
||||
$avatar = aksrt_get_avatar_box($user_id, 'avatar-img avatar-lg', true, false);
|
||||
$name = aksrt_get_user_name([
|
||||
// 会员/禁封徽章不再挂头像角标,改由名字行的会员位出图(jio_get_user_name)。
|
||||
$avatar = jio_get_avatar_box($user_id, 'avatar-img avatar-lg', true, false);
|
||||
$name = jio_get_user_name([
|
||||
'id' => $user_id,
|
||||
'class' => 'flex1 flex ac',
|
||||
'vip' => true,
|
||||
@@ -173,8 +173,8 @@ final class UserRenderer {
|
||||
'level' => true,
|
||||
'follow' => true,
|
||||
]);
|
||||
$tag_metas = aksrt_get_user_badges($user_id);
|
||||
$desc = aksrt_get_user_description($user_id);
|
||||
$tag_metas = jio_get_user_badges($user_id);
|
||||
$desc = jio_get_user_description($user_id);
|
||||
$btns = '';
|
||||
$posts = '';
|
||||
$checkin = '';
|
||||
@@ -184,7 +184,7 @@ final class UserRenderer {
|
||||
$args['show_button'] = false;
|
||||
}
|
||||
if ($args['show_posts'] && (int) $args['limit'] > 0) {
|
||||
$posts = aksrt_render_user_card_posts([
|
||||
$posts = jio_render_user_card_posts([
|
||||
'user_id' => $user_id,
|
||||
'limit' => (int) $args['limit'],
|
||||
'orderby' => (string) $args['orderby'],
|
||||
@@ -193,15 +193,15 @@ final class UserRenderer {
|
||||
]);
|
||||
}
|
||||
if ($args['show_checkin'] && $cuid === $user_id) {
|
||||
$checkin = aksrt_header_user_checkin_btn($user_id, 'img-badge jb-yellow');
|
||||
$checkin = jio_header_user_checkin_btn($user_id, 'img-badge jb-yellow');
|
||||
}
|
||||
|
||||
if ($args['show_button']) {
|
||||
$btns .= self::new_add_btn((string) $args['button_1'], 'but pw-1em mr6 ' . (string) $args['button_1_class'], (string) $args['button_1_text']);
|
||||
if ('home' === $args['button_2']) {
|
||||
$btns .= self::card_link(aksrt_get_user_home_url($user_id), (string) $args['button_2_class'], (string) $args['button_2_text']);
|
||||
$btns .= self::card_link(jio_get_user_home_url($user_id), (string) $args['button_2_class'], (string) $args['button_2_text']);
|
||||
} else {
|
||||
$btns .= self::card_link(aksrt_get_user_center_url(), (string) $args['button_2_class'], (string) $args['button_2_text'], true);
|
||||
$btns .= self::card_link(jio_get_user_center_url(), (string) $args['button_2_class'], (string) $args['button_2_text'], true);
|
||||
}
|
||||
$btns = $btns !== '' ? '<div class="user-btns mt20">' . $btns . '</div>' : '';
|
||||
}
|
||||
@@ -229,7 +229,7 @@ final class UserRenderer {
|
||||
if ($type !== 'post') {
|
||||
return '';
|
||||
}
|
||||
$url = aksrt_get_new_post_url();
|
||||
$url = jio_get_new_post_url();
|
||||
if ($url === '') {
|
||||
return '';
|
||||
}
|
||||
@@ -249,11 +249,11 @@ final class UserRenderer {
|
||||
usort($users, static fn(\WP_User $a, \WP_User $b): int => self::metric($b, $metric) <=> self::metric($a, $metric));
|
||||
$users = array_slice($users, 0, (int) $i['number']);
|
||||
if (!$users) {
|
||||
return RendererHelpers::empty_state(__('暂无用户数据', 'aksrt'));
|
||||
return RendererHelpers::empty_state(__('暂无用户数据', 'jio'));
|
||||
}
|
||||
$html = '<ol class="aksrt-user-ranking">';
|
||||
$html = '<ol class="jio-user-ranking">';
|
||||
foreach ($users as $index => $user) {
|
||||
$html .= '<li><span class="aksrt-user-ranking__index' . (!empty($i['show_badge']) && $index < 3 ? ' is-top' : '') . '">' . ($index + 1) . '</span>' . self::user_tile($user, self::metric($user, $metric), self::metric_label($metric)) . '</li>';
|
||||
$html .= '<li><span class="jio-user-ranking__index' . (!empty($i['show_badge']) && $index < 3 ? ' is-top' : '') . '">' . ($index + 1) . '</span>' . self::user_tile($user, self::metric($user, $metric), self::metric_label($metric)) . '</li>';
|
||||
}
|
||||
return $html . '</ol>';
|
||||
}
|
||||
@@ -277,7 +277,7 @@ final class UserRenderer {
|
||||
}
|
||||
return self::metric($b, $orderby) <=> self::metric($a, $orderby);
|
||||
});
|
||||
$html = '<div class="aksrt-widget-grid aksrt-user-list">';
|
||||
$html = '<div class="jio-widget-grid jio-user-list">';
|
||||
foreach (array_slice($users, 0, (int) $i['number']) as $user) {
|
||||
$html .= '<article>' . self::user_tile($user, self::metric($user, $orderby), self::metric_label($orderby)) . '</article>';
|
||||
}
|
||||
@@ -285,27 +285,27 @@ final class UserRenderer {
|
||||
}
|
||||
|
||||
private static function user_tile(\WP_User $user, int $value, string $label): string {
|
||||
$url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : get_author_posts_url((int) $user->ID);
|
||||
return '<a class="aksrt-user-tile" href="' . esc_url($url) . '">' . (function_exists('aksrt_get_avatar_html') ? aksrt_get_avatar_html($user->ID, 64) : get_avatar($user->ID, 64)) . '<span><strong>' . esc_html($user->display_name) . '</strong><small>' . esc_html($label) . ' ' . number_format_i18n($value) . '</small></span></a>';
|
||||
$url = function_exists('jio_get_user_home_url') ? jio_get_user_home_url($user) : get_author_posts_url((int) $user->ID);
|
||||
return '<a class="jio-user-tile" href="' . esc_url($url) . '">' . (function_exists('jio_get_avatar_html') ? jio_get_avatar_html($user->ID, 64) : get_avatar($user->ID, 64)) . '<span><strong>' . esc_html($user->display_name) . '</strong><small>' . esc_html($label) . ' ' . number_format_i18n($value) . '</small></span></a>';
|
||||
}
|
||||
|
||||
private static function metric(\WP_User $user, string $metric): int {
|
||||
$id = (int) $user->ID;
|
||||
if ($metric === 'points') {
|
||||
return aksrt_user_points($id);
|
||||
return jio_user_points($id);
|
||||
}
|
||||
if ($metric === 'followers') {
|
||||
return class_exists('AKSRT\\User\\Follow') ? (int) \AKSRT\User\Follow::get_instance()->get_follower_count($id) : 0;
|
||||
return class_exists('Jio\\User\\Follow') ? (int) \Jio\User\Follow::get_instance()->get_follower_count($id) : 0;
|
||||
}
|
||||
if ($metric === 'post_count') {
|
||||
return (int) count_user_posts($id, 'post', true);
|
||||
}
|
||||
$key = $metric === 'checkin_continuous_day' ? 'aksrt_checkin_continuous_day' : 'aksrt_checkin_all_day';
|
||||
$key = $metric === 'checkin_continuous_day' ? 'jio_checkin_continuous_day' : 'jio_checkin_all_day';
|
||||
return (int) get_user_meta($id, $key, true);
|
||||
}
|
||||
|
||||
private static function metric_label(string $metric): string {
|
||||
$labels = ['points' => __('积分', 'aksrt'), 'followers' => __('粉丝', 'aksrt'), 'post_count' => __('文章', 'aksrt'), 'registered' => __('新加入', 'aksrt'), 'display_name' => __('用户', 'aksrt'), 'checkin_all_day' => __('累计签到', 'aksrt'), 'checkin_continuous_day' => __('连续签到', 'aksrt')];
|
||||
$labels = ['points' => __('积分', 'jio'), 'followers' => __('粉丝', 'jio'), 'post_count' => __('文章', 'jio'), 'registered' => __('新加入', 'jio'), 'display_name' => __('用户', 'jio'), 'checkin_all_day' => __('累计签到', 'jio'), 'checkin_continuous_day' => __('连续签到', 'jio')];
|
||||
return $labels[$metric] ?? $labels['points'];
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Public read-only endpoints for saved widget instances. */
|
||||
final class RestController extends \WP_REST_Controller {
|
||||
public function __construct() {
|
||||
$this->namespace = 'aksrt/v1';
|
||||
$this->namespace = 'jio/v1';
|
||||
$this->rest_base = 'widgets';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ final class RestController extends \WP_REST_Controller {
|
||||
'permission_callback' => '__return_true',
|
||||
'args' => [
|
||||
'widget' => ['type' => 'string', 'required' => true, 'pattern' => '^[a-z][a-z0-9_]*$', 'validate_callback' => [$this, 'validate_widget']],
|
||||
'instance' => ['type' => 'string', 'required' => true, 'pattern' => '^aksrt_widget_[a-z0-9_]+-[1-9][0-9]*$'],
|
||||
'instance' => ['type' => 'string', 'required' => true, 'pattern' => '^jio_widget_[a-z0-9_]+-[1-9][0-9]*$'],
|
||||
'page' => ['type' => 'integer', 'default' => 1, 'minimum' => 1, 'maximum' => 1000],
|
||||
'segment' => ['type' => 'string', 'default' => '', 'pattern' => '^[0-9]{0,2}$'],
|
||||
],
|
||||
@@ -36,11 +36,11 @@ final class RestController extends \WP_REST_Controller {
|
||||
public function get_items($request) {
|
||||
$unknown = array_diff(array_keys($request->get_params()), ['widget', 'instance', 'page', 'segment', 'rest_route']);
|
||||
if ($unknown) {
|
||||
return new \WP_Error('aksrt_widget_unknown_parameter', __('请求包含不支持的参数。', 'aksrt'), ['status' => 400, 'parameters' => array_values($unknown)]);
|
||||
return new \WP_Error('jio_widget_unknown_parameter', __('请求包含不支持的参数。', 'jio'), ['status' => 400, 'parameters' => array_values($unknown)]);
|
||||
}
|
||||
$slug = (string) $request->get_param('widget');
|
||||
if (!RendererRegistry::supports_items($slug)) {
|
||||
return new \WP_Error('aksrt_widget_items_unsupported', __('该小工具不提供动态列表。', 'aksrt'), ['status' => 404]);
|
||||
return new \WP_Error('jio_widget_items_unsupported', __('该小工具不提供动态列表。', 'jio'), ['status' => 404]);
|
||||
}
|
||||
$instance_id = (string) $request->get_param('instance');
|
||||
$instance = $this->load_instance($slug, $instance_id);
|
||||
@@ -57,7 +57,7 @@ final class RestController extends \WP_REST_Controller {
|
||||
private function load_instance(string $slug, string $instance_id) {
|
||||
$definition = WidgetRegistry::get($slug);
|
||||
if ($definition === null || !preg_match('/^' . preg_quote($definition->id_base(), '/') . '-([1-9][0-9]*)$/', $instance_id, $matches)) {
|
||||
return new \WP_Error('aksrt_widget_invalid_instance', __('小工具实例无效。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_widget_invalid_instance', __('小工具实例无效。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
$sidebars = wp_get_sidebars_widgets();
|
||||
$registered = false;
|
||||
@@ -68,13 +68,13 @@ final class RestController extends \WP_REST_Controller {
|
||||
}
|
||||
}
|
||||
if (!$registered) {
|
||||
return new \WP_Error('aksrt_widget_instance_not_registered', __('小工具实例未挂载。', 'aksrt'), ['status' => 404]);
|
||||
return new \WP_Error('jio_widget_instance_not_registered', __('小工具实例未挂载。', 'jio'), ['status' => 404]);
|
||||
}
|
||||
$widget = new SchemaWidget($definition);
|
||||
$settings = $widget->get_settings();
|
||||
$number = (int) $matches[1];
|
||||
if (!is_array($settings) || !isset($settings[$number]) || !is_array($settings[$number])) {
|
||||
return new \WP_Error('aksrt_widget_instance_not_found', __('未找到小工具配置。', 'aksrt'), ['status' => 404]);
|
||||
return new \WP_Error('jio_widget_instance_not_found', __('未找到小工具配置。', 'jio'), ['status' => 404]);
|
||||
}
|
||||
return $definition->normalize($settings[$number]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -16,7 +16,7 @@ final class SchemaWidget extends \WP_Widget {
|
||||
$definition->id_base(),
|
||||
$definition->name(),
|
||||
[
|
||||
'classname' => 'aksrt-schema-widget aksrt-schema-widget--' . $definition->slug(),
|
||||
'classname' => 'jio-schema-widget jio-schema-widget--' . $definition->slug(),
|
||||
'description' => $definition->description(),
|
||||
'customize_selective_refresh' => true,
|
||||
]
|
||||
@@ -28,7 +28,7 @@ final class SchemaWidget extends \WP_Widget {
|
||||
}
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
$renderer = 'AKSRT\\WidgetSystem\\FrontendRenderer';
|
||||
$renderer = 'Jio\\WidgetSystem\\FrontendRenderer';
|
||||
if (class_exists($renderer) && is_callable([$renderer, 'render'])) {
|
||||
$renderer::render($this->definition, (array) $args, $this->definition->normalize((array) $instance), $this);
|
||||
}
|
||||
@@ -64,10 +64,10 @@ final class SchemaWidget extends \WP_Widget {
|
||||
|
||||
private function render_lazy_placeholder(): void {
|
||||
printf(
|
||||
'<div class="aksrt-widget-form-lazy" data-id-base="%1$s" data-widget-number="%2$s"><div class="aksrt-widget-form-lazy__status"><div class="t-notice t-loading">%3$s</div></div></div>',
|
||||
'<div class="jio-widget-form-lazy" data-id-base="%1$s" data-widget-number="%2$s"><div class="jio-widget-form-lazy__status"><div class="t-notice t-loading">%3$s</div></div></div>',
|
||||
esc_attr($this->id_base),
|
||||
esc_attr((string) $this->number),
|
||||
esc_html__('正在加载模块配置…', 'aksrt')
|
||||
esc_html__('正在加载模块配置…', 'jio')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Admin AJAX endpoints for per-sidebar export, JSON import and template import. */
|
||||
final class TransferController {
|
||||
public const NONCE = 'aksrt_widgets_transfer';
|
||||
public const NONCE = 'jio_widgets_transfer';
|
||||
|
||||
public static function register_hooks(): void {
|
||||
add_action('wp_ajax_aksrt_widgets_export_sidebar', [self::class, 'ajax_export']);
|
||||
add_action('wp_ajax_aksrt_widgets_import_sidebar', [self::class, 'ajax_import']);
|
||||
add_action('wp_ajax_aksrt_widgets_list_templates', [self::class, 'ajax_list_templates']);
|
||||
add_action('wp_ajax_aksrt_widgets_import_template', [self::class, 'ajax_import_template']);
|
||||
add_action('wp_ajax_jio_widgets_export_sidebar', [self::class, 'ajax_export']);
|
||||
add_action('wp_ajax_jio_widgets_import_sidebar', [self::class, 'ajax_import']);
|
||||
add_action('wp_ajax_jio_widgets_list_templates', [self::class, 'ajax_list_templates']);
|
||||
add_action('wp_ajax_jio_widgets_import_template', [self::class, 'ajax_import_template']);
|
||||
}
|
||||
|
||||
public static function ajax_export(): void {
|
||||
@@ -27,22 +27,22 @@ final class TransferController {
|
||||
$sidebar = self::target_sidebar();
|
||||
$raw = isset($_POST['json']) ? trim((string) wp_unslash($_POST['json'])) : '';
|
||||
if ($raw === '') {
|
||||
wp_send_json_error(['message' => __('请粘贴 JSON 内容。', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请粘贴 JSON 内容。', 'jio')]);
|
||||
}
|
||||
if (strlen($raw) > 2 * MB_IN_BYTES) {
|
||||
wp_send_json_error(['message' => __('JSON 内容超过 2MB。', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('JSON 内容超过 2MB。', 'jio')]);
|
||||
}
|
||||
$payload = json_decode($raw, true);
|
||||
if (!is_array($payload)) {
|
||||
wp_send_json_error(['message' => __('JSON 解析失败,请检查格式。', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('JSON 解析失败,请检查格式。', 'jio')]);
|
||||
}
|
||||
$mode = self::import_mode();
|
||||
$result = self::run_import($payload, $sidebar, $mode);
|
||||
$message = $mode === 'append'
|
||||
/* translators: 1: sidebar name, 2: imported widget count */
|
||||
? __('已向侧栏「%1$s」末尾追加 %2$d 个小工具。请刷新页面后查看效果。', 'aksrt')
|
||||
? __('已向侧栏「%1$s」末尾追加 %2$d 个小工具。请刷新页面后查看效果。', 'jio')
|
||||
/* translators: 1: sidebar name, 2: imported widget count */
|
||||
: __('已覆盖侧栏「%1$s」并导入 %2$d 个小工具。请刷新页面后查看效果。', 'aksrt');
|
||||
: __('已覆盖侧栏「%1$s」并导入 %2$d 个小工具。请刷新页面后查看效果。', 'jio');
|
||||
self::send_result($sidebar, $mode, $result, $message);
|
||||
}
|
||||
|
||||
@@ -74,23 +74,23 @@ final class TransferController {
|
||||
$result = self::run_import($payload, $sidebar, $mode);
|
||||
$message = $mode === 'append'
|
||||
/* translators: 1: sidebar name, 2: imported widget count */
|
||||
? __('已从模板向侧栏「%1$s」末尾追加 %2$d 个小工具。请刷新页面后查看效果。', 'aksrt')
|
||||
? __('已从模板向侧栏「%1$s」末尾追加 %2$d 个小工具。请刷新页面后查看效果。', 'jio')
|
||||
/* translators: 1: sidebar name, 2: imported widget count */
|
||||
: __('已用模板覆盖侧栏「%1$s」并导入 %2$d 个小工具。请刷新页面后查看效果。', 'aksrt');
|
||||
: __('已用模板覆盖侧栏「%1$s」并导入 %2$d 个小工具。请刷新页面后查看效果。', 'jio');
|
||||
self::send_result($sidebar, $mode, $result, $message, ['template_id' => $template]);
|
||||
}
|
||||
|
||||
private static function authorize(): void {
|
||||
check_ajax_referer(self::NONCE, 'nonce');
|
||||
if (!current_user_can('edit_theme_options')) {
|
||||
wp_send_json_error(['message' => __('权限不足', 'aksrt')], 403);
|
||||
wp_send_json_error(['message' => __('权限不足', 'jio')], 403);
|
||||
}
|
||||
}
|
||||
|
||||
private static function target_sidebar(): string {
|
||||
$sidebar = isset($_POST['sidebar_id']) ? sanitize_key(wp_unslash($_POST['sidebar_id'])) : '';
|
||||
if ($sidebar === '' || !isset($GLOBALS['wp_registered_sidebars'][$sidebar])) {
|
||||
wp_send_json_error(['message' => __('无效的侧栏。', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('无效的侧栏。', 'jio')]);
|
||||
}
|
||||
return $sidebar;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Canonical 40 static areas plus five opt-in areas for each page. */
|
||||
final class WidgetAreas {
|
||||
private const PAGE_CACHE_KEY = 'aksrt_widget_pages_v1';
|
||||
private const PAGE_CACHE_KEY = 'jio_widget_pages_v1';
|
||||
|
||||
/** @return array<string, array{0:string,1:string,2:string}> */
|
||||
public static function definitions(): array {
|
||||
@@ -69,7 +69,7 @@ final class WidgetAreas {
|
||||
if (!is_active_sidebar($id)) {
|
||||
return false;
|
||||
}
|
||||
$class = trim('aksrt-widget-area aksrt-widget-area--' . sanitize_html_class($id) . ' ' . $class);
|
||||
$class = trim('jio-widget-area jio-widget-area--' . sanitize_html_class($id) . ' ' . $class);
|
||||
echo '<div class="' . esc_attr($class) . '" data-widget-area="' . esc_attr($id) . '">';
|
||||
dynamic_sidebar($id);
|
||||
echo '</div>';
|
||||
@@ -77,11 +77,11 @@ final class WidgetAreas {
|
||||
}
|
||||
|
||||
public static function flush_page_cache(): void {
|
||||
wp_cache_delete(self::PAGE_CACHE_KEY, 'aksrt');
|
||||
wp_cache_delete(self::PAGE_CACHE_KEY, 'jio');
|
||||
}
|
||||
|
||||
private static function register_page_areas(): void {
|
||||
$page_ids = wp_cache_get(self::PAGE_CACHE_KEY, 'aksrt');
|
||||
$page_ids = wp_cache_get(self::PAGE_CACHE_KEY, 'jio');
|
||||
if (!is_array($page_ids)) {
|
||||
$page_ids = get_posts([
|
||||
'post_type' => 'page',
|
||||
@@ -101,7 +101,7 @@ final class WidgetAreas {
|
||||
],
|
||||
]);
|
||||
$page_ids = array_map('absint', $page_ids);
|
||||
wp_cache_set(self::PAGE_CACHE_KEY, $page_ids, 'aksrt');
|
||||
wp_cache_set(self::PAGE_CACHE_KEY, $page_ids, 'jio');
|
||||
}
|
||||
|
||||
$positions = [
|
||||
@@ -135,11 +135,11 @@ final class WidgetAreas {
|
||||
private static function register_area(string $id, string $name, string $description, string $kind): void {
|
||||
register_sidebar([
|
||||
'id' => $id,
|
||||
'name' => __($name, 'aksrt'),
|
||||
'description' => __($description, 'aksrt'),
|
||||
'before_widget' => '<section id="%1$s" class="aksrt-widget-shell aksrt-widget-shell--' . esc_attr($kind) . ' %2$s">',
|
||||
'name' => __($name, 'jio'),
|
||||
'description' => __($description, 'jio'),
|
||||
'before_widget' => '<section id="%1$s" class="jio-widget-shell jio-widget-shell--' . esc_attr($kind) . ' %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3 class="aksrt-widget-shell__title">',
|
||||
'before_title' => '<h3 class="jio-widget-shell__title">',
|
||||
'after_title' => '</h3>',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Canonical catalog of the 37 modern AKSRT widgets.
|
||||
* Canonical catalog of the 37 modern Jio widgets.
|
||||
*/
|
||||
final class WidgetCatalog {
|
||||
public static function definitions(): array {
|
||||
@@ -64,7 +64,7 @@ final class WidgetCatalog {
|
||||
foreach ($items as [$slug, $name, $description, $size]) {
|
||||
$definitions[] = [
|
||||
'slug' => $slug,
|
||||
'name' => 'AKSRT ' . $name,
|
||||
'name' => 'Jio ' . $name,
|
||||
'description' => $description,
|
||||
'group' => $group,
|
||||
'renderer' => $slug,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -57,7 +57,7 @@ final class WidgetDefinition {
|
||||
}
|
||||
|
||||
public function id_base(): string {
|
||||
return 'aksrt_widget_' . $this->slug;
|
||||
return 'jio_widget_' . $this->slug;
|
||||
}
|
||||
|
||||
public function name(): string {
|
||||
@@ -99,15 +99,15 @@ final class WidgetDefinition {
|
||||
$header[] = ['type' => 'content', 'content' => esc_html($this->description)];
|
||||
}
|
||||
$reminders = [
|
||||
'wide' => __('此模块适合放在页面的全宽度或主内容容器中,不能放置在较小的容器中', 'aksrt'),
|
||||
'sidebar' => __('此模块只适合添加到侧边栏', 'aksrt'),
|
||||
'wide' => __('此模块适合放在页面的全宽度或主内容容器中,不能放置在较小的容器中', 'jio'),
|
||||
'sidebar' => __('此模块只适合添加到侧边栏', 'jio'),
|
||||
];
|
||||
if (isset($reminders[$this->size])) {
|
||||
$header[] = ['type' => 'submessage', 'style' => 'warning', 'content' => '<i class="fas fa-fw fa-info-circle"></i>' . esc_html($reminders[$this->size])];
|
||||
}
|
||||
$common = CommonFields::for_definition($this->common);
|
||||
if ($common && $this->fields) {
|
||||
$common[] = ['type' => 'subheading', 'content' => esc_html__('模块内容配置', 'aksrt')];
|
||||
$common[] = ['type' => 'subheading', 'content' => esc_html__('模块内容配置', 'jio')];
|
||||
}
|
||||
return array_merge($header, $common, $this->fields);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -31,7 +31,7 @@ final class WidgetRegistry {
|
||||
}
|
||||
|
||||
public static function get_by_id_base(string $id_base): ?WidgetDefinition {
|
||||
$prefix = 'aksrt_widget_';
|
||||
$prefix = 'jio_widget_';
|
||||
if (!str_starts_with($id_base, $prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -436,8 +436,8 @@ final class WidgetSchemas {
|
||||
];
|
||||
if ($slug === 'slider_media_combo') {
|
||||
$combo_slides = [
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题:AKSRT', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题 AKSRT', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题:Jio', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题 Jio', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
];
|
||||
$combo_option = [
|
||||
['id' => 'loop', 'type' => 'switcher', 'label' => '循环切换', 'default' => true],
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Import/export contract for schema widgets. */
|
||||
final class WidgetTransfer {
|
||||
public const FORMAT = 'aksrt.widgets.v1';
|
||||
public const FORMAT = 'jio.widgets.v1';
|
||||
|
||||
/** @return array<string, array<string,mixed>> */
|
||||
public static function templates(): array {
|
||||
return [
|
||||
'article_home' => [
|
||||
'title' => __('文章首页', 'aksrt'),
|
||||
'desc' => __('公告、幻灯片、多栏目文章与热榜侧栏。', 'aksrt'),
|
||||
'remind' => __('导入到首页主内容区域,侧栏模块会一并导入。', 'aksrt'),
|
||||
'title' => __('文章首页', 'jio'),
|
||||
'desc' => __('公告、幻灯片、多栏目文章与热榜侧栏。', 'jio'),
|
||||
'remind' => __('导入到首页主内容区域,侧栏模块会一并导入。', 'jio'),
|
||||
'sidebars' => [
|
||||
'home_top_content' => [
|
||||
['widget' => 'notice', 'settings' => ['title' => '站点公告']],
|
||||
@@ -25,9 +25,9 @@ final class WidgetTransfer {
|
||||
],
|
||||
],
|
||||
'article_list' => [
|
||||
'title' => __('文章列表', 'aksrt'),
|
||||
'desc' => __('标题、分类卡片与可分页文章列表。', 'aksrt'),
|
||||
'remind' => __('需已有文章与分类内容。', 'aksrt'),
|
||||
'title' => __('文章列表', 'jio'),
|
||||
'desc' => __('标题、分类卡片与可分页文章列表。', 'jio'),
|
||||
'remind' => __('需已有文章与分类内容。', 'jio'),
|
||||
'sidebars' => [
|
||||
'home_top_content' => [
|
||||
['widget' => 'text_title', 'settings' => ['heading' => '最新知识内容', 'description' => '持续更新的课程、文章与资料']],
|
||||
@@ -37,9 +37,9 @@ final class WidgetTransfer {
|
||||
],
|
||||
],
|
||||
'links_navigation' => [
|
||||
'title' => __('链接导航', 'aksrt'),
|
||||
'desc' => __('搜索、分类入口与链接列表。', 'aksrt'),
|
||||
'remind' => __('需已在链接管理中添加链接。', 'aksrt'),
|
||||
'title' => __('链接导航', 'jio'),
|
||||
'desc' => __('搜索、分类入口与链接列表。', 'jio'),
|
||||
'remind' => __('需已在链接管理中添加链接。', 'jio'),
|
||||
'sidebars' => [
|
||||
'home_top_content' => [
|
||||
['widget' => 'icon_cover_cards', 'settings' => ['title' => '常用入口']],
|
||||
@@ -49,9 +49,9 @@ final class WidgetTransfer {
|
||||
],
|
||||
],
|
||||
'article_sidebar' => [
|
||||
'title' => __('文章侧栏', 'aksrt'),
|
||||
'desc' => __('目录、作者、付费授权与热榜文章。', 'aksrt'),
|
||||
'remind' => __('只能导入到文章页侧边栏。', 'aksrt'),
|
||||
'title' => __('文章侧栏', 'jio'),
|
||||
'desc' => __('目录、作者、付费授权与热榜文章。', 'jio'),
|
||||
'remind' => __('只能导入到文章页侧边栏。', 'jio'),
|
||||
'sidebars' => [
|
||||
'single_sidebar' => [
|
||||
['widget' => 'posts_toc', 'settings' => ['title' => '文章目录']],
|
||||
@@ -62,9 +62,9 @@ final class WidgetTransfer {
|
||||
],
|
||||
],
|
||||
'knowledge_landing' => [
|
||||
'title' => __('知识付费落地页', 'aksrt'),
|
||||
'desc' => __('亮点、方案、评价与常见问题。', 'aksrt'),
|
||||
'remind' => __('适合放置在全宽度或主内容容器中。', 'aksrt'),
|
||||
'title' => __('知识付费落地页', 'jio'),
|
||||
'desc' => __('亮点、方案、评价与常见问题。', 'jio'),
|
||||
'remind' => __('适合放置在全宽度或主内容容器中。', 'jio'),
|
||||
'sidebars' => [
|
||||
'home_top_content' => [
|
||||
['widget' => 'feature_intro', 'settings' => ['title' => '系统化学习路径']],
|
||||
@@ -81,7 +81,7 @@ final class WidgetTransfer {
|
||||
public static function template_payload(string $template): array {
|
||||
$templates = self::templates();
|
||||
if (!isset($templates[$template])) {
|
||||
throw new \InvalidArgumentException(__('未知的小工具模板。', 'aksrt'));
|
||||
throw new \InvalidArgumentException(__('未知的小工具模板。', 'jio'));
|
||||
}
|
||||
return [
|
||||
'format' => self::FORMAT,
|
||||
@@ -121,7 +121,7 @@ final class WidgetTransfer {
|
||||
/** @return array{sidebars:int,widgets:int} */
|
||||
public static function import(array $payload, string $mode = 'append', string $target_sidebar = ''): array {
|
||||
if (($payload['format'] ?? '') !== self::FORMAT || !isset($payload['sidebars']) || !is_array($payload['sidebars'])) {
|
||||
throw new \InvalidArgumentException(__('仅接受 aksrt.widgets.v1 格式。', 'aksrt'));
|
||||
throw new \InvalidArgumentException(__('仅接受 jio.widgets.v1 格式。', 'jio'));
|
||||
}
|
||||
$mode = $mode === 'replace' ? 'replace' : 'append';
|
||||
$registered = array_keys($GLOBALS['wp_registered_sidebars'] ?? []);
|
||||
@@ -180,7 +180,7 @@ final class WidgetTransfer {
|
||||
}
|
||||
|
||||
private static function export_widget(string $widget_id): ?array {
|
||||
if (!preg_match('/^(aksrt_widget_[a-z0-9_]+)-([1-9][0-9]*)$/', $widget_id, $matches)) {
|
||||
if (!preg_match('/^(jio_widget_[a-z0-9_]+)-([1-9][0-9]*)$/', $widget_id, $matches)) {
|
||||
return null;
|
||||
}
|
||||
$definition = WidgetRegistry::get_by_id_base($matches[1]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
namespace Jio\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -26,8 +26,8 @@ final class WidgetVisibility {
|
||||
public static function device_class(array $instance): string {
|
||||
$type = (string) ($instance['show_type'] ?? 'all');
|
||||
if ($type === 'only_pc') {
|
||||
return 'aksrt-widget--only-pc';
|
||||
return 'jio-widget--only-pc';
|
||||
}
|
||||
return $type === 'only_sm' ? 'aksrt-widget--only-mobile' : '';
|
||||
return $type === 'only_sm' ? 'jio-widget--only-mobile' : '';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user