From 8849540fda890c5af84306c6b231b6945be1d8fa Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Jul 2026 23:05:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E7=94=A8=E9=A1=B5=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=20content-shell=EF=BC=8C=E5=B9=B6=E5=88=A0=20page-header=20que?= =?UTF-8?q?ry-var=20=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit archives/friends/newposts/posts-navs/categories 统一壳层与 page-header 契约, 主路径不再保留 aksrt_ph_* ambient 传参。 --- templates/pages/page-archives.php | 105 +++++++++++++++------------- templates/pages/page-categories.php | 49 +++++++------ templates/pages/page-friends.php | 89 ++++++++++++----------- templates/pages/page-newposts.php | 83 +++++++++++----------- templates/pages/page-posts-navs.php | 84 +++++++++++----------- templates/parts/page-header.php | 28 ++------ 6 files changed, 228 insertions(+), 210 deletions(-) diff --git a/templates/pages/page-archives.php b/templates/pages/page-archives.php index b73a017e..1e83c718 100644 --- a/templates/pages/page-archives.php +++ b/templates/pages/page-archives.php @@ -12,57 +12,64 @@ defined('ABSPATH') || exit; get_header(); global $wpdb; + +if (function_exists('aksrt_archive_open_shell')) { + aksrt_archive_open_shell([ + 'main_class' => 'site-main container content-shell content-shell--page page-content-default', + 'has_sidebar' => false, + 'page_kind' => 'archives', + ]); +} ?> +
+ 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); ?> -
  • - -
- -
-
-
-
+
+ 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]); +} + get_footer(); diff --git a/templates/pages/page-categories.php b/templates/pages/page-categories.php index 25cf8c4e..304a31cf 100644 --- a/templates/pages/page-categories.php +++ b/templates/pages/page-categories.php @@ -46,26 +46,31 @@ if ($page_title === '') { } ?> -
- + 'site-main container content-shell content-shell--page', + 'has_sidebar' => false, + 'page_kind' => 'categories', + ]); +} +?> +
+ + esc_html($page_title), + 'desc' => $cats_meta, + ]); + ?> - - - +
term_id; @@ -124,7 +129,11 @@ if ($page_title === '') {

-
+ false]); +} + get_footer(); diff --git a/templates/pages/page-friends.php b/templates/pages/page-friends.php index 0a71ef07..060b7631 100644 --- a/templates/pages/page-friends.php +++ b/templates/pages/page-friends.php @@ -11,51 +11,56 @@ defined('ABSPATH') || exit; get_header(); $links = function_exists('aksrt_get_friend_links') ? aksrt_get_friend_links() : []; + +if (function_exists('aksrt_archive_open_shell')) { + aksrt_archive_open_shell([ + 'main_class' => 'site-main container content-shell content-shell--page page-content-default', + 'has_sidebar' => false, + 'page_kind' => 'friends', + ]); +} ?> +
+ esc_html__('友情链接', 'aksrt'), + 'desc' => __('与这些优秀的站点交换友链', 'aksrt'), + ]); + ?> -
- + + + +
+

+
+ - -
- false]); +} + get_footer(); diff --git a/templates/pages/page-newposts.php b/templates/pages/page-newposts.php index 635f9241..7ca132b6 100644 --- a/templates/pages/page-newposts.php +++ b/templates/pages/page-newposts.php @@ -14,7 +14,6 @@ get_header(); $paged = max(1, (int) get_query_var('paged')); $per_page = 20; - $query = new WP_Query([ 'post_type' => 'post', 'post_status' => 'publish', @@ -23,45 +22,51 @@ $query = new WP_Query([ 'orderby' => 'date', 'order' => 'DESC', ]); + +if (function_exists('aksrt_archive_open_shell')) { + aksrt_archive_open_shell([ + 'main_class' => 'site-main container content-shell content-shell--page page-content-default', + 'has_sidebar' => false, + 'page_kind' => 'newposts', + ]); +} ?> +
+ esc_html(get_the_title() ?: __('最新文章', 'aksrt')), + ]); + ?> -
- - -
-
-
-
- have_posts()) : ?> -
- have_posts()) : $query->the_post(); ?> -
- -

- -

-

