Align homepage and category discovery, modern widgets, admin controls, quotes, and comments with the reference theme. Remove superseded paths and add rendering and behavior coverage. Update stale asset and finance contracts; all 760 Node tests and 139 widget assertions pass.
87 lines
3.1 KiB
PHP
87 lines
3.1 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 = \AKSRT\Core\TermMeta::resolve_archive_settings($term);
|
|
$has_sidebar = aksrt_archive_has_sidebar(!empty($archive_settings['show_sidebar']));
|
|
$ajax_filter = !empty($archive_settings['filter_bar']);
|
|
$sort_state = aksrt_archive_get_sort_state((array) ($archive_settings['orderby_option'] ?? []));
|
|
$filter_groups = [];
|
|
foreach (['category' => __('分类', 'aksrt'), 'post_tag' => __('标签', 'aksrt')] as $taxonomy => $label) {
|
|
$key = $taxonomy === 'category' ? 'ajax_category' : 'ajax_tag';
|
|
if (!empty($archive_settings[$key . '_enabled'])) {
|
|
$group = aksrt_archive_build_term_filter_group($taxonomy, (array) $archive_settings[$key], $label);
|
|
if ($group) {
|
|
$filter_groups[] = $group;
|
|
}
|
|
}
|
|
}
|
|
if (!empty($archive_settings['custom_filter_enabled'])) {
|
|
$filter_groups = array_merge($filter_groups, aksrt_archive_build_custom_filter_groups(
|
|
(array) $archive_settings['custom_dimensions'], $archive_settings['custom_filter_keys']
|
|
));
|
|
}
|
|
aksrt_archive_open_shell([
|
|
'main_class' => 'site-main container', 'has_sidebar' => $has_sidebar,
|
|
'top_fluid' => ['cat_top_fluid'], 'page_kind' => 'category',
|
|
]);
|
|
aksrt_archive_render_widget_zone(['cat_top_content']);
|
|
aksrt_archive_render_term_header([
|
|
'header_style' => $archive_settings['header_style'],
|
|
'show_cover' => !empty($archive_settings['show_cover']),
|
|
'cover_url' => (string) $archive_settings['cover_url'],
|
|
'title' => single_cat_title('', false),
|
|
'description' => !empty($archive_settings['show_desc']) ? $archive_settings['description'] : '',
|
|
'post_count' => !empty($archive_settings['post_count']),
|
|
]);
|
|
ob_start();
|
|
if ($ajax_filter) {
|
|
aksrt_archive_render_filter_bar([
|
|
'aria_label' => __('分类筛选', 'aksrt'), 'groups' => $filter_groups,
|
|
'sort_enabled' => !empty($archive_settings['orderby_enabled']),
|
|
'sort_current' => $sort_state['current'], 'sort_links' => $sort_state['links'],
|
|
'sort_labels' => \AKSRT\Settings\Settings::homepage_sort_labels(),
|
|
'sort_option' => (array) $archive_settings['orderby_option'],
|
|
]);
|
|
}
|
|
$filter_html = (string) ob_get_clean();
|
|
aksrt_archive_render_stream(null, aksrt_archive_get_render_config(['context' => 'category']), [
|
|
'page_kind' => 'category', 'query_context' => 'archive',
|
|
'empty_text' => __('暂无内容', 'aksrt'),
|
|
'filter_html' => $filter_html,
|
|
]);
|
|
aksrt_archive_render_widget_zone(['cat_bottom_content']);
|
|
aksrt_archive_close_shell(['has_sidebar' => $has_sidebar, 'bottom_fluid' => ['cat_bottom_fluid']]);
|
|
get_footer();
|