专用页对齐 content-shell,并删 page-header query-var 回退

archives/friends/newposts/posts-navs/categories 统一壳层与 page-header 契约,
主路径不再保留 aksrt_ph_* ambient 传参。
This commit is contained in:
2026-07-09 23:05:06 +08:00
parent 9fd0735e97
commit 8849540fda
6 changed files with 228 additions and 210 deletions
+20 -13
View File
@@ -12,17 +12,23 @@ 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',
]);
}
?>
<div class="content-main content-main--page content-main--archives">
<?php
get_template_part('templates/parts/page-header', null, [
'title' => esc_html__('文章归档', 'aksrt'),
]);
?>
<main id="main-content" class="container page-content-default" tabindex="-1">
<header class="page-header">
<h1 class="entry-title"><?php esc_html_e('文章归档', 'aksrt'); ?></h1>
</header>
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary">
<div class="aksrt-archives container">
<div class="aksrt-archives">
<?php
$years = $wpdb->get_results(
"SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, COUNT(*) AS count
@@ -37,7 +43,7 @@ global $wpdb;
if ((int) $row->year !== $current_year) :
$current_year = (int) $row->year;
?>
<h2 class="aksrt-archives__year"><?php echo esc_html($current_year); ?></h2>
<h2 class="aksrt-archives__year"><?php echo esc_html((string) $current_year); ?></h2>
<?php endif; ?>
<h3 class="aksrt-archives__month">
<?php echo esc_html(sprintf('%d 月 (%d 篇)', (int) $row->month, (int) $row->count)); ?>
@@ -61,8 +67,9 @@ global $wpdb;
<?php endforeach; ?>
</div>
</div>
</div>
</main>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();
+22 -13
View File
@@ -46,26 +46,31 @@ if ($page_title === '') {
}
?>
<main id="main-content" class="site-main content-shell" tabindex="-1">
<?php if (function_exists('aksrt_breadcrumbs')) {
aksrt_breadcrumbs();
} ?>
<header class="page-header aksrt-cats-header">
<h1 class="entry-title"><?php echo esc_html($page_title); ?></h1>
<p class="aksrt-cats-header__meta">
<?php
if (function_exists('aksrt_archive_open_shell')) {
aksrt_archive_open_shell([
'main_class' => 'site-main container content-shell content-shell--page',
'has_sidebar' => false,
'page_kind' => 'categories',
]);
}
?>
<div class="content-main content-main--page content-main--categories">
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
<?php
printf(
$cats_meta = sprintf(
/* translators: 1: total category count, 2: total published post count */
esc_html__('共 %1$d 个分类 · 共 %2$d 篇文章', 'aksrt'),
$total_cats,
$total_posts
);
get_template_part('templates/parts/page-header', null, [
'title' => esc_html($page_title),
'desc' => $cats_meta,
]);
?>
</p>
</header>
<?php if (!empty($top_level)) : ?>
<?php if (!empty($top_level)) : ?>
<section class="aksrt-cats-grid" aria-label="<?php esc_attr_e('分类列表', 'aksrt'); ?>">
<?php foreach ($top_level as $cat) :
$cat_id = (int) $cat->term_id;
@@ -124,7 +129,11 @@ if ($page_title === '') {
<?php esc_html_e('返回首页', 'aksrt'); ?>
</a>
</p>
</main>
</div>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();
+22 -17
View File
@@ -11,19 +11,24 @@ 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',
]);
}
?>
<div class="content-main content-main--page content-main--friends">
<?php
get_template_part('templates/parts/page-header', null, [
'title' => esc_html__('友情链接', 'aksrt'),
'desc' => __('与这些优秀的站点交换友链', 'aksrt'),
]);
?>
<main id="main-content" class="container page-content-default" tabindex="-1">
<header class="page-header">
<h1 class="entry-title"><?php esc_html_e('友情链接', 'aksrt'); ?></h1>
<p><?php esc_html_e('与这些优秀的站点交换友链', 'aksrt'); ?></p>
</header>
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary">
<?php if (! empty($links)) : ?>
<?php if (!empty($links)) : ?>
<div class="friends-grid">
<?php foreach ($links as $link) : ?>
<a class="friend-card" href="<?php echo esc_url($link['url'] ?? '#'); ?>" target="_blank" rel="noopener noreferrer">
@@ -44,18 +49,18 @@ $links = function_exists('aksrt_get_friend_links') ? aksrt_get_friend_links() :
<?php endforeach; ?>
</div>
<?php else : ?>
<div class="no-results">
<div class="no-results content-stream__empty">
<p><?php esc_html_e('暂无友链,请在主题后台添加。', 'aksrt'); ?></p>
</div>
<?php endif; ?>
<p style="text-align:center;margin-top:32px;">
<p class="text-center" style="margin-top:32px;">
<a class="btn-outline" href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('返回首页', 'aksrt'); ?></a>
</p>
</div>
</div>
</div>
</main>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();
+22 -17
View File
@@ -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,17 +22,23 @@ $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',
]);
}
?>
<div class="content-main content-main--page content-main--newposts">
<?php
get_template_part('templates/parts/page-header', null, [
'title' => esc_html(get_the_title() ?: __('最新文章', 'aksrt')),
]);
?>
<main id="main-content" class="container page-content-default" tabindex="-1">
<header class="page-header">
<h1 class="entry-title"><?php echo esc_html(get_the_title() ?: __('最新文章', 'aksrt')); ?></h1>
</header>
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary">
<div class="aksrt-newposts container">
<div class="aksrt-newposts">
<?php if ($query->have_posts()) : ?>
<div class="aksrt-newposts__list">
<?php while ($query->have_posts()) : $query->the_post(); ?>
@@ -50,18 +55,18 @@ $query = new WP_Query([
if (function_exists('aksrt_render_pagination')) {
aksrt_render_pagination($query);
} else {
echo '<div class="aksrt-pagination">' . paginate_links(['total' => $query->max_num_pages]) . '</div>';
echo '<div class="aksrt-pagination">' . paginate_links(['total' => $query->max_num_pages]) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
wp_reset_postdata();
?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p class="aksrt-newposts__empty"><?php esc_html_e('暂无文章。', 'aksrt'); ?></p>
<p class="aksrt-newposts__empty content-stream__empty"><?php esc_html_e('暂无文章。', 'aksrt'); ?></p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();
+20 -14
View File
@@ -14,17 +14,23 @@ 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]);
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',
]);
}
?>
<div class="content-main content-main--page content-main--posts-navs">
<?php
get_template_part('templates/parts/page-header', null, [
'title' => esc_html(get_the_title() ?: __('文章导航', 'aksrt')),
]);
?>
<main id="main-content" class="container page-content-default" tabindex="-1">
<header class="page-header">
<h1 class="entry-title"><?php echo esc_html(get_the_title() ?: __('文章导航', 'aksrt')); ?></h1>
</header>
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary">
<div class="aksrt-posts-navs container">
<div class="aksrt-posts-navs">
<?php if (!empty($categories)) : ?>
<section class="aksrt-posts-navs__section">
<h2 class="aksrt-posts-navs__heading"><?php esc_html_e('热门分类', 'aksrt'); ?></h2>
@@ -32,7 +38,7 @@ $tags = get_tags(['hide_empty' => true, 'orderby' => 'count', 'order' => '
<?php foreach ($categories as $cat) : ?>
<a href="<?php echo esc_url(get_category_link($cat->term_id)); ?>" class="aksrt-posts-navs__cat-chip">
<span class="aksrt-posts-navs__cat-name"><?php echo esc_html($cat->name); ?></span>
<span class="aksrt-posts-navs__cat-count"><?php echo esc_html($cat->count); ?></span>
<span class="aksrt-posts-navs__cat-count"><?php echo esc_html((string) $cat->count); ?></span>
</a>
<?php endforeach; ?>
</div>
@@ -51,9 +57,9 @@ $tags = get_tags(['hide_empty' => true, 'orderby' => 'count', 'order' => '
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();
+7 -21
View File
@@ -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'] ?? '');