| 1 |
<?php |
| 2 |
/** |
| 3 |
* Docs Archive Template |
| 4 |
* |
| 5 |
* @package King_Addons |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
$docs_kb = \King_Addons\Docs_KB::instance(); |
| 13 |
$options = $docs_kb->get_options(); |
| 14 |
$layout = $options['layout'] ?? 'card'; |
| 15 |
$columns = $options['columns'] ?? 3; |
| 16 |
$search_enabled = !empty($options['search_enabled']); |
| 17 |
$primary_color = $options['primary_color'] ?? '#0066ff'; |
| 18 |
|
| 19 |
// Get categories with docs |
| 20 |
$categories = $docs_kb->get_categories_with_docs(); |
| 21 |
|
| 22 |
get_header(); |
| 23 |
?> |
| 24 |
|
| 25 |
<div class="kng-docs-page kng-docs-archive" data-layout="<?php echo esc_attr($layout); ?>"> |
| 26 |
<div class="kng-docs-container"> |
| 27 |
|
| 28 |
<!-- Hero Section --> |
| 29 |
<div class="kng-docs-hero"> |
| 30 |
<h1 class="kng-docs-hero-title"><?php echo esc_html($options['archive_title'] ?? __('Documentation', 'king-addons')); ?></h1> |
| 31 |
<p class="kng-docs-hero-subtitle"><?php echo esc_html($options['archive_subtitle'] ?? __('Find answers to your questions', 'king-addons')); ?></p> |
| 32 |
|
| 33 |
<?php if ($search_enabled): ?> |
| 34 |
<div class="kng-docs-search"> |
| 35 |
<div class="kng-docs-search-inner"> |
| 36 |
<svg class="kng-docs-search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| 37 |
<circle cx="11" cy="11" r="8"/> |
| 38 |
<path d="M21 21l-4.35-4.35"/> |
| 39 |
</svg> |
| 40 |
<input type="text" |
| 41 |
class="kng-docs-search-input" |
| 42 |
placeholder="<?php echo esc_attr($options['search_placeholder'] ?? __('Search documentation...', 'king-addons')); ?>" |
| 43 |
data-min-chars="<?php echo esc_attr($options['search_min_chars'] ?? 2); ?>" |
| 44 |
autocomplete="off"> |
| 45 |
<div class="kng-docs-search-loader" style="display: none;"> |
| 46 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| 47 |
<circle cx="12" cy="12" r="10" stroke-dasharray="60" stroke-linecap="round"/> |
| 48 |
</svg> |
| 49 |
</div> |
| 50 |
</div> |
| 51 |
<div class="kng-docs-search-results" style="display: none;"></div> |
| 52 |
</div> |
| 53 |
<?php endif; ?> |
| 54 |
</div> |
| 55 |
|
| 56 |
<?php if (empty($categories)): ?> |
| 57 |
<div class="kng-docs-empty"> |
| 58 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"> |
| 59 |
<path d="M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"/> |
| 60 |
</svg> |
| 61 |
<h3><?php esc_html_e('No documentation yet', 'king-addons'); ?></h3> |
| 62 |
<p><?php esc_html_e('Start by creating categories and adding articles.', 'king-addons'); ?></p> |
| 63 |
</div> |
| 64 |
<?php else: ?> |
| 65 |
|
| 66 |
<!-- Categories Grid --> |
| 67 |
<div class="kng-docs-categories kng-docs-layout-<?php echo esc_attr($layout); ?>" style="--kng-docs-columns: <?php echo esc_attr($columns); ?>; --kng-docs-primary: <?php echo esc_attr($primary_color); ?>;"> |
| 68 |
<?php foreach ($categories as $category): ?> |
| 69 |
<?php if ($layout === 'box'): ?> |
| 70 |
<!-- Box Layout --> |
| 71 |
<div class="kng-docs-category kng-docs-category-box"> |
| 72 |
<div class="kng-docs-category-header"> |
| 73 |
<?php if (!empty($options['show_category_icon']) && !empty($category['icon'])): ?> |
| 74 |
<div class="kng-docs-category-icon" style="--icon-color: <?php echo esc_attr($options['category_icon_color'] ?? $primary_color); ?>"> |
| 75 |
<?php echo \King_Addons\Docs_KB::get_icon_svg($category['icon']); ?> |
| 76 |
</div> |
| 77 |
<?php endif; ?> |
| 78 |
<a href="<?php echo esc_url($category['url']); ?>" class="kng-docs-category-title"> |
| 79 |
<?php echo esc_html($category['name']); ?> |
| 80 |
</a> |
| 81 |
<?php if (!empty($options['show_article_count'])): ?> |
| 82 |
<span class="kng-docs-category-count"><?php echo esc_html($category['count']); ?></span> |
| 83 |
<?php endif; ?> |
| 84 |
</div> |
| 85 |
<?php if (!empty($category['description'])): ?> |
| 86 |
<p class="kng-docs-category-desc"><?php echo esc_html($category['description']); ?></p> |
| 87 |
<?php endif; ?> |
| 88 |
<?php if (!empty($category['docs'])): ?> |
| 89 |
<ul class="kng-docs-category-list"> |
| 90 |
<?php foreach (array_slice($category['docs'], 0, 5) as $doc): ?> |
| 91 |
<li> |
| 92 |
<a href="<?php echo esc_url($doc['url']); ?>"> |
| 93 |
<?php echo esc_html($doc['title']); ?> |
| 94 |
</a> |
| 95 |
</li> |
| 96 |
<?php endforeach; ?> |
| 97 |
</ul> |
| 98 |
<?php if (count($category['docs']) > 5): ?> |
| 99 |
<a href="<?php echo esc_url($category['url']); ?>" class="kng-docs-category-more"> |
| 100 |
<?php printf(esc_html__('View all %d articles', 'king-addons'), $category['count']); ?> |
| 101 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg> |
| 102 |
</a> |
| 103 |
<?php endif; ?> |
| 104 |
<?php endif; ?> |
| 105 |
</div> |
| 106 |
|
| 107 |
<?php elseif ($layout === 'card'): ?> |
| 108 |
<!-- Card Layout --> |
| 109 |
<a href="<?php echo esc_url($category['url']); ?>" class="kng-docs-category kng-docs-category-card"> |
| 110 |
<?php if (!empty($options['show_category_icon']) && !empty($category['icon'])): ?> |
| 111 |
<div class="kng-docs-category-icon" style="--icon-color: <?php echo esc_attr($options['category_icon_color'] ?? $primary_color); ?>"> |
| 112 |
<?php echo \King_Addons\Docs_KB::get_icon_svg($category['icon']); ?> |
| 113 |
</div> |
| 114 |
<?php endif; ?> |
| 115 |
<h3 class="kng-docs-category-title"><?php echo esc_html($category['name']); ?></h3> |
| 116 |
<?php if (!empty($category['description'])): ?> |
| 117 |
<p class="kng-docs-category-desc"><?php echo esc_html($category['description']); ?></p> |
| 118 |
<?php endif; ?> |
| 119 |
<?php if (!empty($options['show_article_count'])): ?> |
| 120 |
<span class="kng-docs-category-count"> |
| 121 |
<?php printf(esc_html(_n('%d article', '%d articles', $category['count'], 'king-addons')), $category['count']); ?> |
| 122 |
</span> |
| 123 |
<?php endif; ?> |
| 124 |
</a> |
| 125 |
|
| 126 |
<?php else: ?> |
| 127 |
<!-- Modern Layout --> |
| 128 |
<a href="<?php echo esc_url($category['url']); ?>" class="kng-docs-category kng-docs-category-modern"> |
| 129 |
<?php if (!empty($options['show_category_icon']) && !empty($category['icon'])): ?> |
| 130 |
<div class="kng-docs-category-icon" style="--icon-color: <?php echo esc_attr($options['category_icon_color'] ?? $primary_color); ?>"> |
| 131 |
<?php echo \King_Addons\Docs_KB::get_icon_svg($category['icon']); ?> |
| 132 |
</div> |
| 133 |
<?php endif; ?> |
| 134 |
<div class="kng-docs-category-content"> |
| 135 |
<h3 class="kng-docs-category-title"><?php echo esc_html($category['name']); ?></h3> |
| 136 |
<?php if (!empty($category['description'])): ?> |
| 137 |
<p class="kng-docs-category-desc"><?php echo esc_html($category['description']); ?></p> |
| 138 |
<?php endif; ?> |
| 139 |
<?php if (!empty($options['show_article_count'])): ?> |
| 140 |
<span class="kng-docs-category-count"> |
| 141 |
<?php printf(esc_html(_n('%d article', '%d articles', $category['count'], 'king-addons')), $category['count']); ?> |
| 142 |
</span> |
| 143 |
<?php endif; ?> |
| 144 |
</div> |
| 145 |
<svg class="kng-docs-category-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg> |
| 146 |
</a> |
| 147 |
<?php endif; ?> |
| 148 |
<?php endforeach; ?> |
| 149 |
</div> |
| 150 |
<?php endif; ?> |
| 151 |
|
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
<?php get_footer(); ?> |
| 156 |
|