Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
79 lines
3.1 KiB
PHP
79 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Category archive template.
|
|
*
|
|
* @package Jio
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
get_header();
|
|
|
|
$term = get_queried_object();
|
|
if (!$term instanceof WP_Term) {
|
|
get_footer();
|
|
return;
|
|
}
|
|
|
|
$archive_settings = \Jio\Core\TermMeta::resolve_archive_settings($term);
|
|
$has_sidebar = jio_archive_has_sidebar(!empty($archive_settings['show_sidebar']));
|
|
$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) {
|
|
$key = $taxonomy === 'category' ? 'ajax_category' : 'ajax_tag';
|
|
if (!empty($archive_settings[$key . '_enabled'])) {
|
|
$group = jio_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, jio_archive_build_custom_filter_groups(
|
|
(array) $archive_settings['custom_dimensions'], $archive_settings['custom_filter_keys']
|
|
));
|
|
}
|
|
jio_archive_open_shell([
|
|
'main_class' => 'site-main container', 'has_sidebar' => $has_sidebar,
|
|
'top_fluid' => ['cat_top_fluid'], 'page_kind' => 'category',
|
|
]);
|
|
jio_archive_render_widget_zone(['cat_top_content']);
|
|
jio_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 (!empty($access['allow']) && $ajax_filter) {
|
|
jio_archive_render_filter_bar([
|
|
'aria_label' => __('分类筛选', 'jio'), 'groups' => $filter_groups,
|
|
'sort_enabled' => !empty($archive_settings['orderby_enabled']),
|
|
'sort_current' => $sort_state['current'], 'sort_links' => $sort_state['links'],
|
|
'sort_labels' => \Jio\Settings\Settings::homepage_sort_labels(),
|
|
'sort_option' => (array) $archive_settings['orderby_option'],
|
|
]);
|
|
}
|
|
$filter_html = (string) ob_get_clean();
|
|
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();
|