导入 AKSRT 主题开发源码
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Reusable Page Header Template Part.
|
||||
*
|
||||
* Renders a unified page header for archive / search / page templates.
|
||||
* Style is driven by the global setting `page_header_style` with optional
|
||||
* per-page post-meta override (`page_header_style`).
|
||||
*
|
||||
* Query vars consumed (set via set_query_var before calling get_template_part):
|
||||
* aksrt_ph_style – override style ('' | '1' | '2' | '3'), defaults to global setting
|
||||
* aksrt_ph_eyebrow – eyebrow label text
|
||||
* aksrt_ph_title – title HTML (already escaped by caller)
|
||||
* aksrt_ph_desc – description text
|
||||
* aksrt_ph_cover – cover image URL override
|
||||
* aksrt_ph_extra – extra HTML appended inside the body area (e.g. admin quick-links)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// Resolve style: explicit query var > global setting.
|
||||
$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')
|
||||
: '1';
|
||||
}
|
||||
|
||||
// '' means "don't show header"
|
||||
if ($ph_style === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$ph_eyebrow = get_query_var('aksrt_ph_eyebrow', '');
|
||||
$ph_title = get_query_var('aksrt_ph_title', '');
|
||||
$ph_desc = get_query_var('aksrt_ph_desc', '');
|
||||
$ph_extra = get_query_var('aksrt_ph_extra', '');
|
||||
|
||||
// Cover image: explicit > global setting > post thumbnail.
|
||||
$ph_cover = get_query_var('aksrt_ph_cover', '');
|
||||
if (empty($ph_cover) && class_exists('AKSRT_Settings')) {
|
||||
$other = AKSRT_Settings::get_other_page_settings();
|
||||
$ph_cover = $other['header_cover_img'] ?? '';
|
||||
}
|
||||
if (empty($ph_cover) && has_post_thumbnail()) {
|
||||
$ph_cover = get_the_post_thumbnail_url(get_the_ID(), 'full');
|
||||
}
|
||||
|
||||
// Map style value to CSS modifier class.
|
||||
$style_class = 'term-page-header--simple';
|
||||
if ($ph_style === '2') {
|
||||
$style_class = 'term-page-header--card';
|
||||
} elseif ($ph_style === '3') {
|
||||
$style_class = 'term-page-header--cover';
|
||||
}
|
||||
|
||||
// Cover inline style (for cover style).
|
||||
$cover_style = '';
|
||||
if ($ph_style === '3' && !empty($ph_cover)) {
|
||||
$cover_style = ' style="background-image:url(\'' . esc_url($ph_cover) . '\')"';
|
||||
}
|
||||
?>
|
||||
|
||||
<header class="page-header term-page-header <?php echo esc_attr($style_class); ?>">
|
||||
<?php if ($ph_style === '3' && !empty($ph_cover)) : ?>
|
||||
<div class="term-page-header__cover-bg"<?php echo $cover_style; /* phpcs:ignore -- escaped above */ ?>>
|
||||
<div class="term-page-header__cover-overlay"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="term-page-header__body<?php echo $ph_style === '3' ? ' term-page-header__body--overlay' : ''; ?>">
|
||||
<div>
|
||||
<?php if ($ph_eyebrow !== '') : ?>
|
||||
<p class="term-page-header__eyebrow"><?php echo esc_html($ph_eyebrow); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h1 class="entry-title"><?php echo $ph_title; /* phpcs:ignore -- caller must escape */ ?></h1>
|
||||
|
||||
<?php if ($ph_desc !== '') : ?>
|
||||
<p class="term-page-header__desc"><?php echo esc_html($ph_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($ph_extra !== '') : ?>
|
||||
<?php echo $ph_extra; /* phpcs:ignore -- caller must escape */ ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($ph_style === '2' && !empty($ph_cover)) : ?>
|
||||
<div class="term-page-header__cover"<?php echo $cover_style; /* phpcs:ignore -- escaped above */ ?>></div>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
Reference in New Issue
Block a user