fix(page-display): connect header component visibility settings

This commit is contained in:
2026-08-19 13:35:31 +08:00
parent 8a738c7998
commit d4a9b7fd98
8 changed files with 152 additions and 34 deletions
+24 -10
View File
@@ -58,8 +58,11 @@ if (!function_exists('aksrt_header_slide_matches_query')) {
return is_category();
case 'tag':
return is_tag();
case 'user_home':
case 'author':
return is_author();
return is_author() || (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page());
case 'user_center':
return function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page();
case 'single':
return is_singular('post');
case 'search':
@@ -68,6 +71,10 @@ if (!function_exists('aksrt_header_slide_matches_query')) {
if (!is_page()) {
return false;
}
if ((function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page())
|| (function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page())) {
return false;
}
foreach (aksrt_header_slide_excluded_page_templates() as $template) {
if (is_page_template($template)) {
return false;
@@ -92,13 +99,6 @@ if (!function_exists('aksrt_header_slide_is_show')) {
return false;
}
$page_config = aksrt_get_page_header_slider_config();
if ($page_config) {
$show_type = sanitize_key((string) ($page_config['header_slider_show_type'] ?? ''));
return !($show_type === 'only_pc' && wp_is_mobile())
&& !($show_type === 'only_sm' && !wp_is_mobile());
}
$settings = class_exists('\\AKSRT\\Settings\\Settings')
? \AKSRT\Settings\Settings::get_header_slider_settings()
: [];
@@ -107,13 +107,27 @@ if (!function_exists('aksrt_header_slide_is_show')) {
return false;
}
$matches_global_scope = false;
foreach ((array) ($settings['show_on_pages'] ?? []) as $type) {
if (aksrt_header_slide_matches_query((string) $type)) {
return true;
$matches_global_scope = true;
break;
}
}
if (!$matches_global_scope) {
return false;
}
return false;
// Per-page data may customize an already-enabled component, but it must
// never bypass the global page scope selected in the theme settings.
$page_config = aksrt_get_page_header_slider_config();
if ($page_config) {
$page_show_type = sanitize_key((string) ($page_config['header_slider_show_type'] ?? ''));
return !($page_show_type === 'only_pc' && wp_is_mobile())
&& !($page_show_type === 'only_sm' && !wp_is_mobile());
}
return true;
}
}