Zibll 主线收口:统一 single 并清退 compat 资源路径
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
0a6f97af21
commit
09f1eec909
26 files changed
+158
-1325
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in new issue
Block a user