Zibll 主线收口:统一 single 并清退 compat 资源路径

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kate522andClaude committed 2026-07-09 20:30:49 +08:00
1 parent 0a6f97af21
commit 09f1eec909
26 files changed
+158 -1325

No files matched your search

@@ -32,20 +32,6 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
'permission_callback' => [$this, 'check_permission'],
]);
// Docs page stats
register_rest_route(self::API_NAMESPACE, '/docs/stats', [
'methods' => 'GET',
'callback' => [$this, 'get_docs_stats'],
'permission_callback' => [$this, 'check_permission'],
]);
// Docs search (public, for frontend AJAX)
register_rest_route(self::API_NAMESPACE, '/docs/search', [
'methods' => 'GET',
'callback' => [$this, 'search_docs'],
'permission_callback' => '__return_true',
]);
// Extensions service status summary (aggregated)
register_rest_route(self::API_NAMESPACE, '/settings/extensions', [
'methods' => 'GET',
@@ -126,36 +112,11 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
}
public function get_docs_stats(): WP_REST_Response {
$nav_count = 0;
$special_count = 0;
$nav_query = new WP_Query([
'post_type' => 'page',
'post_status' => 'publish',
'meta_key' => '_wp_page_template',
'meta_value' => 'templates/pages/page-documentnav.php',
'posts_per_page' => 1,
'fields' => 'ids',
'no_found_rows' => false,
]);
$nav_count = (int) $nav_query->found_posts;
$special_query = new WP_Query([
'post_type' => 'page',
'post_status' => 'publish',
'meta_key' => '_wp_page_template',
'meta_value' => 'templates/pages/page-special.php',
'posts_per_page' => 1,
'fields' => 'ids',
'no_found_rows' => false,
]);
$special_count = (int) $special_query->found_posts;
return $this->success([
'data' => [
'total' => $nav_count + $special_count,
'nav_count' => $nav_count,
'special_count' => $special_count,
'total' => 0,
'nav_count' => 0,
'special_count' => 0,
],
]);
}
@@ -164,24 +125,10 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
* GET /docs/search — search document pages by keyword.
*/
public function search_docs(WP_REST_Request $request): WP_REST_Response {
$keyword = trim(sanitize_text_field((string) $request->get_param('keyword')));
$root_id = (int) $request->get_param('root_id');
$limit = max(1, min(50, (int) ($request->get_param('limit') ?: 20)));
if ($keyword === '') {
return $this->success(['data' => ['results' => [], 'total' => 0]]);
}
if (!class_exists('AKSRT_Docs_Presenter')) {
return $this->success(['data' => ['results' => [], 'total' => 0]]);
}
$results = AKSRT_Docs_Presenter::get_instance()->search_pages($keyword, $root_id, $limit);
return $this->success([
'data' => [
'results' => $results,
'total' => count($results),
'results' => [],
'total' => 0,
],
]);
}
@@ -439,13 +386,12 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
$services['push'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
// Docs Mode
$docs_en = !empty($settings['docs_mode_enabled']);
// Docs Mode (compat path is retired from rebuilt mainline)
$services['docs_mode'] = [
'enabled' => $docs_en,
'enabled' => false,
'provider' => 'builtin',
'configured' => $docs_en,
'available' => $docs_en,
'configured' => false,
'available' => false,
'verified' => true,
'transport' => 'builtin',
'missing_fields' => [],
@@ -9,7 +9,6 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
if ($request->get_method() === 'GET') {
$data = AKSRT_Settings::get_homepage_fixed_settings();
$data['homepage_modules'] = AKSRT_Settings::get_homepage_modules();
return rest_ensure_response([
'code' => 'success',
'data' => $data,
@@ -104,30 +103,6 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
$settings['homepage_tabs'] = $tabs;
}
if (isset($params['homepage_modules']) && is_array($params['homepage_modules'])) {
$modules = [];
$allowed_types = [
'hero', 'banner', 'category', 'tabs', 'ranking', 'recent',
'tag_cloud', 'friend_links', 'html', 'hotspot',
'category_recommend_cards', 'text_title', 'button_group',
'spacing', 'faq', 'data_grid', 'highlight_cards',
'partner_marquee', 'product_showcase',
];
foreach ($params['homepage_modules'] as $module) {
if (!is_array($module) || !in_array($module['type'] ?? '', $allowed_types, true)) {
continue;
}
$modules[] = [
'id' => sanitize_text_field($module['id'] ?? uniqid('mod_')),
'type' => sanitize_text_field($module['type']),
'config' => is_array($module['config'] ?? null) ? $module['config'] : [],
'enabled' => !empty($module['enabled']),
'title' => sanitize_text_field($module['title'] ?? ''),
];
}
$settings['homepage_modules'] = $modules;
}
$current = get_option($option_key, []);
if (!is_array($current)) {
$current = [];
@@ -141,7 +116,6 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
AKSRT_Settings::flush_settings_cache();
update_option('aksrt_homepage_schema_version', gmdate('Y-m-d'));
delete_transient('aksrt_homepage_cached_images');
delete_transient('aksrt_homepage_modules_cache');
do_action('aksrt_homepage_settings_changed');
return rest_ensure_response([
@@ -35,10 +35,8 @@ class AKSRT_Admin_Schema_Payment {
['key' => 'payment_paid_show_user', 'label' => '显示购买用户', 'type' => 'switch', 'default' => true],
['key' => 'payment_paid_show_paycount', 'label' => '显示购买次数', 'type' => 'switch', 'default' => true],
['key' => 'payment_paid_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
['label' => '文章模块上', 'value' => 'box_top'],
['label' => '内容顶', 'value' => 'top'],
['label' => '内容底', 'value' => 'bottom'],
['label' => '模块下', 'value' => 'box_bottom'],
['label' => '内容顶部(正文前)', 'value' => 'top'],
['label' => '内容底部(正文后)', 'value' => 'bottom'],
]],
]],
['key' => 'download', 'title' => '下载能力', 'fields' => [
@@ -294,10 +292,8 @@ class AKSRT_Admin_Schema_Payment {
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'payment_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
['key' => 'payment_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
['label' => '文章模块上', 'value' => 'box_top'],
['label' => '内容顶', 'value' => 'top'],
['label' => '内容底', 'value' => 'bottom'],
['label' => '模块下', 'value' => 'box_bottom'],
['label' => '内容顶部(正文前)', 'value' => 'top'],
['label' => '内容底部(正文后)', 'value' => 'bottom'],
]],
['key' => 'payment_free_logged_show', 'label' => '登录用户显示免费', 'type' => 'switch', 'default' => false],
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
+1 -14
View File
@@ -214,19 +214,6 @@ class AKSRT_Docs_Presenter {
* @return bool
*/
public function is_docs_page(int $page_id): bool {
if (!class_exists('AKSRT_Settings')) {
return false;
}
$settings = AKSRT_Settings::get_docs_mode_settings();
if (empty($settings['enabled'])) {
return false;
}
$template = get_page_template_slug($page_id);
return in_array($template, [
'templates/pages/page-documentnav.php',
'templates/pages/page-special.php',
], true);
return false;
}
}
+2 -30
View File
@@ -33,9 +33,9 @@ class AKSRT_Templates {
}
/**
* 主线页面模板:内容 / 用户 / 付费 / 论坛 / 商城主线可选模板。
* Selectable page templates shown in wp-admin for the rebuilt mainline.
*/
private function mainline_page_template_map(): array {
private function page_template_map(): array {
return [
'templates/pages/page-sign.php' => __('AKSRT - 登录/注册', 'aksrt'),
'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'),
@@ -55,34 +55,6 @@ class AKSRT_Templates {
];
}
/**
* 兼容保留页面模板:非 Zibll 主线能力(文档模式、下载中心、专题、消息、投稿)。
*
* 这些模板文件与已分配它们的历史页面继续正常渲染(见 load_page_template()),
* 只是默认不再出现在 wp-admin 页面模板下拉中,避免污染主线内容心智。
* 站点可通过 aksrt_show_compat_page_templates() 重新暴露下拉选项。
*/
private function compat_page_template_map(): array {
return [
'templates/pages/page-special.php' => __('AKSRT - 专题聚合(兼容)', 'aksrt'),
'templates/pages/page-documentnav.php' => __('AKSRT - 文档导航(兼容)', 'aksrt'),
'templates/pages/page-messages.php' => __('AKSRT - 消息中心(兼容)', 'aksrt'),
'templates/pages/page-download.php' => __('AKSRT - 下载中心(兼容)', 'aksrt'),
'templates/pages/page-submit.php' => __('AKSRT - 前台投稿(兼容)', 'aksrt'),
];
}
private function page_template_map(): array {
$map = $this->mainline_page_template_map();
// 兼容页面模板默认隐藏出下拉;仅在站点显式开启时暴露。
if (function_exists('aksrt_show_compat_page_templates') && aksrt_show_compat_page_templates()) {
$map = array_merge($map, $this->compat_page_template_map());
}
return $map;
}
/**
* Register selectable page templates in wp-admin.
*/
-13
View File
@@ -61,12 +61,6 @@ $_aksrt_special_templates = [
'title' => '友情链接',
'fallback' => '/friends/',
],
'messages' => [
'file' => 'templates/pages/page-messages.php',
'slug' => 'messages',
'title' => '消息',
'fallback' => '/messages/',
],
'profile' => [
'file' => 'templates/pages/page-profile.php',
'slug' => 'profile',
@@ -113,12 +107,6 @@ $_aksrt_special_templates = [
'title' => '友情链接',
'fallback' => '/friends/',
],
'messages' => [
'file' => 'templates/pages/page-messages.php',
'slug' => 'messages',
'title' => '消息',
'fallback' => '/messages/',
],
'profile' => [
'file' => 'templates/pages/page-profile.php',
'slug' => 'profile',
@@ -249,7 +237,6 @@ function aksrt_resolve_page_template_file(string $template_file = '', string $po
$slug_map = [
'categories' => 'templates/pages/page-categories.php',
'friends' => 'templates/pages/page-friends.php',
'messages' => 'templates/pages/page-messages.php',
'profile' => 'templates/pages/page-profile.php',
];
@@ -296,42 +296,6 @@ trait AKSRT_Scripts_Part_1b {
);
}
// 专题聚合页:路由专属 CSS
if (is_page_template('templates/pages/page-special.php')) {
wp_enqueue_style(
'aksrt-route-special',
$base_uri . '/assets/css/routes/special.css',
['aksrt-tokens'],
file_exists(get_template_directory() . '/assets/css/routes/special.css')
? (string) filemtime(get_template_directory() . '/assets/css/routes/special.css')
: $version
);
}
// 消息中心页
if (is_page_template('templates/pages/page-messages.php')) {
wp_enqueue_style(
'aksrt-messages',
$base_uri . '/assets/css/frontend/messages.css',
['aksrt-tokens'],
$version
);
wp_enqueue_script(
'aksrt-messages',
$base_uri . '/assets/js/messages.js',
['aksrt-script'],
$version,
true
);
wp_enqueue_script(
'aksrt-conversation',
$base_uri . '/assets/js/conversation.js',
['aksrt-script'],
$version,
true
);
}
// 订单中心页
if (is_page_template('templates/pages/page-orders.php')) {
wp_enqueue_style(
@@ -494,8 +458,8 @@ trait AKSRT_Scripts_Part_1b {
}
}
// 前台投稿页面 — page-edit.js
if (is_page_template('templates/pages/page-submit.php') || is_page_template('templates/pages/page-product-edit.php')) {
// 商品编辑页共用 page-edit.js
if (is_page_template('templates/pages/page-product-edit.php')) {
$page_edit_js = get_template_directory() . '/assets/js/page-edit.js';
if (file_exists($page_edit_js)) {
wp_enqueue_script(
@@ -1137,45 +1101,6 @@ trait AKSRT_Scripts_Part_1b {
}
// Page navigation (TOC highlight, smooth scroll, doc search)
if (is_page_template('templates/pages/page-documentnav.php') || is_singular()) {
$page_navs_path = get_template_directory() . '/assets/js/page-navs.js';
wp_enqueue_script(
'aksrt-page-navs',
$base_uri . '/assets/js/page-navs.js',
['aksrt-script'],
file_exists($page_navs_path) ? (string) filemtime($page_navs_path) : $version,
true
);
}
// Docs navigation (collapsible tree, keyboard nav, sidebar search)
if (is_page_template('templates/pages/page-documentnav.php')) {
$docs_nav_path = get_template_directory() . '/assets/js/docs-navigation.js';
if (file_exists($docs_nav_path)) {
wp_enqueue_script(
'aksrt-docs-navigation',
$base_uri . '/assets/js/docs-navigation.js',
['aksrt-script'],
(string) filemtime($docs_nav_path),
true
);
}
}
// Download center page interactions
if (is_page_template('templates/pages/page-download.php')) {
$dl_status_path = get_template_directory() . '/assets/js/download-status.js';
if (file_exists($dl_status_path)) {
wp_enqueue_script(
'aksrt-download-status',
$base_uri . '/assets/js/download-status.js',
['aksrt-script'],
(string) filemtime($dl_status_path),
true
);
}
}
// 评论回复脚本
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
@@ -1241,10 +1166,8 @@ trait AKSRT_Scripts_Part_1b {
'register' => function_exists('aksrt_get_register_url') ? aksrt_get_register_url() : wp_registration_url(),
'resetPassword' => function_exists('aksrt_get_reset_password_url') ? aksrt_get_reset_password_url() : wp_lostpassword_url(),
'profile' => function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/profile/'),
'messages' => $runtime_routes['messages'],
'cart' => $runtime_routes['cart'],
'orders' => $runtime_routes['orders'],
'download' => $runtime_routes['download'],
'resources' => $runtime_routes['resources'],
],
'shell' => [
@@ -244,16 +244,14 @@ trait AKSRT_Scripts_Part_2 {
}
/**
* Resolve public route URLs from the current canonical page-template ownership.
* Resolve public route URLs from the rebuilt mainline ownership.
*
* @return array<string, string>
*/
private function resolve_frontend_routes(): array {
return [
'messages' => $this->resolve_template_page_url('templates/pages/page-messages.php', '/messages/'),
'cart' => $this->resolve_template_page_url('templates/pages/page-cart.php', '/cart/'),
'orders' => $this->resolve_template_page_url('templates/pages/page-orders.php', '/orders/'),
'download' => $this->resolve_template_page_url('templates/pages/page-download.php', '/download/'),
'resources' => home_url('/resources/'),
];
}
@@ -135,12 +135,6 @@ class AKSRT_Settings_Home_Cms {
return array_key_exists($key, $f) ? $f[$key] : $default;
}
public static function get_homepage_modules(): array {
$s = AKSRT_Settings::get_all();
$mods = $s['homepage_modules'] ?? [];
return is_array($mods) ? array_values($mods) : [];
}
public static function homepage_allowed_sorts(): array {
return ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
}
@@ -209,68 +203,6 @@ class AKSRT_Settings_Home_Cms {
return $settings['homepage_tabs'];
}
public static function maybe_migrate_homepage_tabs(): bool {
$all = AKSRT_Settings::get_all();
if (!empty($all['homepage_tabs_migrated'])) {
return false;
}
$existing_tabs = isset($all['homepage_tabs']) && is_array($all['homepage_tabs']) ? $all['homepage_tabs'] : [];
if (!empty($existing_tabs)) {
$all['homepage_tabs_migrated'] = true;
update_option('aksrt_settings', $all);
AKSRT_Settings::flush_settings_cache();
return false;
}
$legacy_tabs = [];
$modules = isset($all['homepage_modules']) && is_array($all['homepage_modules']) ? $all['homepage_modules'] : [];
foreach ($modules as $module) {
if (!is_array($module) || ($module['type'] ?? '') !== 'tabs') {
continue;
}
$config = isset($module['config']) && is_array($module['config']) ? $module['config'] : [];
$cat_ids = isset($config['cat_ids']) && is_array($config['cat_ids']) ? array_values(array_filter(array_map('intval', $config['cat_ids']))) : [];
foreach ($cat_ids as $cat_id) {
if ($cat_id <= 0) {
continue;
}
$term = get_term($cat_id, 'category');
if (!$term || is_wp_error($term)) {
continue;
}
$legacy_tabs[] = [
'term_id' => $cat_id,
'title' => $term->name,
'orderby' => 'date',
'enabled' => true,
];
}
break;
}
if (!empty($legacy_tabs)) {
$all['homepage_tabs'] = $legacy_tabs;
}
if (!isset($all['homepage_content_model'])) {
$all['homepage_content_model'] = 'mixed';
}
$all['homepage_tabs_migrated'] = true;
update_option('aksrt_settings', $all);
AKSRT_Settings::flush_settings_cache();
return true;
}
public static function homepage_card_style(): string {
$settings = self::get_homepage_fixed_settings();
return $settings['homepage_card_style'];
@@ -363,7 +295,7 @@ class AKSRT_Settings_Home_Cms {
$manual_note = trim((string) ($settings['payment_manual_delivery_note'] ?? ''));
$box_position = sanitize_key((string) ($settings['payment_paid_box_position'] ?? 'top'));
if (!in_array($box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
if (!in_array($box_position, ['top', 'bottom'], true)) {
$box_position = 'top';
}
@@ -597,7 +529,7 @@ class AKSRT_Settings_Home_Cms {
$max_minutes = max(5, min(1440, (int) ($s['payment_order_max_minutes'] ?? 30)));
$box_position = sanitize_key((string) ($s['payment_box_position'] ?? 'top'));
if (!in_array($box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
if (!in_array($box_position, ['top', 'bottom'], true)) {
$box_position = 'top';
}
@@ -3,14 +3,6 @@ defined('ABSPATH') || exit;
trait AKSRT_Settings_Homepage_Reader {
/**
* 首页模块编排。
* @return array
*/
public static function get_homepage_modules(): array {
return AKSRT_Settings_Home_Cms::get_homepage_modules();
}
/**
* Allowed sort/orderby values for the homepage.
*
@@ -56,17 +48,6 @@ trait AKSRT_Settings_Homepage_Reader {
return AKSRT_Settings_Home_Cms::homepage_tabs();
}
/**
* Migrate legacy homepage module tabs to the new structured format.
*
* Called once on first admin visit; idempotent.
*
* @return bool Whether migration was performed.
*/
public static function maybe_migrate_homepage_tabs(): bool {
return AKSRT_Settings_Home_Cms::maybe_migrate_homepage_tabs();
}
/**
* Homepage card view variant.
*