-
- -
- ' . paginate_links(['total' => $query->max_num_pages]) . '
'; - } - ?> - - -

- -
-
-
-
- - +
+ have_posts()) : ?> +
+ have_posts()) : $query->the_post(); ?> +
+ +

+ +

+

+
+ +
+ ' . paginate_links(['total' => $query->max_num_pages]) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } + wp_reset_postdata(); + ?> + +

+ +
+ false]); +} + get_footer(); diff --git a/templates/pages/page-posts-navs.php b/templates/pages/page-posts-navs.php index d6a33f9d..28e84ebe 100644 --- a/templates/pages/page-posts-navs.php +++ b/templates/pages/page-posts-navs.php @@ -13,47 +13,53 @@ defined('ABSPATH') || exit; get_header(); $categories = get_categories(['hide_empty' => true, 'orderby' => 'count', 'order' => 'DESC', 'number' => 20]); -$tags = get_tags(['hide_empty' => true, 'orderby' => 'count', 'order' => 'DESC', 'number' => 40]); +$tags = get_tags(['hide_empty' => true, 'orderby' => 'count', 'order' => 'DESC', 'number' => 40]); + +if (function_exists('aksrt_archive_open_shell')) { + aksrt_archive_open_shell([ + 'main_class' => 'site-main container content-shell content-shell--page page-content-default', + 'has_sidebar' => false, + 'page_kind' => 'posts-navs', + ]); +} ?> +
+ esc_html(get_the_title() ?: __('文章导航', 'aksrt')), + ]); + ?> -
- - -
-
-
-
- -
-

- -
- - - -
-

-
- - name); ?> - -
-
- -
-
-
-
-
+
+ +
+

+ +
+ + +
+

+
+ + name); ?> + +
+
+ +
+
false]); +} + get_footer(); diff --git a/templates/parts/page-header.php b/templates/parts/page-header.php index 6c51b542..98e4b38f 100644 --- a/templates/parts/page-header.php +++ b/templates/parts/page-header.php @@ -3,7 +3,6 @@ * Reusable Page Header Template Part. * * Contract: get_template_part(..., null, $args) - * Prefer explicit $args over ambient query vars. * * Args: * style – '' | '1' | '2' | '3' | 'not' @@ -20,11 +19,8 @@ defined('ABSPATH') || exit; $args = is_array($args ?? null) ? $args : []; -// Resolve style: explicit args > residual query var > global setting. +// Resolve style: explicit args > global setting. $ph_style = array_key_exists('style', $args) ? $args['style'] : null; -if ($ph_style === null) { - $ph_style = get_query_var('aksrt_ph_style', null); -} if ($ph_style === null) { $ph_style = class_exists('AKSRT_Settings') ? (AKSRT_Settings::get_other_page_settings()['header_style'] ?? '1') @@ -39,23 +35,13 @@ if ($ph_style === '') { return; } -$ph_eyebrow = array_key_exists('eyebrow', $args) - ? (string) $args['eyebrow'] - : (string) get_query_var('aksrt_ph_eyebrow', ''); -$ph_title = array_key_exists('title', $args) - ? (string) $args['title'] - : (string) get_query_var('aksrt_ph_title', ''); -$ph_desc = array_key_exists('desc', $args) - ? (string) $args['desc'] - : (string) get_query_var('aksrt_ph_desc', ''); -$ph_extra = array_key_exists('extra', $args) - ? (string) $args['extra'] - : (string) get_query_var('aksrt_ph_extra', ''); +$ph_eyebrow = (string) ($args['eyebrow'] ?? ''); +$ph_title = (string) ($args['title'] ?? ''); +$ph_desc = (string) ($args['desc'] ?? ''); +$ph_extra = (string) ($args['extra'] ?? ''); -// Cover image: explicit args > residual query var > global setting > post thumbnail. -$ph_cover = array_key_exists('cover', $args) - ? (string) $args['cover'] - : (string) get_query_var('aksrt_ph_cover', ''); +// Cover image: explicit args > global setting > post thumbnail. +$ph_cover = (string) ($args['cover'] ?? ''); if ($ph_cover === '' && class_exists('AKSRT_Settings')) { $other = AKSRT_Settings::get_other_page_settings(); $ph_cover = (string) ($other['header_cover_img'] ?? '');