首页「更多栏目」tab 与「排序方式」切换的骨架占位与参考主题 zibll 有实质差异,
根因不是几何宽度,而是三处结构/契约错位:
1. 骨架块自身结构与参考主题不同。card 分支用了 `<posts>` 元素 + `.post-graphic`
包裹层(列表变体,带 margin-right:20px),而参考主题 card 骨架是
`<div class="posts-item card">` 且 `.item-thumbnail` 是直接子元素。
→ card 骨架右侧多出一条真实卡片没有的 20px 沟槽。
2. 骨架块被错误地打上 `ajax-item`。参考主题的占位块没有该类。它会让
`find('.ajax-item')` / ajax-list 的 `inject()` 把骨架当成真实条目。
3. 排序切换的骨架被预渲染节点顶替。aksrt_render_pagination() 在 .ajax-pag 内
渲染了一个写死 2 条、写死 list 形状的 .post_ajax_loader;runtime post_ajax()
会先在容器内 find('.post_ajax_loader'),找到就复用并丢弃调用方按视口动态
拼出的骨架 → 切排序永远是 2 条 list 骨架,card 布局下也是、与视口宽度无关。
参考主题 zib_paging() 根本没有 loader 兄弟节点。
改动:
- inc/helpers/posts-renderer/markup.php:aksrt_render_placeholder() 的
card/list 分支改为与 zib_get_post_placeholder() 逐字等价的结构;去掉
ajax-item 类、card 分支的 .post-graphic 包裹层,元素改用 <div>。
- inc/helpers/template-tags/pagination-permissions.php:删除预渲染 loader,
与参考主题 zib_paging() 一致 —— 只渲染翻页控件。
- assets/js/core/pagination.js:找不到骨架节点时构造与 runtime/main.js 同款
的文章骨架(卡片 8/6/4 条、列表 4/3 条,按视口与参考主题同阈值),
不再退化为「转圈 + 文案」这个第二套加载语言;仅评论等非文章面保留该兜底。
- assets/js/core/pagination.js:为排序菜单(.ajax-option)与 tab 触发器
(.post_ajax_trigger)增加避让 —— 它们归 legacy runtime 管线,
否则一次点击发两个请求(与 ajax-list.js 的既有避让对称)。
- assets/js/runtime/main.js:post_ajax 的显隐由 fadeIn()/hide() 改为
.is-loading 类切换。前者写 inline display,优先级高于类规则,一旦残留
骨架永远打不开,正是骨架契约明令禁止的失败模式。
归档/分类筛选面原本另有一套独立加载语言(spinner 遮罩 + opacity 淡出),
本次一并统一到同一条 .post_ajax_loader + .is-loading 契约:
- inc/helpers/aksrt-archive.php:删除 show_loading 标记位与遮罩 DOM,
改为在分页之后渲染文章骨架。
- assets/js/core/archive.js:showLoading/hideLoading 只切 .is-loading;
fetchPosts() 清空内容时保留骨架与分页节点(与参考主题 success 只 hide
不删的生命周期一致),原先会连带删掉骨架。
- assets/css/frontend/layout.css:删除 .archive__ajax-wrap.is-loading
的 opacity 淡出与 spinner 遮罩规则。
- category.php / tag.php:删除已失效的 show_loading 实参。
验证:php -l 全部通过;php tools/audit-admin-contracts.php errors=0;
契约测试 post-visual(22) / asset-ledger(16) / message-center(8) /
lazyload(7) / frontend-lifecycle(13) / zibll-modern-widgets(10) /
page-display(18) / a11y 全绿;已重跑 build:public 刷新产物。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
157 lines
5.8 KiB
PHP
157 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* Category archive template.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
get_header();
|
|
|
|
$term = get_queried_object();
|
|
if (class_exists('\AKSRT\Core\DocsPresenter')) {
|
|
$docs_presenter = \AKSRT\Core\DocsPresenter::get_instance();
|
|
if ($term instanceof WP_Term && $term->taxonomy === 'category') {
|
|
$doc_candidates = get_posts([
|
|
'post_type' => 'page',
|
|
'post_status' => 'publish',
|
|
'posts_per_page' => 1,
|
|
'meta_key' => '_aksrt_doc_category',
|
|
'meta_value' => (string) $term->term_id,
|
|
'fields' => 'ids',
|
|
]);
|
|
if (!empty($doc_candidates)) {
|
|
get_template_part('templates/pages/page-documentnav');
|
|
get_footer();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (!$term instanceof WP_Term) {
|
|
get_footer();
|
|
return;
|
|
}
|
|
|
|
$archive_settings = class_exists('\AKSRT\Core\TermMeta')
|
|
? \AKSRT\Core\TermMeta::resolve_archive_settings($term)
|
|
: [
|
|
'header_style' => 'cover',
|
|
'show_sidebar' => true,
|
|
'show_cover' => false,
|
|
'show_desc' => !empty($term->description),
|
|
'filter_bar' => true,
|
|
'cover_url' => '',
|
|
'description' => (string) $term->description,
|
|
];
|
|
|
|
$has_sidebar = function_exists('aksrt_archive_has_sidebar')
|
|
? aksrt_archive_has_sidebar(!empty($archive_settings['show_sidebar']))
|
|
: (!empty($archive_settings['show_sidebar']) && is_active_sidebar('cat_sidebar'));
|
|
$description = !empty($archive_settings['show_desc']) ? wp_kses_post((string) $archive_settings['description']) : '';
|
|
$header_style = (string) $archive_settings['header_style'];
|
|
$ajax_filter = !empty($archive_settings['filter_bar']);
|
|
$sort_state = function_exists('aksrt_archive_get_sort_state')
|
|
? aksrt_archive_get_sort_state((array) ($archive_settings['orderby_option'] ?? []))
|
|
: ['current' => 'date', 'links' => []];
|
|
$current_sort = $sort_state['current'];
|
|
$sort_links = $sort_state['links'];
|
|
$render_config = function_exists('aksrt_archive_get_render_config')
|
|
? aksrt_archive_get_render_config(['context' => 'category'])
|
|
: ['context' => 'category'];
|
|
|
|
$filter_groups = [];
|
|
if (!empty($archive_settings['ajax_category_enabled']) && function_exists('aksrt_archive_build_term_filter_group')) {
|
|
$group = aksrt_archive_build_term_filter_group('category', (array) ($archive_settings['ajax_category'] ?? []), __('分类', 'aksrt'), $ajax_filter);
|
|
if ($group !== []) {
|
|
$filter_groups[] = $group;
|
|
}
|
|
}
|
|
if (!empty($archive_settings['ajax_tag_enabled']) && function_exists('aksrt_archive_build_term_filter_group')) {
|
|
$group = aksrt_archive_build_term_filter_group('post_tag', (array) ($archive_settings['ajax_tag'] ?? []), __('标签', 'aksrt'), $ajax_filter);
|
|
if ($group !== []) {
|
|
$filter_groups[] = $group;
|
|
}
|
|
}
|
|
if (!empty($archive_settings['custom_filter_enabled']) && function_exists('aksrt_archive_build_custom_filter_groups')) {
|
|
$filter_groups = array_merge(
|
|
$filter_groups,
|
|
aksrt_archive_build_custom_filter_groups(
|
|
(array) ($archive_settings['custom_dimensions'] ?? []),
|
|
$archive_settings['custom_filter_keys'] ?? 'all',
|
|
$ajax_filter
|
|
)
|
|
);
|
|
}
|
|
|
|
if (function_exists('aksrt_archive_open_shell')) {
|
|
aksrt_archive_open_shell([
|
|
'main_class' => 'site-main container',
|
|
'has_sidebar' => $has_sidebar,
|
|
'top_fluid' => ['cat_top_fluid'],
|
|
'page_kind' => 'category',
|
|
]);
|
|
}
|
|
?>
|
|
<?php if (function_exists('aksrt_archive_render_widget_zone')) { aksrt_archive_render_widget_zone(['cat_top_content']); } elseif (is_active_sidebar('cat_top_content')) { dynamic_sidebar('cat_top_content'); } ?>
|
|
|
|
<div class="content-main content-main--archive content-main--category">
|
|
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
|
|
|
<?php
|
|
if (function_exists('aksrt_archive_render_term_header')) {
|
|
aksrt_archive_render_term_header([
|
|
'header_style' => $header_style,
|
|
'show_cover' => !empty($archive_settings['show_cover']),
|
|
'cover_url' => (string) ($archive_settings['cover_url'] ?? ''),
|
|
'eyebrow' => __('分类归档', 'aksrt'),
|
|
'title' => single_cat_title('', false),
|
|
'description' => $description,
|
|
'admin_path' => 'page-display/category',
|
|
'admin_label' => __('分类页设置', 'aksrt'),
|
|
]);
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
if (!empty($archive_settings['filter_bar']) && function_exists('aksrt_archive_render_filter_bar')) {
|
|
aksrt_archive_render_filter_bar([
|
|
'ajax' => $ajax_filter,
|
|
'ajax_archive' => 'category',
|
|
'term_id' => (int) $term->term_id,
|
|
'aria_label' => __('分类筛选', 'aksrt'),
|
|
'meta_text' => !empty($archive_settings['post_count']) ? sprintf(_n('%d 篇文章', '%d 篇文章', (int) $term->count, 'aksrt'), (int) $term->count) : '',
|
|
'groups' => $filter_groups,
|
|
'sort_enabled' => !empty($archive_settings['orderby_enabled']),
|
|
'sort_current' => $current_sort,
|
|
'sort_links' => $sort_links,
|
|
'sort_labels' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sort_labels() : [],
|
|
'sort_as_main' => false,
|
|
]);
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
if (function_exists('aksrt_archive_render_stream')) {
|
|
aksrt_archive_render_stream(null, $render_config, [
|
|
'page_kind' => 'category',
|
|
'query_context' => 'archive',
|
|
'stream_class' => 'archive__ajax-wrap content-stream--archive content-stream--category',
|
|
'empty_text' => __('该分类下暂无文章', 'aksrt'),
|
|
'ajax_enabled' => $ajax_filter,
|
|
]);
|
|
}
|
|
?>
|
|
|
|
<?php if (function_exists('aksrt_archive_render_widget_zone')) { aksrt_archive_render_widget_zone(['cat_bottom_content']); } elseif (is_active_sidebar('cat_bottom_content')) { dynamic_sidebar('cat_bottom_content'); } ?>
|
|
</div>
|
|
<?php
|
|
if (function_exists('aksrt_archive_close_shell')) {
|
|
aksrt_archive_close_shell([
|
|
'has_sidebar' => $has_sidebar,
|
|
'bottom_fluid' => ['cat_bottom_fluid'],
|
|
]);
|
|
}
|
|
|
|
get_footer();
|