fix(header): wire multi-function page-type enable like zibll

Connect header_components_show_on through aksrt_header_slide_is_show with
zibll page-type matching, drop the homepage-only gate, align admin options,
apply nav color, enqueue by is_show, remove dead float-btn schema, and
consume footer_tabbar_single extend mode on post singles.
This commit is contained in:
kate522 committed 2026-07-15 17:12:51 +08:00
1 parent 3e3a4631f0
commit bfb64211ee
12 files changed
+445 -285

No files matched your search

+145 -7
View File
@@ -822,27 +822,165 @@ if (!function_exists('aksrt_homepage_render_section')) {
}
}
if (!function_exists('aksrt_header_components_page_type_keys')) {
/**
* Allowed page-type keys for header multi-function (zibll CFS_Module::page_type).
*
* @return list<string>
*/
function aksrt_header_components_page_type_keys(): array {
return [
'home',
'topics',
'category',
'tag',
'author',
'single',
'search',
'forum_home',
'forum_plate',
'forum_post',
'page',
];
}
}
if (!function_exists('aksrt_header_slide_excluded_page_templates')) {
/**
* Page templates excluded from the generic "page" type (zibll parity).
*
* @return list<string>
*/
function aksrt_header_slide_excluded_page_templates(): array {
return [
'templates/pages/page-sign.php',
'templates/pages/page-login.php',
'templates/pages/page-register.php',
'templates/pages/page-reset-password.php',
'templates/pages/page-bind-account.php',
'templates/pages/page-verify-email.php',
'templates/pages/page-download.php',
'templates/pages/page-download-file.php',
'templates/pages/page-forums.php',
];
}
}
if (!function_exists('aksrt_header_slide_match_page_type')) {
/**
* Whether the current main query matches a header-slider page-type key.
*
* Mirrors zibll zib_header_slide_is_show() matching rules.
*/
function aksrt_header_slide_match_page_type(string $type): bool {
global $wp_query;
$type = sanitize_key($type);
if ($type === '' || !($wp_query instanceof WP_Query)) {
return false;
}
$raw_post_type = $wp_query->get('post_type');
if (is_array($raw_post_type)) {
$post_type = (string) reset($raw_post_type);
} else {
$post_type = (string) $raw_post_type;
}
// Special keys that are not plain is_{$type} flags.
if ($type === 'topics') {
return is_tax('topics');
}
if ($type === 'forum_home') {
return is_page_template('templates/pages/page-forums.php');
}
if ($type === 'forum_plate') {
return is_singular('aksrt_forum_plate') || $post_type === 'aksrt_forum_plate';
}
if ($type === 'forum_post') {
return is_singular('aksrt_forum_topic') || $post_type === 'aksrt_forum_topic';
}
// Generic WP_Query is_* flags (home/category/tag/author/single/search/page).
$query_flag = 'is_' . $type;
if (empty($wp_query->{$query_flag})) {
return false;
}
if ($type === 'single') {
// Only ordinary posts; CPTs use dedicated keys.
return $post_type === '' || $post_type === 'post';
}
if ($type === 'page') {
foreach (aksrt_header_slide_excluded_page_templates() as $template) {
if (is_page_template($template)) {
return false;
}
}
return true;
}
return true;
}
}
if (!function_exists('aksrt_header_slide_is_show')) {
/**
* Whether the header multi-function slider should render (zibll header-slider contract).
*
* Master switch: non-empty header_components_show_on + current page-type match.
* Device rule: header_components_device_visibility (only_pc / only_sm).
*/
function aksrt_header_slide_is_show(): bool {
if (is_admin()) {
global $wp_query;
if (is_admin() || !($wp_query instanceof WP_Query)) {
return false;
}
// Match zibll: only first page of the posts index / front page.
if (!(is_front_page() || is_home())) {
// Not on paginated views (zibll: query_vars['paged'] non-empty).
$paged = (int) $wp_query->get('paged');
if ($paged > 1) {
return false;
}
if (function_exists('aksrt_homepage_get_current_page') && aksrt_homepage_get_current_page() > 1) {
return false;
}
return function_exists('aksrt_homepage_module_hero_enabled')
? aksrt_homepage_module_hero_enabled()
: true;
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_header_components_settings()
: [];
$show_on = isset($settings['show_on_pages']) ? (array) $settings['show_on_pages'] : [];
$allowed = array_values(array_intersect(
array_map('sanitize_key', $show_on),
aksrt_header_components_page_type_keys()
));
// Empty selection = feature off (zibll header_slider_show).
if ($allowed === []) {
return false;
}
// Device visibility (zibll header_slider_show_type).
$show_type = (string) ($settings['show_type'] ?? '');
if ($show_type === 'only_pc' && wp_is_mobile()) {
return false;
}
if ($show_type === 'only_sm' && !wp_is_mobile()) {
return false;
}
foreach ($allowed as $type) {
if (aksrt_header_slide_match_page_type($type)) {
return true;
}
}
return false;
}
}