diff --git a/assets/css/routes/archives.css b/assets/css/routes/archives.css
new file mode 100644
index 00000000..6c151e25
--- /dev/null
+++ b/assets/css/routes/archives.css
@@ -0,0 +1,83 @@
+/**
+ * Archives page (zibll archives) styles.
+ *
+ * @package AKSRT
+ */
+
+.page-template-archives .content-wrap {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 20px;
+}
+
+.page-template-archives .content-layout {
+ flex: 1 1 0;
+ min-width: 0;
+}
+
+.page-template-archives .sidebar {
+ flex: 0 0 300px;
+ max-width: 100%;
+}
+
+.archives-month-list {
+ list-style: none;
+ margin: 0;
+ padding: 0 8px 8px;
+ display: flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+}
+
+.archives-month-list .author-set-left {
+ width: 3.2em;
+ flex: 0 0 3.2em;
+ padding: 6px 0;
+ font-size: 13px;
+}
+
+.archives-month-list .author-set-right {
+ flex: 1 1 calc(100% - 3.5em);
+ min-width: 0;
+ padding: 6px 0;
+ border-bottom: 1px dashed var(--main-border-color, rgba(0, 0, 0, 0.06));
+}
+
+.archives-month-list .author-set-right a {
+ color: inherit;
+ text-decoration: none;
+}
+
+.archives-month-list .author-set-right a:hover {
+ color: var(--focus-color, var(--color-primary));
+}
+
+.title-h-center {
+ position: relative;
+ padding-bottom: 8px;
+ margin: 12px 0 10px;
+ text-align: center;
+}
+
+.title-h-center:before {
+ content: '';
+ position: absolute;
+ left: 0;
+ right: 0;
+ margin: auto;
+ bottom: 3px;
+ width: 40px;
+ height: 3px;
+ border-radius: 5px;
+ background: var(--theme-color, var(--color-primary));
+}
+
+.ml6 {
+ margin-left: 6px;
+}
+
+@media (max-width: 991px) {
+ .page-template-archives .sidebar {
+ flex: 1 1 100%;
+ }
+}
diff --git a/assets/css/routes/documentnav.css b/assets/css/routes/documentnav.css
new file mode 100644
index 00000000..72488b65
--- /dev/null
+++ b/assets/css/routes/documentnav.css
@@ -0,0 +1,240 @@
+/**
+ * Document navigation page (zibll documentnav) styles.
+ *
+ * @package AKSRT
+ */
+
+.page-template-documentnav .document-nav-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 16px;
+ margin: 0;
+}
+
+.page-template-documentnav .document-nav-aside {
+ flex: 0 0 32%;
+ max-width: 100%;
+ min-width: 220px;
+}
+
+.page-template-documentnav .document-nav-main {
+ flex: 1 1 0;
+ min-width: 0;
+}
+
+.document-nav .panel-group {
+ margin: 0;
+}
+
+.document-nav .panel {
+ border: none;
+ box-shadow: none;
+ border-top: 1px solid var(--main-border-color, #eee);
+}
+
+.document-nav .panel-title {
+ margin: 0;
+ font-size: 1em;
+}
+
+.document-nav .panel-toggle {
+ padding: 10px;
+ display: block;
+ color: inherit;
+ text-decoration: none;
+}
+
+.document-nav .panel-toggle:not(.collapsed) {
+ color: var(--focus-color, var(--color-primary));
+}
+
+.document-nav .panel-toggle .fa {
+ transition: transform 0.2s;
+}
+
+.document-nav .panel-toggle:not(.collapsed) .fa {
+ transform: rotate(90deg);
+}
+
+.document-nav .panel-collapse {
+ display: none;
+}
+
+.document-nav .panel-collapse.is-open,
+.document-nav .panel-collapse.in {
+ display: block;
+}
+
+.document-nav .panel-child,
+.document-nav .category {
+ padding-left: 15px;
+}
+
+.document-nav .cat-load {
+ padding: 10px;
+ display: block;
+ color: inherit;
+ text-decoration: none;
+ position: relative;
+}
+
+.document-nav > .panel-group > .cat-load {
+ padding-left: 2px;
+}
+
+.document-nav > .panel-group > .cat-load::before {
+ content: '';
+ width: 0.5em;
+ height: 0.5em;
+ border: 0.1em solid var(--focus-color, var(--color-primary));
+ border-radius: 1em;
+ margin: 0 0.5em;
+ vertical-align: 0.1em;
+ display: inline-block;
+}
+
+.document-nav .cat-load.active {
+ background: var(--main-border-color, rgba(0, 0, 0, 0.06));
+ color: var(--focus-color, var(--color-primary));
+ border-radius: 4px;
+}
+
+.document-nav .loading {
+ overflow: hidden;
+ width: 0;
+ opacity: 0;
+ transition: 0.3s;
+ display: inline-block;
+}
+
+.document-nav .is-loading .loading,
+.document-nav .cat-load.is-loading .loading {
+ width: 0.7em;
+ opacity: 1;
+ margin-right: 6px;
+}
+
+.document-nav-container {
+ transition: 0.3s;
+ min-height: 120px;
+}
+
+.document-nav-container.is-loading {
+ opacity: 0.55;
+ pointer-events: none;
+}
+
+.document-search {
+ position: relative;
+ margin-bottom: 16px;
+ padding: 12px;
+}
+
+.document-search .line-form {
+ position: relative;
+}
+
+.document-search .line-form-input {
+ width: 100%;
+ border: 1px solid var(--main-border-color, #ddd);
+ border-radius: 8px;
+ padding: 10px 40px 10px 12px;
+ box-sizing: border-box;
+ background: var(--main-bg-color, #fff);
+}
+
+.document-search .abs-right {
+ position: absolute;
+ right: 8px;
+ top: 50%;
+ transform: translateY(-50%);
+ border: 0;
+ background: transparent;
+ cursor: pointer;
+ color: var(--muted-2-color, #888);
+}
+
+.document-search .search-loading {
+ inset: 0;
+ display: none;
+ align-items: center;
+ justify-content: center;
+ border-radius: 8px;
+ background: color-mix(in srgb, var(--main-bg-color, #fff) 88%, transparent);
+ z-index: 2;
+}
+
+.document-search.is-loading .search-loading {
+ display: flex;
+}
+
+.list-group {
+ border-radius: 8px;
+ overflow: hidden;
+}
+
+.list-group-item {
+ display: block;
+ padding: 12px 14px;
+ background: var(--main-bg-color, #fff);
+ border-bottom: 1px solid var(--muted-border-color, #eee);
+ color: var(--main-color, inherit);
+ text-decoration: none;
+}
+
+.list-group-item:last-child {
+ border-bottom: 0;
+}
+
+a.list-group-item:hover,
+a.list-group-item:focus {
+ background: var(--body-bg-color, #f7f7f8);
+ color: var(--focus-color, var(--color-primary));
+}
+
+.list-group-item .pull-right {
+ float: right;
+}
+
+.list-group-item .badg-sm {
+ font-size: 12px;
+ opacity: 0.75;
+}
+
+.list-group-item .focus-color {
+ color: var(--focus-color, var(--color-primary));
+}
+
+.document-nav-container .pagenav a {
+ display: inline-block;
+ min-width: 32px;
+ padding: 4px 8px;
+ margin: 2px;
+ border-radius: 4px;
+ text-decoration: none;
+ color: inherit;
+ background: var(--surface-2, #f0f0f0);
+}
+
+.document-nav-container .pagenav a.current {
+ background: var(--focus-color, var(--color-primary));
+ color: #fff;
+}
+
+.history-search .search_keywords {
+ display: inline-block;
+ margin: 0 6px 6px 0;
+ padding: 2px 8px;
+ border-radius: 999px;
+ background: var(--surface-2, #f0f0f0);
+ color: inherit;
+ text-decoration: none;
+ font-size: 12px;
+}
+
+@media (max-width: 767px) {
+ .page-template-documentnav .document-nav-aside,
+ .page-template-documentnav .document-nav-main {
+ flex: 1 1 100%;
+ }
+}
diff --git a/assets/js/documentnav-page.js b/assets/js/documentnav-page.js
new file mode 100644
index 00000000..210b3cb2
--- /dev/null
+++ b/assets/js/documentnav-page.js
@@ -0,0 +1,197 @@
+/**
+ * Document navigation AJAX (zibll page-template documentnav subset).
+ *
+ * @package AKSRT
+ */
+(function () {
+ 'use strict';
+
+ function ajaxUrl() {
+ if (window.aksrtData && window.aksrtData.ajaxUrl) return window.aksrtData.ajaxUrl;
+ return '/wp-admin/admin-ajax.php';
+ }
+
+ function toast(msg, type) {
+ if (window.aksrt && typeof window.aksrt.toast === 'function') {
+ window.aksrt.toast(msg, type || 'info');
+ return;
+ }
+ // eslint-disable-next-line no-alert
+ window.alert(msg);
+ }
+
+ function qs(sel, root) {
+ return (root || document).querySelector(sel);
+ }
+
+ function qsa(sel, root) {
+ return Array.prototype.slice.call((root || document).querySelectorAll(sel));
+ }
+
+ function documentAjax(triggerEl, data, url) {
+ var container = qs('.document-nav-container');
+ var searchBox = qs('.document-search');
+ if (!container) return;
+
+ container.classList.add('is-loading');
+ if (searchBox && data && data.search) searchBox.classList.add('is-loading');
+
+ data = data || {};
+ data.one_cat = container.getAttribute('data-one-cat') || '';
+ data.action = 'aksrt_documentnav_posts';
+
+ var body = new URLSearchParams();
+ Object.keys(data).forEach(function (k) {
+ if (data[k] !== undefined && data[k] !== null) body.append(k, data[k]);
+ });
+
+ fetch(url || ajaxUrl(), {
+ method: 'POST',
+ credentials: 'same-origin',
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
+ body: body.toString(),
+ })
+ .then(function (r) { return r.json(); })
+ .then(function (n) {
+ if (!n || n.error || !n.html) {
+ toast((n && n.msg) || '加载失败,请重试', 'danger');
+ }
+ if (n && n.html) container.innerHTML = n.html;
+ if (n && n.history_search) {
+ var hist = qs('.history-search > div');
+ if (hist) hist.innerHTML = n.history_search;
+ }
+ })
+ .catch(function () {
+ toast('网络错误', 'danger');
+ })
+ .finally(function () {
+ container.classList.remove('is-loading');
+ if (searchBox) searchBox.classList.remove('is-loading');
+ if (triggerEl && triggerEl.classList) triggerEl.classList.remove('is-loading');
+ });
+ }
+
+ function initAccordion() {
+ var nav = qs('.document-nav');
+ if (!nav) return;
+ nav.addEventListener('click', function (e) {
+ var toggle = e.target.closest('.panel-toggle[data-toggle="collapse"]');
+ if (!toggle) return;
+ e.preventDefault();
+ var targetSel = toggle.getAttribute('data-target');
+ var panel = targetSel ? qs(targetSel, nav) : null;
+ if (!panel) return;
+ var parentSel = toggle.getAttribute('data-parent');
+ if (parentSel) {
+ var parent = qs(parentSel, nav);
+ if (parent) {
+ qsa('.panel-collapse.is-open, .panel-collapse.in', parent).forEach(function (p) {
+ if (p !== panel) {
+ p.classList.remove('is-open', 'in');
+ var t = parent.querySelector('[data-target="#' + p.id + '"]');
+ if (t) t.classList.add('collapsed');
+ }
+ });
+ }
+ }
+ var open = panel.classList.contains('is-open') || panel.classList.contains('in');
+ if (open) {
+ panel.classList.remove('is-open', 'in');
+ toggle.classList.add('collapsed');
+ } else {
+ panel.classList.add('is-open', 'in');
+ toggle.classList.remove('collapsed');
+ }
+ });
+ }
+
+ function initSearch() {
+ var form = qs('.document-search-form');
+ if (!form) return;
+ form.addEventListener('submit', function (e) {
+ e.preventDefault();
+ var input = form.querySelector('[name="s"]');
+ var search = input ? String(input.value || '').trim() : '';
+ if (!search.length) {
+ toast('请输入搜索关键词', 'warning');
+ return;
+ }
+ if (search.length < 2) {
+ toast('关键词太短', 'warning');
+ return;
+ }
+ qsa('.cat-load').forEach(function (el) {
+ el.classList.remove('is-loading', 'active');
+ });
+ documentAjax(qs('.document-search'), { search: search });
+ });
+
+ document.addEventListener('click', function (e) {
+ var kw = e.target.closest('.document-search .search_keywords');
+ if (!kw) return;
+ e.preventDefault();
+ var text = (kw.textContent || '').trim();
+ var input = qs('.document-search-form [name="s"]');
+ if (input) {
+ input.value = text;
+ input.dispatchEvent(new Event('input', { bubbles: true }));
+ }
+ if (form) form.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true }));
+ });
+ }
+
+ function initCatLoad() {
+ document.addEventListener('click', function (e) {
+ var a = e.target.closest('.cat-load');
+ if (!a) return;
+ e.preventDefault();
+ qsa('.cat-load').forEach(function (el) {
+ el.classList.remove('is-loading', 'active');
+ });
+ a.classList.add('is-loading', 'active');
+ var catId = a.getAttribute('data-cat-id') || a.getAttribute('cat-id') || '';
+ documentAjax(a, { cat_id: catId });
+ });
+ }
+
+ function initPager() {
+ document.addEventListener('click', function (e) {
+ var a = e.target.closest('.document-nav-container .pagenav a');
+ if (!a) return;
+ e.preventDefault();
+ var paged = a.getAttribute('data-paged') || '';
+ var href = a.getAttribute('href') || '';
+ if (paged) {
+ // Prefer current context from last active cat or search.
+ var active = qs('.cat-load.active');
+ var searchInput = qs('.document-search-form [name="s"]');
+ var data = { paged: paged };
+ if (active) {
+ data.cat_id = active.getAttribute('data-cat-id') || '';
+ } else if (searchInput && searchInput.value) {
+ data.search = searchInput.value.trim();
+ }
+ documentAjax(a, data);
+ return;
+ }
+ if (href && href.indexOf('admin-ajax.php') !== -1) {
+ documentAjax(a, {}, href);
+ }
+ });
+ }
+
+ function init() {
+ if (!qs('.document-nav-container') && !qs('.document-nav')) return;
+ initAccordion();
+ initSearch();
+ initCatLoad();
+ initPager();
+ }
+
+ if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', init);
+ } else {
+ init();
+ }
+})();
diff --git a/functions.php b/functions.php
index 5a9f176e..73358825 100644
--- a/functions.php
+++ b/functions.php
@@ -261,6 +261,9 @@ if (class_exists('\AKSRT\Core\PostsNavs')) {
if (class_exists('\AKSRT\User\AuthApply')) {
\AKSRT\User\AuthApply::get_instance()->init();
}
+if (class_exists('\AKSRT\Core\DocumentNav')) {
+ \AKSRT\Core\DocumentNav::get_instance()->init();
+}
if (class_exists('\AKSRT\Messages\SiteNotice')) {
\AKSRT\Messages\SiteNotice::get_instance()->init();
}
diff --git a/src/AKSRT/Core/DocumentNav.php b/src/AKSRT/Core/DocumentNav.php
new file mode 100644
index 00000000..c2c749f3
--- /dev/null
+++ b/src/AKSRT/Core/DocumentNav.php
@@ -0,0 +1,316 @@
+ $cat,
+ 'initial_content' => $initial,
+ ];
+ }
+
+ /**
+ * Render posts list HTML (zibll zib_get_documentnav_posts).
+ */
+ public static function render_posts_html(\WP_Query $query): string {
+ if (!$query->have_posts()) {
+ $empty = function_exists('aksrt_get_null')
+ ? aksrt_get_null(__('暂无相应内容', 'aksrt'), 40)
+ : '
' . esc_html__('暂无相应内容', 'aksrt') . '
';
+ return '' . $empty . '
';
+ }
+
+ $html = '';
+ while ($query->have_posts()) {
+ $query->the_post();
+ $time_ago = human_time_diff(get_the_time('U'), current_time('timestamp')) . __('前', 'aksrt');
+ $subtitle = (string) get_post_meta(get_the_ID(), 'subtitle', true);
+ if ($subtitle === '') {
+ $subtitle = (string) get_post_meta(get_the_ID(), 'aksrt_subtitle', true);
+ }
+ $html .= '
';
+ $html .= '' . esc_html($time_ago) . '';
+ $html .= esc_html(get_the_title());
+ if ($subtitle !== '') {
+ $html .= ' ' . esc_html($subtitle) . '';
+ }
+ $html .= '';
+ }
+ $html .= '
';
+ wp_reset_postdata();
+ return $html;
+ }
+
+ /**
+ * Simple paginate links for document nav container.
+ */
+ public static function render_paginate(int $total, int $current, int $page_size, array $args = []): string {
+ $max = (int) ceil(max(0, $total) / max(1, $page_size));
+ if ($max <= 1) {
+ return '';
+ }
+ $current = max(1, min($current, $max));
+ $html = '';
+ for ($i = 1; $i <= $max; $i++) {
+ $url = add_query_arg(array_merge($args, ['paged' => $i]));
+ $cls = $i === $current ? 'current' : '';
+ $html .= '
' . (int) $i . ' ';
+ }
+ $html .= '
';
+ return $html;
+ }
+
+ /**
+ * Recursive category accordion HTML.
+ */
+ public static function render_panels(int $cat_id, string $data_parent = 'accordion', string $class = 'panel', bool &$is_on_open = true): string {
+ if ($cat_id <= 0) {
+ return '';
+ }
+ $terms = _get_term_hierarchy('category');
+ if (empty($terms[$cat_id]) || !is_array($terms[$cat_id])) {
+ return '';
+ }
+
+ $html = '';
+ foreach ($terms[$cat_id] as $child) {
+ $child = (int) $child;
+ if ($child === $cat_id) {
+ continue;
+ }
+ $cat_obj = get_category($child);
+ if (!$cat_obj || is_wp_error($cat_obj)) {
+ continue;
+ }
+ $has_kids = !empty($terms[$child]);
+ if ($has_kids) {
+ $open = $is_on_open;
+ $is_on_open = false;
+ $html .= '
';
+ $html .= '
';
+ $html .= '
';
+ $html .= '
';
+ $html .= self::render_panels($child, 'dosc-cat-nav-panel-' . $child, 'panel panel-child', $is_on_open);
+ $html .= '
';
+ } else {
+ $html .= '
';
+ $html .= '' . esc_html($cat_obj->name);
+ $html .= '';
+ }
+ }
+ $html .= '
';
+ return $html;
+ }
+
+ public function ajax_posts(): void {
+ $search = isset($_REQUEST['search']) ? sanitize_text_field(wp_unslash((string) $_REQUEST['search'])) : '';
+ $cat_id = isset($_REQUEST['cat_id']) ? absint($_REQUEST['cat_id']) : 0;
+ $one_cat = isset($_REQUEST['one_cat']) ? absint($_REQUEST['one_cat']) : 0;
+ $paged = isset($_REQUEST['paged']) ? max(1, absint($_REQUEST['paged'])) : 1;
+ $page_size = 12;
+
+ if ($search === '' && $cat_id <= 0) {
+ wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('参数传入错误!', 'aksrt')]);
+ }
+
+ $args = [
+ 'ignore_sticky_posts' => true,
+ 'paged' => $paged,
+ 'posts_per_page' => $page_size,
+ 'post_status' => 'publish',
+ 'post_type' => 'post',
+ ];
+
+ if ($search !== '') {
+ $args['s'] = $search;
+ $args['cat'] = $one_cat > 0 ? $one_cat : 0;
+ // Persist simple history (user meta or cookie-less option list is optional).
+ $this->remember_search($search);
+ } else {
+ $args['cat'] = $cat_id;
+ }
+
+ $query = new \WP_Query($args);
+ $html = self::render_posts_html($query);
+ $html .= self::render_paginate(
+ (int) $query->found_posts,
+ $paged,
+ $page_size,
+ [
+ 'action' => 'aksrt_documentnav_posts',
+ 'cat_id' => $cat_id,
+ 'search' => $search,
+ 'one_cat' => $one_cat,
+ ]
+ );
+
+ wp_send_json([
+ 'error' => 0,
+ 'html' => $html,
+ 'total' => (int) $query->found_posts,
+ 'history_search' => $this->history_buttons_html(),
+ ]);
+ }
+
+ private function remember_search(string $term): void {
+ $term = trim($term);
+ if ($term === '' || mb_strlen($term) < 2) {
+ return;
+ }
+ $key = is_user_logged_in() ? 'aksrt_doc_search_history_' . get_current_user_id() : '';
+ $list = [];
+ if ($key !== '') {
+ $saved = get_user_meta(get_current_user_id(), 'aksrt_doc_search_history', true);
+ $list = is_array($saved) ? $saved : [];
+ } else {
+ $cookie = isset($_COOKIE['aksrt_doc_search_history']) ? wp_unslash((string) $_COOKIE['aksrt_doc_search_history']) : '';
+ $decoded = json_decode($cookie, true);
+ $list = is_array($decoded) ? $decoded : [];
+ }
+ $list = array_values(array_unique(array_filter(array_map('strval', $list))));
+ array_unshift($list, $term);
+ $list = array_slice(array_values(array_unique($list)), 0, 8);
+ if ($key !== '') {
+ update_user_meta(get_current_user_id(), 'aksrt_doc_search_history', $list);
+ } elseif (!headers_sent()) {
+ setcookie('aksrt_doc_search_history', wp_json_encode($list), time() + WEEK_IN_SECONDS, COOKIEPATH ?: '/', COOKIE_DOMAIN, is_ssl(), true);
+ }
+ }
+
+ /**
+ * @return list
+ */
+ private function get_history(): array {
+ if (is_user_logged_in()) {
+ $saved = get_user_meta(get_current_user_id(), 'aksrt_doc_search_history', true);
+ return is_array($saved) ? array_values(array_filter(array_map('strval', $saved))) : [];
+ }
+ $cookie = isset($_COOKIE['aksrt_doc_search_history']) ? wp_unslash((string) $_COOKIE['aksrt_doc_search_history']) : '';
+ $decoded = json_decode($cookie, true);
+ return is_array($decoded) ? array_values(array_filter(array_map('strval', $decoded))) : [];
+ }
+
+ public function history_buttons_html(): string {
+ $items = $this->get_history();
+ if (!$items) {
+ return '';
+ }
+ $html = '';
+ foreach ($items as $term) {
+ $html .= '' . esc_html($term) . '';
+ }
+ return $html;
+ }
+
+ public function register_meta_box(): void {
+ add_meta_box(
+ 'aksrt_documentnav_meta',
+ __('文档导航设置', 'aksrt'),
+ [$this, 'render_meta_box'],
+ 'page',
+ 'side',
+ 'default'
+ );
+ }
+
+ public function render_meta_box(\WP_Post $post): void {
+ $tpl = (string) get_post_meta($post->ID, '_wp_page_template', true);
+ if ($tpl !== 'templates/pages/page-documentnav.php') {
+ echo '' . esc_html__('将模板设为「AKSRT - 文档导航」后配置。', 'aksrt') . '
';
+ return;
+ }
+ $opt = self::get_options((int) $post->ID);
+ wp_nonce_field('aksrt_documentnav_meta', 'aksrt_documentnav_meta_nonce');
+ $cats = get_categories(['hide_empty' => false, 'parent' => 0]);
+ ?>
+
+
+
+
+
+
+
+
+ $cat,
+ 'initial_content' => $initial,
+ ]);
+ }
+}
diff --git a/src/AKSRT/Core/ScriptsPart1b.php b/src/AKSRT/Core/ScriptsPart1b.php
index 18bcd8a0..e711029a 100644
--- a/src/AKSRT/Core/ScriptsPart1b.php
+++ b/src/AKSRT/Core/ScriptsPart1b.php
@@ -458,6 +458,42 @@ trait ScriptsPart1b {
}
}
+ // 文章归档页
+ if (is_page_template('templates/pages/page-archives.php')) {
+ $ar_css = get_template_directory() . '/assets/css/routes/archives.css';
+ if (file_exists($ar_css)) {
+ wp_enqueue_style(
+ 'aksrt-route-archives',
+ $base_uri . '/assets/css/routes/archives.css',
+ ['aksrt-tokens'],
+ (string) filemtime($ar_css)
+ );
+ }
+ }
+
+ // 文档导航页(zibll documentnav.php)
+ if (is_page_template('templates/pages/page-documentnav.php')) {
+ $dn_css = get_template_directory() . '/assets/css/routes/documentnav.css';
+ if (file_exists($dn_css)) {
+ wp_enqueue_style(
+ 'aksrt-route-documentnav',
+ $base_uri . '/assets/css/routes/documentnav.css',
+ ['aksrt-tokens'],
+ (string) filemtime($dn_css)
+ );
+ }
+ $dn_js = get_template_directory() . '/assets/js/documentnav-page.js';
+ if (file_exists($dn_js)) {
+ wp_enqueue_script(
+ 'aksrt-documentnav-page',
+ $base_uri . '/assets/js/documentnav-page.js',
+ [],
+ (string) filemtime($dn_js),
+ true
+ );
+ }
+ }
+
// 用户身份认证页(zibll user-auth.php)
if (is_page_template('templates/pages/page-user-auth.php')) {
$ua_css = get_template_directory() . '/assets/css/routes/user-auth.css';
diff --git a/src/AKSRT/Core/Templates.php b/src/AKSRT/Core/Templates.php
index e653710f..717564c2 100644
--- a/src/AKSRT/Core/Templates.php
+++ b/src/AKSRT/Core/Templates.php
@@ -40,6 +40,7 @@ class Templates {
'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'),
'templates/pages/page-user-home.php' => __('AKSRT - 用户主页', 'aksrt'),
'templates/pages/page-archives.php' => __('AKSRT - 文章归档', 'aksrt'),
+ 'templates/pages/page-documentnav.php' => __('AKSRT - 文档导航', 'aksrt'),
'templates/pages/page-categories.php' => __('AKSRT - 分类汇总', 'aksrt'),
'templates/pages/page-newposts.php' => __('AKSRT - 最新文章', 'aksrt'),
// 注意:page-newposts = 最新文章列表;投稿页是 page-submit(写文章/投稿)
diff --git a/templates/pages/page-archives.php b/templates/pages/page-archives.php
index 1e83c718..ef4954f2 100644
--- a/templates/pages/page-archives.php
+++ b/templates/pages/page-archives.php
@@ -1,9 +1,10 @@
'site-main container content-shell content-shell--page page-content-default',
- 'has_sidebar' => false,
- 'page_kind' => 'archives',
- ]);
-}
+$header_style = (string) get_post_meta(get_queried_object_id(), 'page_header_style', true);
?>
-
- esc_html__('文章归档', 'aksrt'),
- ]);
- ?>
+
+
+
+
+
+
+
+
-
- get_results(
- "SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, COUNT(*) AS count
- FROM {$wpdb->posts}
- WHERE post_type = 'post' AND post_status = 'publish'
- GROUP BY YEAR(post_date), MONTH(post_date)
- ORDER BY year DESC, month DESC"
- ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
-
- $current_year = 0;
- foreach ($years as $row) :
- if ((int) $row->year !== $current_year) :
- $current_year = (int) $row->year;
- ?>
-
-
-
- month, (int) $row->count)); ?>
-
-
- (int) $row->year,
- 'monthnum' => (int) $row->month,
- 'posts_per_page' => -1,
- 'post_status' => 'publish',
- ]);
- foreach ($month_posts as $mp) :
- ?>
- -
-
- post_title); ?>
-
-
-
-
-
+
+
+
+
- false]);
-}
+
+
+ -1,
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ 'post_status' => 'publish',
+ 'post_type' => 'post',
+ 'suppress_filters' => false,
+ ]);
+
+ foreach ($myposts as $post) :
+ setup_postdata($post);
+ $year = (int) get_the_time('Y', $post);
+ $month = (int) get_the_time('n', $post);
+ $day = (int) get_the_time('j', $post);
+
+ if ($year !== $previous_year || $month !== $previous_month) :
+ if ($ul_open) {
+ echo '';
+ }
+ echo '
';
+ }
+ if (empty($myposts)) {
+ echo '
' . esc_html__('暂无文章', 'aksrt') . '
';
+ }
+ ?>
+
+
+
+
+
+
+
+
+ 0, 'initial_content' => 'updated_posts'];
+$one_cat = (int) ($opt['cat'] ?? 0);
+$initial = (string) ($opt['initial_content'] ?? 'updated_posts');
+
get_header();
-
-// Read doc mode settings
-$doc_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_docs_mode_settings() : [];
-$default_order = $doc_settings['default_order'] ?? 'menu_order';
-
-$presenter = class_exists('\AKSRT\Core\DocsPresenter') ? \AKSRT\Core\DocsPresenter::get_instance() : null;
-
-// Get root-level pages
-$pages = $presenter
- ? $presenter->get_root_pages($default_order)
- : get_pages([
- 'sort_column' => $default_order === 'title' ? 'post_title' : ($default_order === 'date' ? 'post_date' : 'menu_order, post_title'),
- 'sort_order' => 'ASC',
- 'parent' => 0,
- 'hierarchical' => 0,
- 'post_status' => 'publish',
- ]);
-
-// Recent updates
-$recent_pages = $presenter
- ? $presenter->get_recent_pages(8)
- : get_pages([
- 'sort_column' => 'post_modified',
- 'sort_order' => 'DESC',
- 'number' => 8,
- 'post_status' => 'publish',
- ]);
-
-$show_sidebar = !empty($doc_settings['toc_enabled']) || !empty($recent_pages);
?>
+
+
+
+
+
+
-
+
+
+
+
-
+
+ ';
+ echo '
';
+ the_content();
+ echo '';
+ }
+ } elseif ($one_cat > 0 && class_exists(DocumentNav::class)) {
+ $args = [
+ 'cat' => $one_cat,
+ 'order' => 'DESC',
+ 'orderby' => 'modified',
+ 'posts_per_page' => 12,
+ 'no_found_rows' => true,
+ 'ignore_sticky_posts' => true,
+ 'post_status' => 'publish',
+ ];
+ if ($initial === 'date_posts') {
+ $args['orderby'] = 'date';
+ } elseif ($initial === 'views_posts') {
+ $args['orderby'] = 'meta_value_num';
+ $args['meta_key'] = 'aksrt_post_views';
+ }
+ $q = new WP_Query($args);
+ echo DocumentNav::render_posts_html($q); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ } else {
+ echo '
';
+ }
+ ?>
+
+
+
-
+
-