feat(categories): align archive and directory pages

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-05 23:51:33 +08:00
1 parent 7faa2d53d8
commit fbb53c6890
7 files changed
+443 -315

No files matched your search

+17 -25
View File
@@ -10,24 +10,6 @@ defined('ABSPATH') || exit;
get_header();
$term = get_queried_object();
if (class_exists('\Jio\Core\DocsPresenter')) {
$docs_presenter = \Jio\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' => '_jio_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;
@@ -35,7 +17,10 @@ if (!$term instanceof WP_Term) {
$archive_settings = \Jio\Core\TermMeta::resolve_archive_settings($term);
$has_sidebar = jio_archive_has_sidebar(!empty($archive_settings['show_sidebar']));
$ajax_filter = !empty($archive_settings['filter_bar']);
$access = function_exists('jio_get_term_allow_view_data')
? jio_get_term_allow_view_data((int) $term->term_id)
: ['allow' => true, 'not_html' => ''];
$ajax_filter = !empty($access['allow']) && !empty($archive_settings['filter_bar']);
$sort_state = jio_archive_get_sort_state((array) ($archive_settings['orderby_option'] ?? []));
$filter_groups = [];
foreach (['category' => __('分类', 'jio'), 'post_tag' => __('标签', 'jio')] as $taxonomy => $label) {
@@ -66,7 +51,7 @@ jio_archive_render_term_header([
'post_count' => !empty($archive_settings['post_count']),
]);
ob_start();
if ($ajax_filter) {
if (!empty($access['allow']) && $ajax_filter) {
jio_archive_render_filter_bar([
'aria_label' => __('分类筛选', 'jio'), 'groups' => $filter_groups,
'sort_enabled' => !empty($archive_settings['orderby_enabled']),
@@ -76,11 +61,18 @@ if ($ajax_filter) {
]);
}
$filter_html = (string) ob_get_clean();
jio_archive_render_stream(null, jio_archive_get_render_config(['context' => 'category']), [
'page_kind' => 'category', 'query_context' => 'archive',
'empty_text' => __('暂无内容', 'jio'),
'filter_html' => $filter_html,
]);
if (!empty($access['allow'])) {
jio_archive_render_stream(null, jio_archive_get_render_config(['context' => 'category']), [
'page_kind' => 'category', 'query_context' => 'archive',
'empty_text' => __('暂无内容', 'jio'),
'filter_html' => $filter_html,
]);
} else {
echo '<div class="content-stream content-stream--category posts-row ajaxpager"><div class="ajax-item">';
echo function_exists('jio_get_null') ? jio_get_null(__('抱歉!您暂无查看此内容的权限', 'jio'), 20, 'null-cap.svg', '') : '';
echo (string) ($access['not_html'] ?? '');
echo '</div></div>';
}
jio_archive_render_widget_zone(['cat_bottom_content']);
jio_archive_close_shell(['has_sidebar' => $has_sidebar, 'bottom_fluid' => ['cat_bottom_fluid']]);
get_footer();