Merge pull request '兼容层收口:隔离非主线入口' (#8) from worktree-compat-layer-sealing into main

Reviewed-on: CYL/wordpress-theme-aksrt#8
This commit is contained in:
2026-07-06 15:25:59 +08:00
5 changed files with 139 additions and 11 deletions
+1 -1
View File
@@ -6,5 +6,5 @@
* the navigation tree and router definitions while keeping each file focused. * the navigation tree and router definitions while keeping each file focused.
*/ */
export { ADMIN_SECTIONS, getAllAdminPages } from './sections/index.js' export { ADMIN_SECTIONS, getAdminSections, getAllAdminPages } from './sections/index.js'
export { renderFaIcon, customPage, schemaPage, deferredPage } from './sections/helpers.js' export { renderFaIcon, customPage, schemaPage, deferredPage } from './sections/helpers.js'
+1
View File
@@ -32,6 +32,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-vip.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-i18n-switch.php'; require_once AKSRT_DIR . '/inc/helpers/aksrt-i18n-switch.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-posts-renderer.php'; require_once AKSRT_DIR . '/inc/helpers/aksrt-posts-renderer.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-resource.php'; require_once AKSRT_DIR . '/inc/helpers/aksrt-resource.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-compat.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-pay.php'; require_once AKSRT_DIR . '/inc/helpers/aksrt-pay.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-credits.php'; require_once AKSRT_DIR . '/inc/helpers/aksrt-credits.php';
require_once AKSRT_DIR . '/inc/helpers/menu-decoration.php'; require_once AKSRT_DIR . '/inc/helpers/menu-decoration.php';
+32 -6
View File
@@ -32,7 +32,10 @@ class AKSRT_Templates {
// 短代码注册统一在 AKSRT_Shortcodes(registry);本类只提供 archive/profile 渲染实现。 // 短代码注册统一在 AKSRT_Shortcodes(registry);本类只提供 archive/profile 渲染实现。
} }
private function page_template_map(): array { /**
* 主线页面模板:内容 / 用户 / 付费 / 论坛 / 商城主线可选模板。
*/
private function mainline_page_template_map(): array {
return [ return [
'templates/pages/page-sign.php' => __('AKSRT - 登录/注册', 'aksrt'), 'templates/pages/page-sign.php' => __('AKSRT - 登录/注册', 'aksrt'),
'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'), 'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'),
@@ -41,12 +44,7 @@ class AKSRT_Templates {
'templates/pages/page-categories.php' => __('AKSRT - 分类汇总', 'aksrt'), 'templates/pages/page-categories.php' => __('AKSRT - 分类汇总', 'aksrt'),
'templates/pages/page-newposts.php' => __('AKSRT - 最新文章', 'aksrt'), 'templates/pages/page-newposts.php' => __('AKSRT - 最新文章', 'aksrt'),
'templates/pages/page-posts-navs.php' => __('AKSRT - 文章导航', 'aksrt'), 'templates/pages/page-posts-navs.php' => __('AKSRT - 文章导航', 'aksrt'),
'templates/pages/page-special.php' => __('AKSRT - 专题聚合', 'aksrt'),
'templates/pages/page-documentnav.php' => __('AKSRT - 文档导航', 'aksrt'),
'templates/pages/page-friends.php' => __('AKSRT - 友情链接', 'aksrt'), 'templates/pages/page-friends.php' => __('AKSRT - 友情链接', 'aksrt'),
'templates/pages/page-messages.php' => __('AKSRT - 消息中心', 'aksrt'),
'templates/pages/page-download.php' => __('AKSRT - 下载中心', 'aksrt'),
'templates/pages/page-submit.php' => __('AKSRT - 前台投稿', 'aksrt'),
'templates/pages/page-orders.php' => __('AKSRT - 订单中心', 'aksrt'), 'templates/pages/page-orders.php' => __('AKSRT - 订单中心', 'aksrt'),
'templates/pages/page-revenue.php' => __('AKSRT - 收益中心', 'aksrt'), 'templates/pages/page-revenue.php' => __('AKSRT - 收益中心', 'aksrt'),
'templates/pages/page-cart.php' => __('AKSRT - 购物车', 'aksrt'), 'templates/pages/page-cart.php' => __('AKSRT - 购物车', 'aksrt'),
@@ -57,6 +55,34 @@ 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. * Register selectable page templates in wp-admin.
*/ */
+98
View File
@@ -0,0 +1,98 @@
<?php
/**
* AKSRT 兼容层策略中枢 (Compatibility-layer policy hub)
*
* AKSRT → Zibll 1:1 复刻项目的收口约定:部分非主线能力(文档模式、下载中心、
* 前台投稿、专题聚合、站内私信)不再删除,也不再作为默认主入口,而是收敛为
* “兼容保留”能力。本文件集中定义这些兼容入口的可见性开关,供后台与前台统一读取,
* 避免各模板各自硬编码 `home_url()` 或 `function_exists()` 回退逻辑。
*
* 分类口径(见 docs/plan/stream-a-product-scope.md):
* - 兼容保留:路由/数据/模板/设置键保留,但不作默认主入口。
* - 前台隐藏:默认不在主导航、首页、页面模板下拉中暴露;可经 filter 次级开启。
* - 停用候选:默认关闭前台入口;仅在明确兼容需求下由站点手动开启。
*
* 硬约束:这里只控制“入口是否暴露”,不销毁任何路由、模板、ajax handler 或历史数据。
*
* @package AKSRT
* @since 3.4.0
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_messages_url')) {
/**
* 解析站内消息/通知中心页面地址。
*
* 消息通知骨架属于“兼容保留”能力:仍向已登录用户在用户下拉中提供次级入口,
* 但不作为一级导航。优先解析已分配 page-messages 模板的实际页面,回退到 /messages/。
*
* @return string
*/
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);
}
}
if (!function_exists('aksrt_pm_frontend_enabled')) {
/**
* 是否在前台暴露站内私信/会话入口。
*
* 私信/会话系统在收口后属于“停用候选”:ajax handler、数据、模板均保留(后台兼容),
* 但默认不再在前台(如作者操作条“私信”按钮)暴露,以免继续把产品心智推向社交平台。
* 站点如确有兼容需求,可通过该 filter 或常量 AKSRT_ENABLE_PM_FRONTEND 重新开启。
*
* @return bool
*/
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);
}
}
if (!function_exists('aksrt_show_compat_page_templates')) {
/**
* 是否在 wp-admin 页面模板下拉中暴露“兼容保留”页面模板。
*
* 文档导航、下载中心、消息中心、前台投稿、专题聚合等模板默认不再出现在页面模板
* 下拉里,避免污染主线内容心智;但模板文件与已分配这些模板的历史页面仍照常渲染
* (见 AKSRT_Templates::load_page_template())。站点如需继续手动创建这些兼容页面,
* 可通过该 filter 或常量 AKSRT_SHOW_COMPAT_TEMPLATES 重新暴露下拉选项。
*
* @return bool
*/
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);
}
}
+7 -4
View File
@@ -62,10 +62,13 @@ $classes = trim('article-avatar ' . $extra_class . ($show_actions ? ' article-av
<i class="far fa-heart" aria-hidden="true"></i> <i class="far fa-heart" aria-hidden="true"></i>
<span><?php esc_html_e('关注', 'aksrt'); ?></span> <span><?php esc_html_e('关注', 'aksrt'); ?></span>
</button> </button>
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', function_exists('aksrt_get_messages_url') ? aksrt_get_messages_url() : home_url('/messages/'))); ?>" class="author-action-btn author-action-btn--ghost"> <?php // 私信为“停用候选”兼容能力:默认不在前台暴露,仅在站点显式开启时显示。 ?>
<i class="far fa-comment-dots" aria-hidden="true"></i> <?php if (function_exists('aksrt_pm_frontend_enabled') && aksrt_pm_frontend_enabled()) : ?>
<span><?php esc_html_e('私信', 'aksrt'); ?></span> <a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', aksrt_get_messages_url())); ?>" class="author-action-btn author-action-btn--ghost">
</a> <i class="far fa-comment-dots" aria-hidden="true"></i>
<span><?php esc_html_e('私信', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php elseif (!is_user_logged_in()) : ?> <?php elseif (!is_user_logged_in()) : ?>
<a href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink())); ?>" class="author-action-btn author-action-btn--follow"> <a href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink())); ?>" class="author-action-btn author-action-btn--follow">
<i class="far fa-heart" aria-hidden="true"></i> <i class="far fa-heart" aria-hidden="true"></i>