兼容层收口:隔离非主线入口
将文档模式、下载中心、专题聚合、消息中心、前台投稿等非 Zibll 主线能力 收敛为“兼容保留”,默认不再作为主入口暴露,但保留路由/模板/数据/设置键。 - 新增 inc/helpers/aksrt-compat.php 兼容策略中枢: - aksrt_get_messages_url()(补齐此前缺失、被两处模板调用的 helper) - aksrt_pm_frontend_enabled()(前台私信入口开关,默认关闭) - aksrt_show_compat_page_templates()(兼容页面模板下拉开关,默认关闭) - AKSRT_Templates::page_template_map() 拆分为主线/兼容两组,兼容模板默认 移出 wp-admin 页面模板下拉;已分配这些模板的历史页面照常渲染。 - 作者操作条“私信”按钮(停用候选)默认前台隐藏,可经 filter/常量开启。 - 修复 admin-sections.js barrel 未再导出 getAdminSections 的缺陷,该缺陷 会使 router 的兼容分区默认落点重定向在加载时抛错。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -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-posts-renderer.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-credits.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/menu-decoration.php';
|
||||
|
||||
@@ -32,7 +32,10 @@ class AKSRT_Templates {
|
||||
// 短代码注册统一在 AKSRT_Shortcodes(registry);本类只提供 archive/profile 渲染实现。
|
||||
}
|
||||
|
||||
private function page_template_map(): array {
|
||||
/**
|
||||
* 主线页面模板:内容 / 用户 / 付费 / 论坛 / 商城主线可选模板。
|
||||
*/
|
||||
private function mainline_page_template_map(): array {
|
||||
return [
|
||||
'templates/pages/page-sign.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-newposts.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-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-revenue.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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user