| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template: Taxonomy Archive (category & tag pages) |
| 4 |
* |
| 5 |
* Apple Liquid-Glass design – category header, subcategories, articles list, pagination. |
| 6 |
* |
| 7 |
* @package King_Addons |
| 8 |
*/ |
| 9 |
|
| 10 |
defined('ABSPATH') || exit; |
| 11 |
|
| 12 |
$ext = \King_Addons\Docs_KB::instance(); |
| 13 |
$options = $ext->get_options(); |
| 14 |
$mode = $options['dark_mode'] ?? 'auto'; |
| 15 |
$primary = $options['primary_color'] ?? '#0071e3'; |
| 16 |
|
| 17 |
$term = get_queried_object(); |
| 18 |
$is_tag = is_tax('kng_doc_tag'); |
| 19 |
$icon_name = get_term_meta($term->term_id, 'kng_doc_cat_icon', true) ?: 'folder'; |
| 20 |
|
| 21 |
/* ── Subcategories ── */ |
| 22 |
$children = []; |
| 23 |
if (!$is_tag) { |
| 24 |
$children = get_terms([ |
| 25 |
'taxonomy' => 'kng_doc_category', |
| 26 |
'parent' => $term->term_id, |
| 27 |
'hide_empty' => true, |
| 28 |
]); |
| 29 |
if (is_wp_error($children)) $children = []; |
| 30 |
} |
| 31 |
|
| 32 |
get_header(); |
| 33 |
?> |
| 34 |
|
| 35 |
<div class="kng-docs-page" |
| 36 |
data-kng-theme-mode="<?php echo esc_attr($mode); ?>" |
| 37 |
style="--kng-docs-primary:<?php echo esc_attr($primary); ?>; --kng-docs-icon-color:<?php echo esc_attr($primary); ?>;"> |
| 38 |
|
| 39 |
<div class="kng-docs-container"> |
| 40 |
|
| 41 |
<!-- ══════════════════════════════════════ |
| 42 |
BREADCRUMBS |
| 43 |
══════════════════════════════════════ --> |
| 44 |
<nav class="kng-docs-breadcrumbs" aria-label="<?php esc_attr_e('Breadcrumb', 'king-addons'); ?>"> |
| 45 |
<a href="<?php echo esc_url(get_post_type_archive_link('kng_doc')); ?>" class="kng-docs-breadcrumb-item"> |
| 46 |
<?php echo $ext->get_icon_svg('home'); ?> |
| 47 |
<?php esc_html_e('Docs', 'king-addons'); ?> |
| 48 |
</a> |
| 49 |
|
| 50 |
<?php |
| 51 |
if (!$is_tag && $term->parent) { |
| 52 |
$ancestors = get_ancestors($term->term_id, 'kng_doc_category', 'taxonomy'); |
| 53 |
$ancestors = array_reverse($ancestors); |
| 54 |
foreach ($ancestors as $anc_id) { |
| 55 |
$anc = get_term($anc_id, 'kng_doc_category'); |
| 56 |
if ($anc && !is_wp_error($anc)) { |
| 57 |
echo '<span class="kng-docs-breadcrumb-sep">/</span>'; |
| 58 |
echo '<a href="' . esc_url(get_term_link($anc)) . '" class="kng-docs-breadcrumb-item">' . esc_html($anc->name) . '</a>'; |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
?> |
| 63 |
|
| 64 |
<span class="kng-docs-breadcrumb-sep">/</span> |
| 65 |
<span class="kng-docs-breadcrumb-current"><?php echo esc_html($term->name); ?></span> |
| 66 |
</nav> |
| 67 |
|
| 68 |
<!-- ══════════════════════════════════════ |
| 69 |
CATEGORY / TAG HEADER |
| 70 |
══════════════════════════════════════ --> |
| 71 |
<div class="kng-docs-category-header-section kng-docs-reveal"> |
| 72 |
<div class="kng-docs-category-icon-large"> |
| 73 |
<?php echo $ext->get_icon_svg($icon_name); ?> |
| 74 |
</div> |
| 75 |
<h1 class="kng-docs-category-page-title"><?php echo esc_html($term->name); ?></h1> |
| 76 |
<?php if ($term->description) : ?> |
| 77 |
<p class="kng-docs-category-page-desc"><?php echo esc_html($term->description); ?></p> |
| 78 |
<?php endif; ?> |
| 79 |
<p class="kng-docs-category-page-count"> |
| 80 |
<?php printf( |
| 81 |
esc_html(_n('%d article', '%d articles', $term->count, 'king-addons')), |
| 82 |
$term->count |
| 83 |
); ?> |
| 84 |
</p> |
| 85 |
</div> |
| 86 |
|
| 87 |
<!-- ══════════════════════════════════════ |
| 88 |
SUBCATEGORIES |
| 89 |
══════════════════════════════════════ --> |
| 90 |
<?php if (!empty($children)) : ?> |
| 91 |
<div class="kng-docs-subcategories kng-docs-reveal"> |
| 92 |
<h2 class="kng-docs-subcategories-title"><?php esc_html_e('Subcategories', 'king-addons'); ?></h2> |
| 93 |
<div class="kng-docs-subcategories-grid"> |
| 94 |
<?php foreach ($children as $child) : |
| 95 |
$child_icon = get_term_meta($child->term_id, 'kng_doc_cat_icon', true) ?: 'folder'; |
| 96 |
?> |
| 97 |
<a href="<?php echo esc_url(get_term_link($child)); ?>" class="kng-docs-subcategory-card"> |
| 98 |
<span class="kng-docs-subcategory-icon"> |
| 99 |
<?php echo $ext->get_icon_svg($child_icon); ?> |
| 100 |
</span> |
| 101 |
<span class="kng-docs-subcategory-content"> |
| 102 |
<span class="kng-docs-subcategory-name"><?php echo esc_html($child->name); ?></span> |
| 103 |
<span class="kng-docs-subcategory-count"> |
| 104 |
<?php printf( |
| 105 |
esc_html(_n('%d article', '%d articles', $child->count, 'king-addons')), |
| 106 |
$child->count |
| 107 |
); ?> |
| 108 |
</span> |
| 109 |
</span> |
| 110 |
<svg class="kng-docs-subcategory-arrow" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"> |
| 111 |
<path d="m9 18 6-6-6-6"/> |
| 112 |
</svg> |
| 113 |
</a> |
| 114 |
<?php endforeach; ?> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
<?php endif; ?> |
| 118 |
|
| 119 |
<!-- ══════════════════════════════════════ |
| 120 |
ARTICLES LIST |
| 121 |
══════════════════════════════════════ --> |
| 122 |
<?php if (have_posts()) : ?> |
| 123 |
<div class="kng-docs-reveal"> |
| 124 |
<h2 class="kng-docs-articles-title"><?php esc_html_e('Articles', 'king-addons'); ?></h2> |
| 125 |
<ul class="kng-docs-articles"> |
| 126 |
<?php while (have_posts()) : the_post(); ?> |
| 127 |
<li> |
| 128 |
<a href="<?php the_permalink(); ?>" class="kng-docs-article-link"> |
| 129 |
<svg class="kng-docs-article-icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"> |
| 130 |
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/> |
| 131 |
<path d="M14 2v6h6"/> |
| 132 |
<path d="M16 13H8"/> |
| 133 |
<path d="M16 17H8"/> |
| 134 |
<path d="M10 9H8"/> |
| 135 |
</svg> |
| 136 |
<span class="kng-docs-article-info"> |
| 137 |
<span class="kng-docs-article-item-title"><?php the_title(); ?></span> |
| 138 |
<?php if (has_excerpt()) : ?> |
| 139 |
<span class="kng-docs-article-excerpt"><?php echo esc_html(get_the_excerpt()); ?></span> |
| 140 |
<?php endif; ?> |
| 141 |
</span> |
| 142 |
<span class="kng-docs-article-date"> |
| 143 |
<?php echo get_the_modified_date(); ?> |
| 144 |
</span> |
| 145 |
<svg class="kng-docs-article-arrow" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"> |
| 146 |
<path d="m9 18 6-6-6-6"/> |
| 147 |
</svg> |
| 148 |
</a> |
| 149 |
</li> |
| 150 |
<?php endwhile; ?> |
| 151 |
</ul> |
| 152 |
</div> |
| 153 |
|
| 154 |
<!-- Pagination --> |
| 155 |
<div class="kng-docs-pagination"> |
| 156 |
<?php |
| 157 |
the_posts_pagination([ |
| 158 |
'mid_size' => 2, |
| 159 |
'prev_text' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', |
| 160 |
'next_text' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', |
| 161 |
]); |
| 162 |
?> |
| 163 |
</div> |
| 164 |
<?php else : ?> |
| 165 |
<div class="kng-docs-empty kng-docs-reveal"> |
| 166 |
<svg fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"> |
| 167 |
<path d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m5.231 13.481L15 17.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v16.5c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Zm3.75 11.625a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z" stroke-linecap="round" stroke-linejoin="round"/> |
| 168 |
</svg> |
| 169 |
<h3><?php esc_html_e('No articles yet', 'king-addons'); ?></h3> |
| 170 |
<p><?php esc_html_e('There are no articles in this category yet.', 'king-addons'); ?></p> |
| 171 |
</div> |
| 172 |
<?php endif; ?> |
| 173 |
|
| 174 |
</div> |
| 175 |
</div> |
| 176 |
|
| 177 |
<?php get_footer(); ?> |
| 178 |
|