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.
*
-14
View File
@@ -469,20 +469,6 @@ add_filter('template_include', function ($template) {
return $candidate ?: $template;
});
// 标记为资源的 post:单页改用 single-aksrt_resource.php 模板
add_filter('single_template', function ($template) {
if (!is_singular('post')) return $template;
$post = get_queried_object();
if (!($post instanceof WP_Post)) return $template;
if (!function_exists('aksrt_is_resource_post')) return $template;
if (!aksrt_is_resource_post($post)) return $template;
if (function_exists('aksrt_is_downloadable_content') && !aksrt_is_downloadable_content($post)) {
return $template;
}
$candidate = locate_template(['single-aksrt_resource.php']);
return $candidate ?: $template;
});
// 资源归档页:标题
add_filter('document_title_parts', function ($parts) {
if (get_query_var('aksrt_is_resource_archive')) {
+11 -69
View File
@@ -1,98 +1,40 @@
<?php
/**
* AKSRT 兼容层策略中枢 (Compatibility-layer policy hub)
* Deprecated compatibility toggles retained only as hard-off stubs.
*
* AKSRT → Zibll 1:1 复刻项目的收口约定:部分非主线能力(文档模式、下载中心、
* 前台投稿、专题聚合、站内私信)不再删除,也不再作为默认主入口,而是收敛为
* “兼容保留”能力。本文件集中定义这些兼容入口的可见性开关,供后台与前台统一读取,
* 避免各模板各自硬编码 `home_url()` 或 `function_exists()` 回退逻辑。
*
* 分类口径(见 docs/plan/stream-a-product-scope.md):
* - 兼容保留:路由/数据/模板/设置键保留,但不作默认主入口。
* - 前台隐藏:默认不在主导航、首页、页面模板下拉中暴露;可经 filter 次级开启。
* - 停用候选:默认关闭前台入口;仅在明确兼容需求下由站点手动开启。
*
* 硬约束:这里只控制“入口是否暴露”,不销毁任何路由、模板、ajax handler 或历史数据。
* The rebuild now treats Zibll-style mainline pages as the only product target.
* Historical message center / PM entry points / compat template pickers stay on
* disk for legacy routing safety, but no longer participate in product-facing
* navigation or configuration decisions.
*
* @package AKSRT
* @since 3.4.0
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_messages_url')) {
/**
* 解析站内消息/通知中心页面地址。
*
* 消息通知骨架属于“兼容保留”能力:仍向已登录用户在用户下拉中提供次级入口,
* 但不作为一级导航。优先解析已分配 page-messages 模板的实际页面,回退到 /messages/。
*
* @return string
* Legacy message center URL stub.
*/
function aksrt_get_messages_url(): string {
$url = '';
if (function_exists('aksrt_find_template_page')) {
$page = aksrt_find_template_page('templates/pages/page-messages.php');
if ($page instanceof WP_Post) {
$url = (string) get_permalink($page);
}
}
if ($url === '') {
$url = home_url('/messages/');
}
/**
* 允许站点/子主题覆盖兼容消息中心地址。
*
* @param string $url 消息中心地址。
*/
return (string) apply_filters('aksrt_messages_url', $url);
return home_url('/messages/');
}
}
if (!function_exists('aksrt_pm_frontend_enabled')) {
/**
* 是否在前台暴露站内私信/会话入口。
*
* 私信/会话系统在收口后属于“停用候选”:ajax handler、数据、模板均保留(后台兼容),
* 但默认不再在前台(如作者操作条“私信”按钮)暴露,以免继续把产品心智推向社交平台。
* 站点如确有兼容需求,可通过该 filter 或常量 AKSRT_ENABLE_PM_FRONTEND 重新开启。
*
* @return bool
* Private-message entry is disabled in the rebuilt mainline.
*/
function aksrt_pm_frontend_enabled(): bool {
$enabled = defined('AKSRT_ENABLE_PM_FRONTEND') && AKSRT_ENABLE_PM_FRONTEND;
/**
* 允许站点重新开启前台私信入口(默认关闭)。
*
* @param bool $enabled 是否开启前台私信入口。
*/
return (bool) apply_filters('aksrt_pm_frontend_enabled', $enabled);
return false;
}
}
if (!function_exists('aksrt_show_compat_page_templates')) {
/**
* 是否在 wp-admin 页面模板下拉中暴露“兼容保留”页面模板。
*
* 文档导航、下载中心、消息中心、前台投稿、专题聚合等模板默认不再出现在页面模板
* 下拉里,避免污染主线内容心智;但模板文件与已分配这些模板的历史页面仍照常渲染
* (见 AKSRT_Templates::load_page_template())。站点如需继续手动创建这些兼容页面,
* 可通过该 filter 或常量 AKSRT_SHOW_COMPAT_TEMPLATES 重新暴露下拉选项。
*
* @return bool
* Compat-only page templates are hidden from the rebuilt product surface.
*/
function aksrt_show_compat_page_templates(): bool {
$show = defined('AKSRT_SHOW_COMPAT_TEMPLATES') && AKSRT_SHOW_COMPAT_TEMPLATES;
/**
* 允许站点在页面模板下拉中重新暴露兼容页面模板(默认关闭)。
*
* @param bool $show 是否暴露兼容页面模板下拉。
*/
return (bool) apply_filters('aksrt_show_compat_page_templates', $show);
return false;
}
}
+6 -193
View File
@@ -60,57 +60,6 @@ if (!function_exists('aksrt_homepage_get_post_types')) {
}
}
if (!function_exists('aksrt_homepage_get_legacy_tabs_config')) {
/**
* Use the first legacy "tabs" home module as a migration bridge so that
* previously configured category ids keep powering the new fixed homepage.
*
* @return array{term_ids:int[],posts_per_page:int}
*/
function aksrt_homepage_get_legacy_tabs_config(): array {
static $config = null;
if (is_array($config)) {
return $config;
}
$config = [
'term_ids' => [],
'posts_per_page' => 6,
];
if (!class_exists('AKSRT_Settings')) {
return $config;
}
foreach (AKSRT_Settings::get_homepage_modules() as $module) {
if (!is_array($module) || ($module['type'] ?? '') !== 'tabs') {
continue;
}
$module_config = isset($module['config']) && is_array($module['config'])
? $module['config']
: [];
$term_ids = isset($module_config['cat_ids']) && is_array($module_config['cat_ids'])
? array_values(array_filter(array_map('intval', $module_config['cat_ids'])))
: [];
if ($term_ids) {
$config['term_ids'] = $term_ids;
}
if (!empty($module_config['count'])) {
$config['posts_per_page'] = max(4, min(12, (int) $module_config['count']));
}
break;
}
return $config;
}
}
if (!function_exists('aksrt_homepage_get_tab_terms')) {
/**
* Homepage category tabs with full config.
@@ -188,10 +137,7 @@ if (!function_exists('aksrt_homepage_get_tab_posts_per_page')) {
}
}
$legacy = aksrt_homepage_get_legacy_tabs_config();
$count = (int) apply_filters('aksrt_homepage_tab_posts_per_page', $legacy['posts_per_page']);
return max(4, min(12, $count));
return 6;
}
}
@@ -393,7 +339,6 @@ if (!function_exists('aksrt_homepage_render_sortbar')) {
: $sort_items;
?>
<div class="aksrt-homepage__sortbar" data-sort-ajax="<?php echo $sort_ajax_enabled ? 'true' : 'false'; ?>" aria-label="<?php esc_attr_e('Homepage Sort', 'aksrt'); ?>">
<span class="aksrt-homepage__sortbar-label"><?php esc_html_e('排序', 'aksrt'); ?></span>
<?php if ($is_dropdown) : ?>
<div class="aksrt-homepage__sortbar-dropdown">
<button type="button" class="aksrt-homepage__sortbar-current" data-sort-dropdown-trigger>
@@ -845,117 +790,6 @@ if (!function_exists('aksrt_homepage_render_system_module')) {
}
}
if (!function_exists('aksrt_homepage_get_featured_modules')) {
/**
* Resolve non-core homepage modules that should render alongside the fixed
* hero/banner/main-stream skeleton.
*
* @return array<int,array{type:string,config:array}>
*/
function aksrt_homepage_get_featured_modules(): array {
if (!class_exists('AKSRT_Settings')) {
return [];
}
$allowed_types = [
'category',
'recent',
'ranking',
'hotspot',
'category_recommend_cards',
'tag_cloud',
'friend_links',
'html',
'highlight_cards',
];
$modules = [];
foreach (AKSRT_Settings::get_homepage_modules() as $module) {
if (!is_array($module)) {
continue;
}
$type = sanitize_key((string) ($module['type'] ?? ''));
if (!in_array($type, $allowed_types, true)) {
continue;
}
$modules[] = [
'type' => $type,
'config' => isset($module['config']) && is_array($module['config']) ? $module['config'] : [],
];
}
return $modules;
}
}
if (!function_exists('aksrt_homepage_render_featured_modules')) {
/**
* Render featured homepage modules in configured order.
*/
function aksrt_homepage_render_featured_modules(array $modules, string $wrapper_class = 'home-modules'): void {
if (empty($modules)) {
return;
}
echo '<div class="' . esc_attr(trim($wrapper_class)) . '">';
foreach ($modules as $idx => $module) {
$type = sanitize_key((string) ($module['type'] ?? ''));
if ($type === '') {
continue;
}
set_query_var('aksrt_module_config', isset($module['config']) && is_array($module['config']) ? $module['config'] : []);
set_query_var('aksrt_module_index', $idx);
get_template_part('templates/parts/home-modules/module', $type);
}
set_query_var('aksrt_module_config', null);
set_query_var('aksrt_module_index', null);
echo '</div>';
}
}
if (!function_exists('aksrt_homepage_split_featured_modules')) {
/**
* Split legacy featured modules into homepage skeleton slots.
*
* @param array<int,array{type:string,config:array}> $modules
* @return array{top:array<int,array{type:string,config:array}>,mid:array<int,array{type:string,config:array}>,bottom:array<int,array{type:string,config:array}>}
*/
function aksrt_homepage_split_featured_modules(array $modules): array {
$buckets = [
'top' => [],
'mid' => [],
'bottom' => [],
];
$top_types = ['highlight_cards', 'hotspot', 'html'];
$bottom_types = ['ranking', 'tag_cloud', 'friend_links'];
foreach ($modules as $module) {
$type = sanitize_key((string) ($module['type'] ?? ''));
if ($type === '') {
continue;
}
if (in_array($type, $top_types, true)) {
$buckets['top'][] = $module;
continue;
}
if (in_array($type, $bottom_types, true)) {
$buckets['bottom'][] = $module;
continue;
}
$buckets['mid'][] = $module;
}
return $buckets;
}
}
if (!function_exists('aksrt_homepage_render_layout')) {
/**
* Render the fixed homepage layout directly.
@@ -964,8 +798,6 @@ if (!function_exists('aksrt_homepage_render_layout')) {
$current_page = aksrt_homepage_get_current_page();
$show_tabs = $current_page === 1;
$tab_configs = $show_tabs ? aksrt_homepage_get_tab_configs() : [];
$featured_modules = $show_tabs ? aksrt_homepage_get_featured_modules() : [];
$featured_slots = $show_tabs ? aksrt_homepage_split_featured_modules($featured_modules) : ['top' => [], 'mid' => [], 'bottom' => []];
$latest_contract = aksrt_homepage_get_latest_panel_contract();
$has_sidebar = aksrt_homepage_has_sidebar();
$hero_on = $show_tabs && aksrt_homepage_module_hero_enabled();
@@ -1003,27 +835,20 @@ if (!function_exists('aksrt_homepage_render_layout')) {
aksrt_homepage_render_system_module('banner', 'aksrt-homepage__content-zone aksrt-homepage__content-zone--banner aksrt-homepage__system-modules home-modules');
}
if (!empty($featured_slots['top'])) {
aksrt_homepage_render_featured_modules(
$featured_slots['top'],
'aksrt-homepage__content-zone aksrt-homepage__content-zone--operated aksrt-homepage__content-zone--top-modules home-modules'
);
}
?>
<?php if ($main_list_enabled) : ?>
<section class="widget widget-card aksrt-homepage__stream home-tab-content index-tab-main" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
<div class="aksrt-homepage__stream-header box-body notop nobottom">
<section class="aksrt-homepage__stream" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
<div class="aksrt-homepage__stream-header">
<div class="aksrt-homepage__stream-intro">
<div class="aksrt-homepage__stream-kicker"><?php esc_html_e('首页主内容流', 'aksrt'); ?></div>
<h2 class="aksrt-homepage__stream-title"><?php echo esc_html($list_title); ?></h2>
<p class="aksrt-homepage__stream-subtitle"><?php esc_html_e('以内容流为主轴,承接运营入口、分类切换与持续更新。', 'aksrt'); ?></p>
<p class="aksrt-homepage__stream-subtitle"><?php esc_html_e('以首页主内容流承接分类切换、排序与持续更新。', 'aksrt'); ?></p>
</div>
<?php if (function_exists('aksrt_render_admin_quick_link')) { aksrt_render_admin_quick_link('page-display/homepage', __('首页设置', 'aksrt'), 'aksrt-admin-quicklink aksrt-homepage__admin-link'); } ?>
</div>
<?php if ($show_tabs && !empty($tab_configs)) : ?>
<div class="aksrt-homepage__tabs box-body notop nobottom index-tab home-tab-nav-box" data-sticky-tabs="<?php echo aksrt_homepage_sticky_tabs_enabled() ? 'true' : 'false'; ?>">
<div class="aksrt-homepage__tabs home-tab-nav-box" data-sticky-tabs="<?php echo aksrt_homepage_sticky_tabs_enabled() ? 'true' : 'false'; ?>">
<ul class="aksrt-homepage__tab-list scroll-x no-scrollbar" role="tablist" data-aksrt-home-tabs>
<li class="aksrt-homepage__tab-item is-active" role="presentation">
<button
@@ -1053,7 +878,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
</ul>
</div>
<?php elseif ($current_page > 1) : ?>
<div class="aksrt-homepage__titlebox box-body notop nobottom">
<div class="aksrt-homepage__titlebox">
<div class="title-theme">
<?php echo esc_html($list_title); ?>
<small class="aksrt-homepage__page-indicator">
@@ -1101,24 +926,12 @@ if (!function_exists('aksrt_homepage_render_layout')) {
<?php endif; ?>
<?php
if (!empty($featured_slots['mid'])) {
aksrt_homepage_render_featured_modules(
$featured_slots['mid'],
'aksrt-homepage__content-zone aksrt-homepage__content-zone--mid home-modules'
);
}
aksrt_homepage_render_widget_zone(
['home_bottom_content'],
'aksrt-homepage__content-zone aksrt-homepage__content-zone--bottom'
);
if (!empty($featured_slots['bottom'])) {
aksrt_homepage_render_featured_modules(
$featured_slots['bottom'],
'aksrt-homepage__content-zone aksrt-homepage__content-zone--supplement home-modules'
);
}
?>
</div>