Files
wordpress-theme-aksrt/src/Admin/Schema/GlobalSchema.php
T
kate522 cf39e72126 feat(extensions): align Baidu push with reference theme
与参考主题(zibll)1:1 对齐百度推送,并清掉存量双路与死代码:

- 新增普通/快速收录通道开关,快速收录走 &type=daily;自动推送 JS 与参考实现一致

- 分类法 saved_term 推送(可推送类型推导公开分类法,排除 post_format,aksrt_baidu_push_taxonomies 可过滤)

- 推送结果写入 meta 去重,成功后不重复提交;编辑页 Metabox 展示结果并提供「重新提交」(nonce 校验后强制推送)

- 配置面收敛到扩展页单一 canonical 键:删除 SEO 页 seo_baidu_* 重复面与两处合并逻辑,不写迁移兜底

- 清理死代码:push_batch(零调用)及 batch_size、从不写入的 baidu_push_verified、零消费的熊掌号 xzh_* 七键;baidu_push_log_enabled 接入 log()

新增 PHP harness 驱动真实逻辑(通道/去重/重试/重新提交/术语/面板渲染)+ 参考主题契约测试;tests/admin 与 tests/widget-system 全量通过。
2026-10-13 21:01:03 +08:00

467 lines
41 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin\Schema;
defined('ABSPATH') || exit;
class GlobalSchema {
public static function build(): array {
return [
'domain' => 'global',
'title' => '全局&功能',
'sections' => [
'common' => [
'key' => 'common',
'title' => '常用功能',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'performance', 'title' => '图像异步懒加载', 'fields' => [
['key' => 'lazy_posts_thumb', 'label' => '文章缩略图懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_avatar', 'label' => '头像懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_posts_content', 'label' => '文章内容图片懒加载', 'type' => 'switch', 'default' => false],
['key' => 'lazy_comment', 'label' => '评论内容图片懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_sider', 'label' => '幻灯片图片懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_cover', 'label' => '封面图片懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_other', 'label' => '其它图片懒加载', 'type' => 'switch', 'default' => true],
['key' => 'lazy_animation', 'label' => '懒加载动画效果', 'type' => 'select', 'default' => 'blur', 'options' => [
['label' => '淡出淡入', 'value' => 'fade'],
['label' => '高斯模糊', 'value' => 'blur'],
['label' => '放大缩小', 'value' => 'scale'],
]],
['key' => 'thumbnail', 'label' => '懒加载预载图', 'type' => 'media', 'default' => get_template_directory_uri() . '/assets/img/thumbnail.svg'],
]],
['key' => 'filing', 'title' => '备案信息', 'fields' => [
['key' => 'icp_filing', 'label' => 'ICP 备案号', 'type' => 'input', 'default' => ''],
['key' => 'police_filing', 'label' => '公安备案号', 'type' => 'input', 'default' => ''],
['key' => 'footer_text', 'label' => '页脚附加文字', 'type' => 'input', 'default' => ''],
]],
],
],
'logo' => [
'key' => 'logo',
'title' => 'LOGO图像',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'logo', 'title' => 'Logo 设置', 'fields' => [
['key' => 'site_logo', 'label' => '站点 Logo', 'type' => 'media', 'default' => ''],
['key' => 'site_logo_dark', 'label' => '暗色模式 Logo', 'type' => 'media', 'default' => ''],
['key' => 'logo_width', 'label' => 'Logo 宽度', 'type' => 'number', 'default' => 150, 'min' => 50, 'max' => 400],
['key' => 'logo_text', 'label' => 'Logo 文字', 'type' => 'input', 'default' => ''],
]],
['key' => 'favicon', 'title' => '站点图标', 'fields' => [
['key' => 'site_favicon', 'label' => '浏览器图标', 'type' => 'media', 'default' => ''],
['key' => 'site_icon', 'label' => '移动端图标', 'type' => 'media', 'default' => ''],
]],
],
],
'seo' => [
'key' => 'seo',
'title' => 'SEO优化',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => 'SEO基础', 'fields' => [
['key' => 'seo_enabled', 'label' => '启用核心SEO优化', 'type' => 'switch', 'default' => true, 'help' => '关闭后主题不再输出 SEO head 标签。'],
['key' => 'seo_ai_enabled', 'label' => 'AI生成SEO内容', 'type' => 'switch', 'default' => false, 'help' => '开启后文章/分类独立 SEO 框显示 AI 生成按钮;需先在 WordPress 配置 AI Connectors。', 'dependsOn' => ['key' => 'seo_enabled', 'value' => true]],
['key' => 'seo_connector', 'label' => 'SEO连接符', 'type' => 'input', 'default' => '-', 'help' => 'AI 生成标题时用于追加站点名。'],
['key' => 'seo_title', 'label' => 'SEO标题(title)', 'type' => 'textarea', 'default' => ''],
['key' => 'seo_keywords', 'label' => 'SEO关键字(keywords)', 'type' => 'textarea', 'default' => ''],
['key' => 'seo_description', 'label' => 'SEO描述(description)', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'ai-seo', 'title' => 'AI SEO 提示词', 'fields' => [
['key' => 'ai_seo_title_prompt', 'label' => '标题提示词', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'seo_ai_enabled', 'value' => true], 'help' => '留空使用内置 原主题风格默认提示词。'],
['key' => 'ai_seo_keywords_prompt', 'label' => '关键词提示词', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'seo_ai_enabled', 'value' => true], 'help' => '留空使用内置默认。'],
['key' => 'ai_seo_description_prompt', 'label' => '描述提示词', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'seo_ai_enabled', 'value' => true], 'help' => '留空使用内置默认。'],
]],
['key' => 'image', 'title' => '图片SEO', 'fields' => [
['key' => 'seo_image_optimize', 'label' => '搜索引擎图片展示优化', 'type' => 'switch', 'default' => true],
['key' => 'seo_image_default', 'label' => '默认图像', 'type' => 'media', 'default' => ''],
['key' => 'seo_image_always_default', 'label' => '固定使用默认图像', 'type' => 'switch', 'default' => false],
['key' => 'seo_auto_alt', 'label' => '文章图片自动添加alt', 'type' => 'switch', 'default' => true],
]],
['key' => 'redirect', 'title' => '外链重定向', 'fields' => [
['key' => 'seo_go_link', 'label' => '启用外链重定向', 'type' => 'switch', 'default' => true],
['key' => 'seo_go_link_nonce', 'label' => '外链重定向鉴权', 'type' => 'switch', 'default' => true],
['key' => 'seo_go_link_post', 'label' => '文章内容外链重定向', 'type' => 'switch', 'default' => true],
['key' => 'seo_go_link_exclude', 'label' => '排除域名', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'advanced', 'title' => '高级SEO', 'fields' => [
['key' => 'seo_no_category', 'label' => '分类URL去除category', 'type' => 'switch', 'default' => false],
['key' => 'seo_jsonld', 'label' => '启用JSON-LD', 'type' => 'switch', 'default' => true],
['key' => 'seo_jsonld_single', 'label' => '文章页JSON-LD', 'type' => 'switch', 'default' => true],
['key' => 'seo_jsonld_page', 'label' => '页面JSON-LD', 'type' => 'switch', 'default' => true],
]],
],
],
'layout' => [
'key' => 'layout',
'title' => '显示&布局',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'color', 'title' => '色彩方案', 'fields' => [
['key' => 'theme_mode', 'label' => '默认主题模式', 'type' => 'radio', 'default' => 'time-auto', 'options' => [
['label' => '浅色', 'value' => 'white-theme'],
['label' => '深色', 'value' => 'dark-theme'],
['label' => '跟随系统', 'value' => 'time-auto'],
]],
['key' => 'theme_mode_button', 'label' => '主题切换按钮位置', 'type' => 'checkbox', 'default' => ['pc_nav', 'm_menu'], 'options' => [
['label' => 'PC 顶部导航', 'value' => 'pc_nav'],
['label' => '移动端菜单', 'value' => 'm_menu'],
]],
['key' => 'theme_skin', 'label' => '预设主题色', 'type' => 'palette', 'default' => 'f04494', 'options' => [
['label' => '玫红', 'value' => 'ff1856'],
['label' => '粉色', 'value' => 'f04494'],
['label' => '紫色', 'value' => 'ae53f3'],
['label' => '靛蓝', 'value' => '627bf5'],
['label' => '天蓝', 'value' => '00a2e3'],
['label' => '青绿', 'value' => '16b597'],
['label' => '翠绿', 'value' => '36af18'],
['label' => '黄绿', 'value' => '8fb107'],
['label' => '棕金', 'value' => 'b18c07'],
['label' => '橘橙', 'value' => 'e06711'],
['label' => '朱红', 'value' => 'f74735'],
]],
['key' => 'primary_color', 'label' => '自定义主题色', 'type' => 'color', 'default' => '#f04494'],
['key' => 'dark_primary_color', 'label' => '暗色模式主题色', 'type' => 'color', 'default' => '#f04494'],
['key' => 'border_radius', 'label' => '全局圆角', 'type' => 'slider', 'default' => 8, 'min' => 0, 'max' => 20],
['key' => 'theme_main_radius', 'label' => '卡片圆角 (px)', 'type' => 'number', 'default' => 12, 'min' => 0, 'max' => 30, 'help' => '独立卡片圆角,不填则使用全局圆角 +4'],
['key' => 'close_backdrop', 'label' => '关闭毛玻璃效果', 'type' => 'switch', 'default' => false],
]],
['key' => 'layout', 'title' => '布局设置', 'fields' => [
// 0(全宽)与 1200–2200 与设置页下拉选项、Settings::container_max_width() 归一化区间一致;
// 上限低于 UI 可选项会让后台保存被校验拒绝,页面宽度卡在旧值。
['key' => 'container_max_width', 'label' => '内容最大宽度', 'type' => 'number', 'default' => 1200, 'min' => 0, 'max' => 2200],
['key' => 'sidebar_enabled', 'label' => '开启侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_position', 'label' => '侧边栏位置', 'type' => 'radio', 'default' => 'right', 'options' => [
['label' => '左侧', 'value' => 'left'],
['label' => '右侧', 'value' => 'right'],
]],
['key' => 'sidebar_width', 'label' => '侧边栏宽度', 'type' => 'number', 'default' => 300, 'min' => 200, 'max' => 400],
['key' => 'sidebar_home_enabled', 'label' => '首页侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_category_enabled', 'label' => '分类页侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_tag_enabled', 'label' => '标签页侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_single_enabled', 'label' => '文章页侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_page_enabled', 'label' => '页面侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_search_enabled', 'label' => '搜索页侧边栏', 'type' => 'switch', 'default' => true],
]],
['key' => 'typography', 'title' => '字体设置', 'fields' => [
['key' => 'font_family', 'label' => '正文字体', 'type' => 'select', 'default' => 'system', 'options' => [
['label' => '系统默认', 'value' => 'system'],
['label' => '思源黑体', 'value' => 'noto-sans-sc'],
['label' => '思源宋体', 'value' => 'noto-serif-sc'],
['label' => '自定义', 'value' => 'custom'],
]],
]],
['key' => 'performance', 'title' => '性能优化', 'fields' => [
['key' => 'qj_loading', 'label' => '全站加载动画', 'type' => 'switch', 'default' => false],
['key' => 'qj_dh_xs', 'label' => '加载动画样式', 'type' => 'select', 'default' => 'no1', 'dependsOn' => ['key' => 'qj_loading', 'value' => true], 'options' => [
['label' => '样式 1', 'value' => 'no1'],
['label' => '样式 2', 'value' => 'no2'],
['label' => '样式 3', 'value' => 'no3'],
['label' => '样式 4', 'value' => 'no4'],
['label' => '样式 5', 'value' => 'no5'],
['label' => '样式 6', 'value' => 'no6'],
['label' => '样式 7', 'value' => 'no7'],
['label' => '样式 8', 'value' => 'no8'],
['label' => '样式 9', 'value' => 'no9'],
['label' => '样式 10', 'value' => 'no10'],
]],
]],
],
],
'code-highlight' => [
'key' => 'code-highlight',
'title' => '代码高亮',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '代码高亮设置', 'fields' => [
['key' => 'highlight_kg', 'label' => '代码高亮开关', 'type' => 'switch', 'default' => true],
['key' => 'highlight_hh', 'label' => '显示行号', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'highlight_kg', 'value' => true]],
['key' => 'highlight_btn', 'label' => '显示扩展按钮', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'highlight_kg', 'value' => true]],
['key' => 'highlight_maxheight', 'label' => '最大高度(px,0=不限)', 'type' => 'number', 'default' => 400, 'min' => 0, 'max' => 2000, 'dependsOn' => ['key' => 'highlight_kg', 'value' => true]],
]],
['key' => 'theme', 'title' => '主题设置', 'fields' => [
['key' => 'highlight_zt', 'label' => '日间默认主题', 'type' => 'select', 'default' => 'enlighter', 'dependsOn' => ['key' => 'highlight_kg', 'value' => true], 'options' => [
['label' => '浅色: Enlighter', 'value' => 'enlighter'],
['label' => '浅色: Bootstrap', 'value' => 'bootstrap4'],
['label' => '浅色: Classic', 'value' => 'classic'],
['label' => '浅色: Beyond', 'value' => 'beyond'],
['label' => '浅色: Mowtwo', 'value' => 'mowtwo'],
['label' => '浅色: Eclipse', 'value' => 'eclipse'],
['label' => '浅色: Droide', 'value' => 'droide'],
['label' => '浅色: Minimal', 'value' => 'minimal'],
['label' => '浅色: Rowhammer', 'value' => 'rowhammer'],
['label' => '浅色: Godzilla', 'value' => 'godzilla'],
['label' => '深色: Dracula', 'value' => 'dracula'],
['label' => '深色: Atomic', 'value' => 'atomic'],
['label' => '深色: Monokai', 'value' => 'monokai'],
]],
['key' => 'highlight_dark_zt', 'label' => '暗色默认主题', 'type' => 'select', 'default' => 'monokai', 'dependsOn' => ['key' => 'highlight_kg', 'value' => true], 'options' => [
['label' => '深色: Dracula', 'value' => 'dracula'],
['label' => '深色: Atomic', 'value' => 'atomic'],
['label' => '深色: Monokai', 'value' => 'monokai'],
['label' => '浅色: Enlighter', 'value' => 'enlighter'],
['label' => '浅色: Bootstrap', 'value' => 'bootstrap4'],
]],
]],
],
],
'system-notice' => [
'key' => 'system-notice',
'title' => '系统公告',
'version' => '2.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '公告设置', 'fields' => [
['key' => 'system_notice_enabled', 'label' => '启用系统公告', 'type' => 'switch', 'default' => true],
['key' => 'system_notice_policy', 'label' => '显示对象', 'type' => 'select', 'default' => '', 'options' => [
['label' => '所有访客', 'value' => ''],
['label' => '仅登录用户', 'value' => 'signin'],
['label' => '仅 VIP 会员', 'value' => 'vip'],
['label' => '仅非 VIP', 'value' => 'free'],
['label' => '仅认证用户', 'value' => 'auth'],
]],
['key' => 'system_notice_title', 'label' => '公告标题', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_content', 'label' => '公告内容', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'buttons', 'title' => '按钮组(留空则不显示)', 'fields' => [
['key' => 'system_notice_btn1_text', 'label' => '按钮 1 文案', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn1_link', 'label' => '按钮 1 链接', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn1_color', 'label' => '按钮 1 颜色', 'type' => 'select', 'default' => 'primary', 'options' => [
['label' => '主题色', 'value' => 'primary'],
['label' => '成功绿', 'value' => 'success'],
['label' => '警告橙', 'value' => 'warning'],
['label' => '危险红', 'value' => 'danger'],
['label' => '信息蓝', 'value' => 'info'],
['label' => '深紫', 'value' => 'purple'],
['label' => '深灰', 'value' => 'dark'],
]],
['key' => 'system_notice_btn2_text', 'label' => '按钮 2 文案', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn2_link', 'label' => '按钮 2 链接', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn2_color', 'label' => '按钮 2 颜色', 'type' => 'select', 'default' => 'primary', 'options' => [
['label' => '主题色', 'value' => 'primary'],
['label' => '成功绿', 'value' => 'success'],
['label' => '警告橙', 'value' => 'warning'],
['label' => '危险红', 'value' => 'danger'],
['label' => '信息蓝', 'value' => 'info'],
['label' => '深紫', 'value' => 'purple'],
['label' => '深灰', 'value' => 'dark'],
]],
['key' => 'system_notice_btn3_text', 'label' => '按钮 3 文案', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn3_link', 'label' => '按钮 3 链接', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn3_color', 'label' => '按钮 3 颜色', 'type' => 'select', 'default' => 'primary', 'options' => [
['label' => '主题色', 'value' => 'primary'],
['label' => '成功绿', 'value' => 'success'],
['label' => '警告橙', 'value' => 'warning'],
['label' => '危险红', 'value' => 'danger'],
['label' => '信息蓝', 'value' => 'info'],
['label' => '深紫', 'value' => 'purple'],
['label' => '深灰', 'value' => 'dark'],
]],
['key' => 'system_notice_btn4_text', 'label' => '按钮 4 文案', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn4_link', 'label' => '按钮 4 链接', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_btn4_color', 'label' => '按钮 4 颜色', 'type' => 'select', 'default' => 'primary', 'options' => [
['label' => '主题色', 'value' => 'primary'],
['label' => '成功绿', 'value' => 'success'],
['label' => '警告橙', 'value' => 'warning'],
['label' => '危险红', 'value' => 'danger'],
['label' => '信息蓝', 'value' => 'info'],
['label' => '深紫', 'value' => 'purple'],
['label' => '深灰', 'value' => 'dark'],
]],
]],
['key' => 'style', 'title' => '样式设置', 'fields' => [
['key' => 'system_notice_size', 'label' => '弹窗尺寸', 'type' => 'select', 'default' => '', 'options' => [
['label' => '默认', 'value' => ''],
['label' => '迷你', 'value' => 'modal-mini'],
['label' => '小号', 'value' => 'modal-sm'],
['label' => '大号', 'value' => 'modal-lg'],
]],
['key' => 'system_notice_radius', 'label' => '按钮圆角', 'type' => 'switch', 'default' => false, 'help' => '开启后弹窗按钮使用圆角样式'],
['key' => 'system_notice_class', 'label' => '公告样式类', 'type' => 'input', 'default' => ''],
['key' => 'system_notice_title_icon', 'label' => '标题图标', 'type' => 'icon', 'default' => ''],
['key' => 'system_notice_title_class', 'label' => '标题背景配色', 'type' => 'select', 'default' => '', 'options' => [
['label' => '无', 'value' => ''],
['label' => '炫彩黄', 'value' => 'jb-yellow'],
['label' => '炫彩蓝', 'value' => 'jb-blue'],
['label' => '炫彩绿', 'value' => 'jb-green'],
['label' => '炫彩紫', 'value' => 'jb-purple'],
['label' => '炫彩红', 'value' => 'jb-red'],
['label' => '炫彩橙', 'value' => 'jb-orange'],
], 'help' => '弹窗标题区域的背景配色方案'],
['key' => 'system_notice_title_style', 'label' => '标题样式', 'type' => 'input', 'default' => ''],
]],
['key' => 'expire', 'title' => '过期设置', 'fields' => [
['key' => 'system_notice_expires', 'label' => '弹窗周期(小时)', 'type' => 'number', 'default' => 24, 'min' => 0, 'max' => 720, 'help' => '0 表示永不过期'],
]],
],
],
'search' => [
'key' => 'search',
'title' => '搜索功能',
'version' => '2.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '搜索基础', 'fields' => [
['key' => 'search_placeholder', 'label' => '搜索框提示文字', 'type' => 'input', 'default' => '开启精彩搜索'],
]],
['key' => 'content-types', 'title' => '搜索内容类型', 'fields' => [
['key' => 'search_type', 'label' => '显示切换搜索类型按钮', 'type' => 'switch', 'default' => true],
['key' => 'search_type_in', 'label' => '默认搜索类型', 'type' => 'radio', 'default' => 'post', 'options' => [
['label' => '文章', 'value' => 'post'],
['label' => '用户', 'value' => 'user'],
]],
]],
['key' => 'features', 'title' => '搜索功能', 'fields' => [
['key' => 'search_history', 'label' => '搜索历史', 'type' => 'switch', 'default' => true],
['key' => 'search_popular_key', 'label' => '热门搜索', 'type' => 'switch', 'default' => true],
['key' => '404_search_s', 'label' => '在 404 页面显示搜索功能', 'type' => 'switch', 'default' => true],
['key' => 'search_posts', 'label' => '搜索框热门文章', 'type' => 'switch', 'default' => true, 'help' => '在搜索面板中显示热门文章列表'],
['key' => 'search_no_page', 'label' => '排除页面', 'type' => 'switch', 'default' => true, 'help' => '搜索结果中排除页面(仅显示文章)'],
['key' => 'search_exclude_cats', 'label' => '排除分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'help' => '搜索结果中排除的文章分类'],
['key' => 'search_custom_key_s', 'label' => '自定义匹配范围', 'type' => 'switch', 'default' => true, 'help' => '启用后可配置搜索匹配字段范围(标题/内容/分类/标签等)'],
['key' => 'search_custom_key', 'label' => '匹配字段', 'type' => 'checkbox', 'default' => ['title', 'content', 'excerpt', 'category', 'post_tag'], 'options' => [
['label' => '标题', 'value' => 'title'], ['label' => '内容', 'value' => 'content'], ['label' => '简介', 'value' => 'excerpt'],
['label' => '分类', 'value' => 'category'], ['label' => '标签', 'value' => 'post_tag'],
['label' => '评论', 'value' => 'coment'], ['label' => '作者昵称', 'value' => 'user'],
]],
['key' => 'search_facets', 'label' => '搜索筛选', 'type' => 'fieldset', 'sanitize_type' => 'array', 'default' => [], 'dependsOn' => ['key' => 'search_ms_s', 'value' => false], 'help' => '搜索结果中显示的筛选列表;启用 Meilisearch 后由搜索引擎生成关联筛选。', 'fields' => [
['key' => 'category', 'label' => '[文章] 分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => []],
['key' => 'post_tag', 'label' => '[文章] 标签', 'type' => 'taxonomy_select', 'taxonomy' => 'post_tag', 'multiple' => true, 'default' => []],
]],
]],
['key' => 'category-search', 'title' => '分类搜索', 'fields' => [
['key' => 'search_cat', 'label' => '启用分类搜索', 'type' => 'switch', 'default' => true, 'help' => '在搜索框旁显示分类选择器'],
['key' => 'search_cat_in', 'label' => '默认分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => false, 'default' => '', 'help' => '留空为全部分类'],
['key' => 'search_more_cat_obj', 'label' => '允许选择的更多分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => []],
]],
['key' => 'popular', 'title' => '热门搜索', 'fields' => [
['key' => 'search_popular_title', 'label' => '标题', 'type' => 'input', 'default' => '热门搜索'],
['key' => 'search_popular_key_num', 'label' => '显示数量', 'type' => 'number', 'default' => 20, 'min' => 10, 'max' => 50, 'step' => 2],
['key' => 'search_popular_sticky', 'label' => '置顶关键词', 'type' => 'input', 'default' => '', 'help' => '使用逗号分隔;可追加 &type=user 指定搜索类型'],
]],
['key' => 'meilisearch', 'title' => 'Meilisearch 智能搜索', 'fields' => [
['key' => 'search_ms_s', 'label' => '启用 Meilisearch', 'type' => 'switch', 'default' => false],
['key' => 'search_ms_opt', 'label' => 'Meilisearch 参数', 'type' => 'fieldset', 'sanitize_type' => 'array', 'default' => [
'api_url' => 'http://127.0.0.1:7700', 'api_key' => '', 'index_prefix' => 'aksrt',
'synonyms' => [['key' => 'wordpress', 'val' => 'wp,wordp,wordpre']],
], 'dependsOn' => ['key' => 'search_ms_s', 'value' => true], 'fields' => [
['key' => 'api_url', 'label' => 'API 地址', 'type' => 'input', 'default' => 'http://127.0.0.1:7700'],
['key' => 'api_key', 'label' => 'API 密钥', 'type' => 'input', 'default' => ''],
['key' => 'index_prefix', 'label' => '索引前缀', 'type' => 'input', 'default' => 'aksrt'],
['key' => 'synonyms', 'label' => '同义词', 'type' => 'repeater', 'default' => [['key' => 'wordpress', 'val' => 'wp,wordp,wordpre']], 'addText' => '添加同义词', 'fields' => [
['key' => 'key', 'label' => '关键词', 'type' => 'input', 'default' => ''],
['key' => 'val', 'label' => '同义词', 'type' => 'textarea', 'default' => ''],
]],
]],
]],
],
],
'share' => [
'key' => 'share',
'title' => '社交分享',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [[
'key' => 'share',
'title' => '社交分享',
'fields' => [
['key' => 'share_s', 'label' => '文章分享功能', 'type' => 'switcher', 'default' => true, 'help' => '关闭后,在文章页面将不显示分享按钮。'],
['key' => 'share_items', 'label' => '分享平台', 'type' => 'custom', 'renderer' => 'sorter', 'sanitize_type' => 'array', 'default' => [
'enabled' => ['qzone' => 'QQ空间', 'weibo' => '微博', 'qq' => 'QQ好友', 'poster' => '海报分享', 'copy' => '复制链接'],
'disabled' => ['facebook' => 'Facebook', 'twitter' => 'X', 'telegram' => 'Telegram', 'whatsapp' => 'WhatsApp', 'linkedin' => 'LinkedIn', 'reddit' => 'Reddit', 'line' => 'LINE', 'vk' => 'VK', 'email' => '邮件'],
], 'options' => [
['label' => 'QQ空间', 'value' => 'qzone'], ['label' => '微博', 'value' => 'weibo'], ['label' => 'QQ好友', 'value' => 'qq'],
['label' => 'Facebook', 'value' => 'facebook'], ['label' => 'X', 'value' => 'twitter'], ['label' => 'Telegram', 'value' => 'telegram'],
['label' => 'WhatsApp', 'value' => 'whatsapp'], ['label' => 'LinkedIn', 'value' => 'linkedin'], ['label' => 'Reddit', 'value' => 'reddit'],
['label' => 'LINE', 'value' => 'line'], ['label' => 'VK', 'value' => 'vk'], ['label' => '邮件', 'value' => 'email'],
['label' => '海报分享', 'value' => 'poster'], ['label' => '复制链接', 'value' => 'copy'],
], 'description' => '左侧启用并拖拽排序,右侧为未启用项(同时启用的数量不建议超过 6 个)。若开启海外平台,用户网络必须能正常访问对应服务。'],
['key' => 'wechat_share_s', 'label' => '微信分享有图', 'type' => 'switcher', 'default' => false, 'help' => '使用微信 JSAPI 在微信 App 内分享。'],
['key' => 'wechat_share_hint', 'label' => '', 'type' => 'content', 'ui_only' => true, 'dependsOn' => ['key' => 'wechat_share_s', 'value' => true], 'content' => '<p><strong>微信分享有图配置</strong></p><p>此功能用于用户从公众号进入页面后调用微信默认分享能力,并不会额外显示分享按钮。请在公众号后台将当前站点域名配置为 JS 接口安全域名。</p><p><a href="https://mp.weixin.qq.com/" target="_blank" rel="noopener noreferrer">前往微信公众平台</a></p>'],
['key' => 'wechat_share_option', 'label' => '微信分享有图配置', 'type' => 'fieldset', 'default' => ['appid' => '', 'app_secret' => '', 'only_logo' => false], 'dependsOn' => ['key' => 'wechat_share_s', 'value' => true], 'fields' => [
['key' => 'appid', 'label' => 'AppID', 'type' => 'input', 'default' => ''],
['key' => 'app_secret', 'label' => 'AppSecret', 'type' => 'input', 'default' => ''],
['key' => 'only_logo', 'label' => '全部使用网站图标', 'type' => 'switcher', 'default' => false, 'help' => '默认自动使用页面封面图;开启后所有页面均使用网站图标。图片启用防盗链时建议开启。'],
]],
['key' => 'share_img', 'label' => '生成海报分享', 'type' => 'switcher', 'default' => true, 'help' => '网站图片使用 OSS 等云存储时,请先配置允许本站 Canvas 读取图片的跨域规则。'],
['key' => 'share_img_warning', 'label' => '', 'type' => 'notice', 'ui_only' => true, 'alertType' => 'warning', 'content' => '海报图片加载失败时,请检查图片 CDN/OSS 的跨域响应头。', 'dependsOn' => ['key' => 'share_img', 'value' => true]],
['key' => 'share_img_compatible_s', 'label' => '海报分享兼容模式', 'type' => 'switcher', 'default' => false, 'dependsOn' => ['key' => 'share_img', 'value' => true], 'help' => '通过服务端代理读取海报图片,改善跨域兼容性;会增加服务器图片处理开销。'],
['key' => 'share_img_byimg', 'label' => '海报分享默认图片', 'type' => 'media', 'default' => get_template_directory_uri() . '/assets/img/slider-bg.jpg', 'dependsOn' => ['key' => 'share_img', 'value' => true], 'help' => '文章没有图片时使用,建议尺寸 800×500。'],
['key' => 'share_logo', 'label' => '海报分享 LOGO', 'type' => 'media', 'default' => get_template_directory_uri() . '/assets/img/logo.png', 'dependsOn' => ['key' => 'share_img', 'value' => true], 'help' => '显示在海报底部,建议尺寸 300×100、大小 50KB 以内。'],
['key' => 'share_desc', 'label' => '海报分享底部文案', 'type' => 'input', 'default' => '扫一扫 立即查看', 'dependsOn' => ['key' => 'share_img', 'value' => true]],
],
]],
],
'email' => \AKSRT\Settings\MailTemplates::build_schema(),
'custom-code' => [
'key' => 'custom-code',
'title' => '自定义代码',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'css', 'title' => '自定义 CSS', 'fields' => [
['key' => 'custom_css', 'label' => '自定义 CSS', 'type' => 'code', 'language' => 'css', 'default' => ''],
]],
['key' => 'code', 'title' => '头部 & 底部代码', 'fields' => [
['key' => 'head_code', 'label' => '头部 HTML 代码', 'type' => 'code', 'default' => '', 'help' => '在 <head> 中输出,支持 meta/link/style/script 等任意 HTML'],
['key' => 'foot_code', 'label' => '底部 HTML 代码', 'type' => 'code', 'default' => '', 'help' => '在 </body> 前输出,支持任意 HTML'],
]],
['key' => 'stats', 'title' => '统计代码', 'fields' => [
['key' => 'trackcode', 'label' => '统计代码', 'type' => 'code', 'default' => '', 'help' => '百度统计/GA/CNZZ/51la 等,自动在 head 中输出'],
]],
],
],
'i18n' => [
'key' => 'i18n',
'title' => '多语言翻译',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '基础配置', 'fields' => [
['key' => 'i18n_enabled', 'label' => '启用多语言', 'type' => 'switch', 'default' => false],
['key' => 'i18n_default_lang', 'label' => '默认语言', 'type' => 'select', 'default' => 'zh-CN', 'options' => [
['label' => '简体中文', 'value' => 'zh-CN'],
['label' => 'English', 'value' => 'en'],
['label' => '繁體中文', 'value' => 'zh-TW'],
['label' => '日本語', 'value' => 'ja'],
['label' => '한국어', 'value' => 'ko'],
['label' => 'Français', 'value' => 'fr'],
['label' => 'Deutsch', 'value' => 'de'],
['label' => 'Español', 'value' => 'es'],
['label' => 'Русский', 'value' => 'ru'],
]],
['key' => 'i18n_auto_detect', 'label' => '自动检测浏览器语言', 'type' => 'switch', 'default' => true, 'help' => '基于浏览器 Accept-Language 自动切换(AKSRT 方案,区别于 legacy IP 定位方案)'],
]],
['key' => 'languages', 'title' => '语言管理', 'fields' => [
['key' => 'i18n_available_langs', 'label' => '可用语言列表', 'type' => 'textarea', 'default' => "zh-CN|简体中文\nen|English\nzh-TW|繁體中文\nja|日本語\nko|한국어\nfr|Français\nde|Deutsch\nes|Español\nru|Русский", 'help' => '每行一个语言,格式:代码|名称(9 种内置语言)'],
['key' => 'i18n_nomenclature', 'label' => '自定义术语', 'type' => 'code', 'default' => '', 'help' => 'JSON 格式自定义翻译术语(key => 翻译),对齐 legacy nomenclature'],
]],
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'i18n_switcher_position', 'label' => '语言切换器位置', 'type' => 'radio', 'default' => 'footer', 'options' => [
['label' => '导航栏', 'value' => 'header'],
['label' => '页脚', 'value' => 'footer'],
['label' => '导航栏+页脚', 'value' => 'both'],
['label' => '隐藏', 'value' => 'none'],
]],
['key' => 'i18n_url_strategy', 'label' => 'URL 策略', 'type' => 'radio', 'default' => 'query', 'options' => [
['label' => '查询参数', 'value' => 'query'],
['label' => '路径前缀', 'value' => 'path'],
['label' => '子域名', 'value' => 'subdomain'],
]],
]],
],
],
],
];
}
}