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_Term_Meta') ? AKSRT_Term_Meta::resolve_archive_settings($term) : [ 'layout_mode' => 'card', 'header_style' => 'cover', 'show_sidebar' => true, 'show_cover' => false, 'show_desc' => !empty($term->description), 'filter_bar' => true, 'cover_url' => '', 'description' => (string) $term->description, 'card_style' => 'standard', ]; $has_sidebar = function_exists('aksrt_archive_has_sidebar') ? aksrt_archive_has_sidebar('cat_sidebar', !empty($archive_settings['show_sidebar'])) : (!empty($archive_settings['show_sidebar']) && (is_active_sidebar('cat_sidebar') || is_active_sidebar('sidebar-blog'))); $description = !empty($archive_settings['show_desc']) ? wp_kses_post((string) $archive_settings['description']) : ''; $header_style = (string) $archive_settings['header_style']; $layout_mode = (string) $archive_settings['layout_mode']; $card_style = (string) ($archive_settings['card_style'] ?? 'standard'); $filter_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_filter_settings() : ['enabled' => false, 'sort' => false, 'ajax_enabled' => false]; if (!empty($filter_settings['enabled']) && !in_array('cat', $filter_settings['custom_filter_show'] ?? ['cat', 'tag'], true)) { $filter_settings['enabled'] = false; } $ajax_filter = !empty($filter_settings['ajax_enabled']) && !empty($filter_settings['enabled']); $cat_filter_config = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_filter_config_for_category((int) $term->term_id) : ['dimensions' => []]; $custom_dimensions = is_array($cat_filter_config['dimensions'] ?? null) ? $cat_filter_config['dimensions'] : []; $sort_state = function_exists('aksrt_archive_get_sort_state') ? aksrt_archive_get_sort_state() : ['current' => 'latest', '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', 'mode' => $layout_mode, 'card_style' => $card_style, ]) : [ 'context' => 'category', 'mode' => $layout_mode, 'card_style' => $card_style, ]; $filter_terms = []; $filter_all_url = get_category_link($term->term_id); if (!empty($archive_settings['filter_bar'])) { $filter_terms = get_terms([ 'taxonomy' => 'category', 'hide_empty' => true, 'parent' => $term->term_id, ]); if (empty($filter_terms) && !empty($term->parent)) { $filter_all_url = get_category_link((int) $term->parent); $filter_terms = get_terms([ 'taxonomy' => 'category', 'hide_empty' => true, 'parent' => (int) $term->parent, ]); } if (is_wp_error($filter_terms)) { $filter_terms = []; } } $tag_filter_terms = []; $current_filter_cat = sanitize_text_field((string) get_query_var('aksrt_filter_cat', '')); $current_filter_tag = sanitize_text_field((string) get_query_var('aksrt_filter_tag', '')); $current_cf_values = []; foreach ($custom_dimensions as $dim) { $cf_key = 'aksrt_cf_' . $dim['key']; $current_cf_values[$dim['key']] = isset($_GET[$cf_key]) ? sanitize_key((string) $_GET[$cf_key]) : ''; } if ($ajax_filter && !empty($filter_settings['cat_show_tag'])) { $tag_filter_terms = get_terms([ 'taxonomy' => 'post_tag', 'hide_empty' => true, 'number' => 20, ]); if (is_wp_error($tag_filter_terms)) { $tag_filter_terms = []; } } $filter_groups = []; if (!empty($filter_terms)) { $chips = [[ 'label' => __('全部', 'aksrt'), 'url' => $filter_all_url, 'active' => empty($term->parent) && $current_filter_cat === '', 'attrs' => $ajax_filter ? ' data-filter-cat="0"' : '', ]]; foreach ($filter_terms as $filter_term) { $is_current = ((int) $filter_term->term_id === (int) $term->term_id) || ($current_filter_cat !== '' && (int) $current_filter_cat === (int) $filter_term->term_id); $chips[] = [ 'label' => $filter_term->name, 'url' => get_term_link($filter_term), 'active' => $is_current, 'attrs' => $ajax_filter ? ' data-filter-cat="' . (int) $filter_term->term_id . '"' : '', ]; } $filter_groups[] = [ 'label' => __('分类导航', 'aksrt'), 'chips' => $chips, ]; } if (!empty($tag_filter_terms)) { $chips = [[ 'label' => __('全部', 'aksrt'), 'url' => remove_query_arg(['aksrt_filter_tag']), 'active' => $current_filter_tag === '', 'attrs' => $ajax_filter ? ' data-filter-tag=""' : '', ]]; foreach ($tag_filter_terms as $tag_term) { $is_current_tag = ($current_filter_tag !== '' && (int) $current_filter_tag === (int) $tag_term->term_id); $chips[] = [ 'label' => $tag_term->name, 'url' => add_query_arg('aksrt_filter_tag', (int) $tag_term->term_id), 'active' => $is_current_tag, 'attrs' => $ajax_filter ? ' data-filter-tag="' . (int) $tag_term->term_id . '"' : '', ]; } $filter_groups[] = [ 'label' => __('标签', 'aksrt'), 'class' => 'archive-filter-bar__main--tags', 'chips' => $chips, ]; } foreach ($custom_dimensions as $dim) { $chips = [[ 'label' => __('全部', 'aksrt'), 'url' => remove_query_arg('aksrt_cf_' . $dim['key']), 'active' => ($current_cf_values[$dim['key']] ?? '') === '', 'attrs' => $ajax_filter ? ' data-filter-cf="' . esc_attr($dim['key']) . '" data-filter-cf-val=""' : '', ]]; foreach ($dim['vals'] as $val) { $is_current_cf = ($current_cf_values[$dim['key']] ?? '') === $val['key']; $chips[] = [ 'label' => $val['name'], 'url' => add_query_arg('aksrt_cf_' . $dim['key'], $val['key']), 'active' => $is_current_cf, 'attrs' => $ajax_filter ? ' data-filter-cf="' . esc_attr($dim['key']) . '" data-filter-cf-val="' . esc_attr($val['key']) . '"' : '', ]; } $filter_groups[] = [ 'label' => $dim['name'], 'class' => 'archive-filter-bar__main--custom', 'chips' => $chips, ]; } if (function_exists('aksrt_archive_open_shell')) { aksrt_archive_open_shell([ 'main_class' => 'site-main container content-shell content-shell--stream', 'has_sidebar' => $has_sidebar, 'top_fluid' => ['cat_top_fluid'], 'page_kind' => 'category', ]); } ?>
$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'), ]); } ?> $ajax_filter, 'ajax_archive' => 'category', 'term_id' => (int) $term->term_id, 'layout_mode' => $layout_mode, 'card_style' => $card_style, 'aria_label' => __('分类筛选', 'aksrt'), 'meta_text' => sprintf(_n('%d 篇文章', '%d 篇文章', (int) $term->count, 'aksrt'), (int) $term->count), 'groups' => $filter_groups, 'sort_enabled' => !empty($filter_settings['enabled']) && !empty($filter_settings['sort']), 'sort_current' => $current_sort, 'sort_links' => $sort_links, 'sort_as_main' => false, ]); } ?> 'category', 'query_context' => 'archive', 'stream_class' => 'archive__ajax-wrap content-stream--archive content-stream--category', 'empty_text' => __('该分类下暂无文章', 'aksrt'), 'ajax_enabled' => $ajax_filter, 'show_loading' => $ajax_filter, ]); } ?>
$has_sidebar, 'bottom_fluid' => ['cat_bottom_fluid'], ]); } get_footer();