fix(header): full zibll 1:1 for top multifunc search/cards/admin
Wire hero search through aksrt_get_search_box, device-gated cards/blur (zib_m_pc_is_show), expanded admin schema, and keyword/type UI styles matching zibll header-slider.
This commit is contained in:
@@ -629,16 +629,18 @@ export const pageDisplaySchemas = {
|
||||
header_components_nav_color: '#ffffff',
|
||||
header_components_show_on: ['home'],
|
||||
header_components_device_visibility: '',
|
||||
header_components_filter_blur_devices: [],
|
||||
header_components_filter_blur_devices: ['pc', 'mobile'],
|
||||
header_components_card_show_devices: ['pc', 'mobile'],
|
||||
header_components_card_shared_bg: false,
|
||||
header_components_card_blur: true,
|
||||
header_components_card_icon_shape: 'circle',
|
||||
header_components_icon_cards: [],
|
||||
header_components_search_pc: true,
|
||||
header_components_search_mobile: true,
|
||||
header_components_search_show_keywords: false,
|
||||
header_components_search_popular_limit: 5,
|
||||
header_components_search_show_keywords: true,
|
||||
header_components_search_popular_limit: 6,
|
||||
header_components_search_in_cat: '',
|
||||
header_components_search_in_type: 'post',
|
||||
header_components_search_more_cats: [],
|
||||
header_components_search_show_input_cat: false,
|
||||
header_components_search_show_type: false,
|
||||
header_components_search_before_html: '<div class="em16 font-bold mb10">更优雅的Wordpress主题</div>\n<div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>',
|
||||
@@ -711,10 +713,18 @@ export const pageDisplaySchemas = {
|
||||
fields: [
|
||||
{ key: 'header_components_search_pc', label: 'PC 端显示搜索', type: 'switch', default: true, dependsOn: { key: 'header_components_search_enabled', value: true } },
|
||||
{ key: 'header_components_search_mobile', label: '移动端显示搜索', type: 'switch', default: true, dependsOn: { key: 'header_components_search_enabled', value: true } },
|
||||
{ key: 'header_components_search_show_keywords', label: '显示热门搜索词', type: 'switch', default: false, dependsOn: { key: 'header_components_search_enabled', value: true } },
|
||||
{ key: 'header_components_search_popular_limit', label: '热词数量', type: 'number', default: 5, min: 1, max: 20, dependsOn: { key: 'header_components_search_show_keywords', value: true } },
|
||||
{ key: 'header_components_search_show_input_cat', label: '显示分类搜索', type: 'switch', default: false, dependsOn: { key: 'header_components_search_enabled', value: true }, help: '搜索框内显示分类选择下拉' },
|
||||
{ key: 'header_components_search_show_type', label: '显示类型切换', type: 'switch', default: false, dependsOn: { key: 'header_components_search_enabled', value: true }, help: '搜索框内显示内容类型切换' },
|
||||
{ key: 'header_components_search_show_keywords', label: '热门搜索', type: 'switch', default: true, dependsOn: { key: 'header_components_search_enabled', value: true }, help: '显示网站热门搜索关键词(移动端不会显示)' },
|
||||
{ key: 'header_components_search_popular_limit', label: '关键词最多显示', type: 'number', default: 6, min: 2, max: 50, dependsOn: { key: 'header_components_search_show_keywords', value: true } },
|
||||
{ key: 'header_components_search_show_input_cat', label: '分类搜索', type: 'switch', default: false, dependsOn: { key: 'header_components_search_enabled', value: true }, help: '显示分类搜索选择' },
|
||||
{ key: 'header_components_search_in_cat', label: '默认搜索的分类', type: 'input', default: '', dependsOn: { key: 'header_components_search_show_input_cat', value: true }, help: '分类 ID,可留空' },
|
||||
{ key: 'header_components_search_show_type', label: '显示类型选择', type: 'switch', default: false, dependsOn: { key: 'header_components_search_enabled', value: true }, help: '显示切换搜索类型的按钮(文章、用户、版块、帖子、商品)' },
|
||||
{ key: 'header_components_search_in_type', label: '默认搜索类型', type: 'radio', default: 'post', dependsOn: { key: 'header_components_search_show_type', value: true }, options: [
|
||||
{ label: '文章', value: 'post' },
|
||||
{ label: '用户', value: 'user' },
|
||||
{ label: '商品', value: 'product' },
|
||||
{ label: '帖子', value: 'forum' },
|
||||
{ label: '版块', value: 'plate' },
|
||||
]},
|
||||
{
|
||||
key: 'header_components_search_before_html',
|
||||
label: '搜索上方额外内容',
|
||||
@@ -740,20 +750,19 @@ export const pageDisplaySchemas = {
|
||||
title: '图标卡片样式',
|
||||
icon: 'fas fa-th-large',
|
||||
fields: [
|
||||
{ key: 'header_components_filter_blur_devices', label: '容器模糊设备', type: 'checkbox', default: [], dependsOn: { key: 'header_components_cards_enabled', value: true }, options: [
|
||||
{ label: 'PC', value: 'pc' },
|
||||
{ label: '移动端', value: 'mobile' },
|
||||
]},
|
||||
{ key: 'header_components_filter_blur_devices', label: '组件高斯模糊特效', type: 'checkbox', default: ['pc', 'mobile'], options: [
|
||||
{ label: 'PC端开启', value: 'pc' },
|
||||
{ label: '移动端开启', value: 'mobile' },
|
||||
], help: '搜索组件和卡片组件背景显示高斯模糊特效(较耗性能)' },
|
||||
{ key: 'header_components_card_show_devices', label: '卡片显示设备', type: 'checkbox', default: ['pc', 'mobile'], dependsOn: { key: 'header_components_cards_enabled', value: true }, options: [
|
||||
{ label: 'PC', value: 'pc' },
|
||||
{ label: '移动端', value: 'mobile' },
|
||||
{ label: 'PC端显示', value: 'pc' },
|
||||
{ label: '移动端显示', value: 'mobile' },
|
||||
]},
|
||||
{ key: 'header_components_card_shared_bg', label: '共享卡片背景', type: 'switch', default: false, dependsOn: { key: 'header_components_cards_enabled', value: true }, help: '开启后所有图标卡片共用背景模式' },
|
||||
{ key: 'header_components_card_blur', label: '启用卡片模糊效果', type: 'switch', default: true, dependsOn: { key: 'header_components_cards_enabled', value: true } },
|
||||
{ key: 'header_components_card_icon_shape', label: '图标形状', type: 'radio', default: 'circle', dependsOn: { key: 'header_components_cards_enabled', value: true }, options: [
|
||||
{ key: 'header_components_card_shared_bg', label: '模块背景', type: 'switch', default: false, dependsOn: { key: 'header_components_cards_enabled', value: true }, help: '整个模块显示背景;关闭后每个卡片各自显示背景(zibll show_widget_bg)' },
|
||||
{ key: 'header_components_card_icon_shape', label: '方形图标', type: 'radio', default: 'circle', dependsOn: { key: 'header_components_cards_enabled', value: true }, options: [
|
||||
{ label: '圆形', value: 'circle' },
|
||||
{ label: '方形', value: 'square' },
|
||||
]},
|
||||
], help: '图标显示为正方形,而不是圆形(zibll icon_radius4)' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -781,23 +790,30 @@ export const pageDisplaySchemas = {
|
||||
dependsOn: { key: 'header_components_cards_enabled', value: true },
|
||||
addText: '添加卡片',
|
||||
fields: [
|
||||
{ key: 'icon', label: '图标类名', type: 'input', default: 'fas fa-star', placeholder: 'fas fa-star' },
|
||||
{ key: 'custom_icon', label: '自定义图标 HTML', type: 'textarea', default: '', rows: 2, placeholder: '<svg>...</svg>' },
|
||||
{ key: 'icon_class', label: '图标配色', type: 'select', default: 'c-blue', options: [
|
||||
{ label: 'Blue', value: 'c-blue' },
|
||||
{ key: 'title', label: '文案标题', type: 'textarea', default: '', rows: 1, help: '第一行文案,字体稍大;支持 HTML(如 badge)' },
|
||||
{ key: 'desc', label: '文案简介', type: 'textarea', default: '', rows: 2, help: '第二行文案,字体稍小;支持 HTML' },
|
||||
{ key: 'icon', label: '选择图标', type: 'input', default: 'fa fa-magic', placeholder: 'fa fa-magic / fas fa-star' },
|
||||
{ key: 'custom_icon', label: '自定义图标', type: 'textarea', default: '', rows: 1, placeholder: '自定义图标 HTML 代码', help: '如使用非自带图标,可输入自定义图标代码' },
|
||||
{ key: 'icon_class', label: '图标颜色', type: 'select', default: 'c-yellow', options: [
|
||||
{ label: 'Yellow', value: 'c-yellow' },
|
||||
{ label: 'Blue', value: 'c-blue' },
|
||||
{ label: 'Blue-2', value: 'c-blue-2' },
|
||||
{ label: 'Green', value: 'c-green' },
|
||||
{ label: 'Red', value: 'c-red' },
|
||||
{ label: 'Orange', value: 'c-orange' },
|
||||
{ label: 'Red-2', value: 'c-red-2' },
|
||||
{ label: 'Cyan', value: 'c-cyan' },
|
||||
{ label: 'Pink', value: 'c-pink' },
|
||||
{ label: 'Purple', value: 'c-purple' },
|
||||
{ label: 'Gray', value: 'c-gray' },
|
||||
{ label: 'Gradient Pink', value: 'jb-pink' },
|
||||
{ label: 'Gradient Yellow', value: 'jb-yellow' },
|
||||
{ label: 'Gradient Blue', value: 'jb-blue' },
|
||||
{ label: 'Gradient Cyan', value: 'jb-cyan' },
|
||||
{ label: 'Gradient Green', value: 'jb-green' },
|
||||
{ label: 'Gradient Purple', value: 'jb-purple' },
|
||||
{ label: 'Gradient Orange', value: 'jb-orange' },
|
||||
]},
|
||||
{ key: 'title', label: '标题', type: 'input', default: '' },
|
||||
{ key: 'desc', label: '描述', type: 'input', default: '' },
|
||||
{ key: 'url', label: '链接 URL', type: 'input', default: '', placeholder: 'https://example.com' },
|
||||
{ key: 'url', label: '跳转链接', type: 'input', default: '', placeholder: 'https://example.com' },
|
||||
{ key: 'target', label: '打开方式', type: 'radio', default: '_self', options: [
|
||||
{ label: '当前标签页', value: '_self' },
|
||||
{ label: '新标签页', value: '_blank' },
|
||||
|
||||
@@ -10,30 +10,52 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* zibll: .header-slider-search .search_keywords, .header-slider-search .search-type-but-average .but */
|
||||
.header-components-search__kw-tag,
|
||||
.header-slider-search .search_keywords {
|
||||
.header-slider-search .search_keywords,
|
||||
.header-slider-search .search-keywords .but,
|
||||
.header-slider-search .search-type-but-average .but {
|
||||
--this-bg: rgba(255, 255, 255, 0.8);
|
||||
--this-color: #888;
|
||||
display: inline-block;
|
||||
padding: 3px 5px;
|
||||
font-size: 0.85em;
|
||||
line-height: 1.4;
|
||||
border-radius: 100px;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
color: #888;
|
||||
background: var(--this-bg);
|
||||
color: var(--this-color);
|
||||
text-decoration: none;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.header-slider-search .search-type-but-average .but.active {
|
||||
--this-bg: var(--focus-color, var(--color-primary));
|
||||
--this-color: #fff;
|
||||
}
|
||||
|
||||
.filter-blur .header-slider-search .search_keywords,
|
||||
.filter-blur .header-slider-search .search-keywords .but,
|
||||
.filter-blur .header-slider-search .search-type-but-average .but,
|
||||
.filter-blur .header-components-search__kw-tag {
|
||||
-webkit-backdrop-filter: saturate(5) blur(20px);
|
||||
backdrop-filter: saturate(5) blur(20px);
|
||||
}
|
||||
|
||||
.header-components-search__kw-tag:hover,
|
||||
.header-slider-search .search_keywords:hover {
|
||||
.header-slider-search .search_keywords:hover,
|
||||
.header-slider-search .search-keywords .but:hover {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
}
|
||||
|
||||
/* Hide default keywords title row inside hero overlay (zibll header search has no title line). */
|
||||
.header-slider-search .search-keywords > p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header-slider-search .search-keywords {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* zibll mobile (max-width: 767px) search / card offsets */
|
||||
@media (max-width: 767px) {
|
||||
.header-components {
|
||||
|
||||
@@ -335,3 +335,14 @@
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
text-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
|
||||
/* zibll: header-slider-search .search-input-text .line-form-line { display:none } */
|
||||
.header-slider-search .search-input-text .line-form-line,
|
||||
.header-components-search .search-input-text .line-form-line {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header-slider-search .search-type-but-average {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ if (!function_exists('aksrt_get_search_keywords_but')) :
|
||||
if ($kw === '') {
|
||||
continue;
|
||||
}
|
||||
$out .= '<a class="but jb-sm" data-search-keyword="' . esc_attr($kw) . '" href="'
|
||||
$out .= '<a class="but jb-sm search_keywords" data-search-keyword="' . esc_attr($kw) . '" href="'
|
||||
. esc_url(home_url('/?s=' . rawurlencode($kw))) . '">'
|
||||
. esc_html($kw) . '</a> ';
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ class SchemaPageDisplay {
|
||||
['key' => 'search', 'title' => '搜索组件', 'fields' => [
|
||||
['key' => 'header_components_search_pc', 'label' => 'PC 端显示搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_mobile', 'label' => '移动端显示搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_show_keywords', 'label' => '显示热门搜索词', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_popular_limit', 'label' => '热词数量', 'type' => 'number', 'default' => 5, 'min' => 1, 'max' => 20, 'dependsOn' => ['key' => 'header_components_search_show_keywords', 'value' => true]],
|
||||
['key' => 'header_components_search_show_keywords', 'label' => '热门搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_popular_limit', 'label' => '关键词最多显示', 'type' => 'number', 'default' => 6, 'min' => 2, 'max' => 50, 'dependsOn' => ['key' => 'header_components_search_show_keywords', 'value' => true]],
|
||||
['key' => 'header_components_search_show_input_cat', 'label' => '显示分类搜索', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_show_type', 'label' => '显示类型切换', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
[
|
||||
@@ -152,7 +152,7 @@ class SchemaPageDisplay {
|
||||
],
|
||||
]],
|
||||
['key' => 'cards', 'title' => '图标卡片样式', 'fields' => [
|
||||
['key' => 'header_components_filter_blur_devices', 'label' => '容器模糊设备', 'type' => 'checkbox', 'default' => [], 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true], 'options' => [
|
||||
['key' => 'header_components_filter_blur_devices', 'label' => '组件高斯模糊特效', 'type' => 'checkbox', 'default' => ['pc', 'mobile'], 'options' => [
|
||||
['label' => 'PC', 'value' => 'pc'],
|
||||
['label' => '移动端', 'value' => 'mobile'],
|
||||
]],
|
||||
@@ -161,7 +161,6 @@ class SchemaPageDisplay {
|
||||
['label' => '移动端', 'value' => 'mobile'],
|
||||
]],
|
||||
['key' => 'header_components_card_shared_bg', 'label' => '共享卡片背景', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true]],
|
||||
['key' => 'header_components_card_blur', 'label' => '启用卡片模糊效果', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true]],
|
||||
['key' => 'header_components_card_icon_shape', 'label' => '图标形状', 'type' => 'radio', 'default' => 'circle', 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true], 'options' => [
|
||||
['label' => '圆形', 'value' => 'circle'],
|
||||
['label' => '方形', 'value' => 'square'],
|
||||
|
||||
@@ -79,36 +79,76 @@ class DisplayRuntime {
|
||||
$show = $is_mobile ? $mobile_on : $pc_on;
|
||||
|
||||
$show_kw = !empty($settings['header_components_search_show_keywords']);
|
||||
$kw_limit = max(1, min(20, (int) ($settings['header_components_search_popular_limit'] ?? 5)));
|
||||
$kw_limit = max(1, min(50, (int) ($settings['header_components_search_popular_limit'] ?? 6)));
|
||||
$show_cat = !empty($settings['header_components_search_show_input_cat']);
|
||||
$show_type = !empty($settings['header_components_search_show_type']);
|
||||
$in_cat = sanitize_text_field((string) ($settings['header_components_search_in_cat'] ?? ''));
|
||||
$in_type = sanitize_key((string) ($settings['header_components_search_in_type'] ?? 'post')) ?: 'post';
|
||||
$more_cats = isset($settings['header_components_search_more_cats'])
|
||||
? array_values(array_filter(array_map('absint', (array) $settings['header_components_search_more_cats'])))
|
||||
: [];
|
||||
|
||||
// Mobile: hide hot keywords to keep the overlay short (zibll parity).
|
||||
// Mobile: hide hot keywords (zibll).
|
||||
if ($is_mobile) {
|
||||
$show_kw = false;
|
||||
}
|
||||
|
||||
$keywords = [];
|
||||
if ($show && $show_kw) {
|
||||
$raw = $settings['hot_search_keywords'] ?? '';
|
||||
$keywords = is_array($raw) ? $raw : preg_split('/[\s,]+/', (string) $raw, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$keywords = array_slice(array_map('sanitize_text_field', $keywords), 0, $kw_limit);
|
||||
if (function_exists('aksrt_get_search_hot_keywords')) {
|
||||
$keywords = (array) aksrt_get_search_hot_keywords();
|
||||
} else {
|
||||
$raw = $settings['hot_search_keywords'] ?? '';
|
||||
$keywords = is_array($raw) ? $raw : preg_split('/[\s,]+/', (string) $raw, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$keywords = array_slice(array_map('sanitize_text_field', array_values($keywords)), 0, $kw_limit);
|
||||
}
|
||||
|
||||
$categories = [];
|
||||
if ($show && $show_cat) {
|
||||
$cats = get_categories(['hide_empty' => false, 'number' => 50]);
|
||||
$cat_args = ['hide_empty' => true, 'number' => 50];
|
||||
if ($more_cats) {
|
||||
$cat_args['include'] = $more_cats;
|
||||
$cat_args['orderby'] = 'include';
|
||||
$cat_args['hide_empty'] = false;
|
||||
}
|
||||
$cats = get_categories($cat_args);
|
||||
foreach ($cats as $cat) {
|
||||
$categories[] = ['id' => $cat->term_id, 'name' => $cat->name];
|
||||
$categories[] = ['id' => (int) $cat->term_id, 'name' => (string) $cat->name];
|
||||
}
|
||||
}
|
||||
|
||||
$type_options = [];
|
||||
if ($show && $show_type) {
|
||||
$types = Settings::get_search_content_types();
|
||||
foreach (($types['enabled'] ?? []) as $type_key => $type_value) {
|
||||
if ($type_value) {
|
||||
$type_options[] = ['key' => $type_key, 'label' => $type_key];
|
||||
$labels = [
|
||||
'post' => __('文章', 'aksrt'),
|
||||
'user' => __('用户', 'aksrt'),
|
||||
'product' => __('商品', 'aksrt'),
|
||||
'forum' => __('帖子', 'aksrt'),
|
||||
'forum_topic' => __('帖子', 'aksrt'),
|
||||
'plate' => __('版块', 'aksrt'),
|
||||
'forum_plate' => __('版块', 'aksrt'),
|
||||
'page' => __('页面', 'aksrt'),
|
||||
];
|
||||
$enabled = $types['enabled'] ?? $types;
|
||||
if (is_array($enabled)) {
|
||||
foreach ($enabled as $type_key => $type_value) {
|
||||
// Support both map[key=>bool] and list of keys.
|
||||
if (is_int($type_key) && is_string($type_value)) {
|
||||
$k = $type_value;
|
||||
$on = true;
|
||||
} else {
|
||||
$k = (string) $type_key;
|
||||
$on = (bool) $type_value;
|
||||
}
|
||||
if (!$on || $k === '') {
|
||||
continue;
|
||||
}
|
||||
$type_options[] = [
|
||||
'key' => $k,
|
||||
'label' => $labels[$k] ?? $k,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,6 +168,9 @@ class DisplayRuntime {
|
||||
'popular_limit' => $kw_limit,
|
||||
'show_input_cat' => $show_cat,
|
||||
'show_type' => $show_type,
|
||||
'in_cat' => $in_cat,
|
||||
'in_type' => $in_type,
|
||||
'more_cats' => $more_cats,
|
||||
'keywords' => $keywords,
|
||||
'categories' => $categories,
|
||||
'type_options' => $type_options,
|
||||
@@ -136,9 +179,7 @@ class DisplayRuntime {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示顶部组件图标卡片覆盖
|
||||
*/
|
||||
|
||||
public static function header_components_cards_enabled(): bool {
|
||||
$settings = Settings::get_all();
|
||||
return !empty($settings['header_components_cards_enabled']);
|
||||
|
||||
@@ -22,29 +22,94 @@ $hero_banners = function_exists('aksrt_get_banners') ? aksrt_get_banners(8, 'her
|
||||
|
||||
$settings = function_exists('aksrt_get_all_settings') ? aksrt_get_all_settings() : [];
|
||||
$search_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_header_components_search_config() : [
|
||||
'pc' => false,
|
||||
'mobile' => false,
|
||||
'show' => false,
|
||||
'keywords' => [],
|
||||
'categories' => [],
|
||||
'type_options' => [],
|
||||
'before_html' => '',
|
||||
'after_html' => '',
|
||||
'show_keywords' => false,
|
||||
'popular_limit' => 6,
|
||||
'show_input_cat' => false,
|
||||
'show_type' => false,
|
||||
'in_cat' => '',
|
||||
'in_type' => 'post',
|
||||
'more_cats' => [],
|
||||
'before_html' => '',
|
||||
'after_html' => '',
|
||||
];
|
||||
$show_search = !empty($search_cfg['show']) || !empty($cfg['with_search']);
|
||||
$show_cards = !empty($settings['header_components_cards_enabled']);
|
||||
|
||||
// zibll zib_m_pc_is_show: checkbox arrays with pc_s / m_s.
|
||||
$is_mobile_req = function_exists('wp_is_mobile') && wp_is_mobile();
|
||||
$m_pc_show = static function ($opt) use ($is_mobile_req): bool {
|
||||
$opt = (array) $opt;
|
||||
return ($is_mobile_req && in_array('m_s', $opt, true)) || (!$is_mobile_req && in_array('pc_s', $opt, true));
|
||||
};
|
||||
|
||||
// Search device gate (zibll header_slider_search_s).
|
||||
$search_opt = [];
|
||||
if (!empty($search_cfg['pc'])) {
|
||||
$search_opt[] = 'pc_s';
|
||||
}
|
||||
if (!empty($search_cfg['mobile'])) {
|
||||
$search_opt[] = 'm_s';
|
||||
}
|
||||
// Fallback: master enabled without explicit devices = both (legacy).
|
||||
if (!$search_opt && !empty($search_cfg['show'])) {
|
||||
$search_opt = ['pc_s', 'm_s'];
|
||||
}
|
||||
$show_search = $m_pc_show($search_opt) || !empty($cfg['with_search']);
|
||||
|
||||
// Cards device gate (zibll header_slider_card_s).
|
||||
$cards_master = !empty($settings['header_components_cards_enabled']);
|
||||
$card_show_devices = isset($settings['header_components_card_show_devices'])
|
||||
? (array) $settings['header_components_card_show_devices']
|
||||
: ['pc', 'mobile'];
|
||||
$card_opt = [];
|
||||
if (in_array('pc', $card_show_devices, true)) {
|
||||
$card_opt[] = 'pc_s';
|
||||
}
|
||||
if (in_array('mobile', $card_show_devices, true)) {
|
||||
$card_opt[] = 'm_s';
|
||||
}
|
||||
if (!$card_opt && $cards_master) {
|
||||
$card_opt = ['pc_s', 'm_s'];
|
||||
}
|
||||
$show_cards = $cards_master && $m_pc_show($card_opt);
|
||||
$icon_cards = isset($settings['header_components_icon_cards']) ? (array) $settings['header_components_icon_cards'] : [];
|
||||
$card_bg_mode = !empty($settings['header_components_card_shared_bg']) ? 'shared' : 'individual';
|
||||
$card_blur = !empty($settings['header_components_card_blur']);
|
||||
$filter_blur_devices = isset($settings['header_components_filter_blur_devices']) ? (array) $settings['header_components_filter_blur_devices'] : ($card_blur ? ['pc', 'mobile'] : []);
|
||||
$card_show_devices = isset($settings['header_components_card_show_devices']) ? (array) $settings['header_components_card_show_devices'] : ['pc', 'mobile'];
|
||||
$card_icon_shape = $settings['header_components_card_icon_shape'] ?? 'circle';
|
||||
|
||||
// Filter blur (zibll header_slider_filter_blur) — independent of cards.
|
||||
$filter_blur_devices = isset($settings['header_components_filter_blur_devices'])
|
||||
? (array) $settings['header_components_filter_blur_devices']
|
||||
: [];
|
||||
// Legacy: header_components_card_blur true without devices → both.
|
||||
if (!$filter_blur_devices && !empty($settings['header_components_card_blur'])) {
|
||||
$filter_blur_devices = ['pc', 'mobile'];
|
||||
}
|
||||
$filter_opt = [];
|
||||
if (in_array('pc', $filter_blur_devices, true)) {
|
||||
$filter_opt[] = 'pc_s';
|
||||
}
|
||||
if (in_array('mobile', $filter_blur_devices, true)) {
|
||||
$filter_opt[] = 'm_s';
|
||||
}
|
||||
$filter_blur_on = $m_pc_show($filter_opt);
|
||||
|
||||
$slide_count = count($hero_banners);
|
||||
$visible_card_count = ($show_cards && !empty($icon_cards)) ? count($icon_cards) : 0;
|
||||
// card-N only counts cards actually rendered on this device (zibll parity).
|
||||
$visible_card_count = 0;
|
||||
if ($show_cards) {
|
||||
foreach ($icon_cards as $_c) {
|
||||
if (is_array($_c) && (trim((string) ($_c['icon'] ?? '')) !== '' || trim((string) ($_c['custom_icon'] ?? '')) !== '' || trim((string) ($_c['customize_icon'] ?? '')) !== '')) {
|
||||
$visible_card_count++;
|
||||
} elseif (is_array($_c) && trim((string) ($_c['title'] ?? '')) !== '') {
|
||||
// Count entries even if icon missing so layout still allocates.
|
||||
$visible_card_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$container_classes = ['header-slider-container', 'header-components-container', 'relative', 'mb20', 'card-' . $visible_card_count];
|
||||
if (in_array('pc', $filter_blur_devices, true) || in_array('mobile', $filter_blur_devices, true)) {
|
||||
if ($filter_blur_on) {
|
||||
$container_classes[] = 'filter-blur';
|
||||
}
|
||||
if (in_array('pc', $filter_blur_devices, true)) {
|
||||
@@ -53,99 +118,50 @@ if (in_array('pc', $filter_blur_devices, true)) {
|
||||
if (in_array('mobile', $filter_blur_devices, true)) {
|
||||
$container_classes[] = 'has-blur-mobile';
|
||||
}
|
||||
if (!in_array('pc', $card_show_devices, true)) {
|
||||
$container_classes[] = 'hide-cards-pc';
|
||||
}
|
||||
if (!in_array('mobile', $card_show_devices, true)) {
|
||||
$container_classes[] = 'hide-cards-mobile';
|
||||
}
|
||||
|
||||
$search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索', 'aksrt');
|
||||
$search_value = trim((string) get_search_query());
|
||||
$search_type = function_exists('aksrt_get_search_form_type') ? aksrt_get_search_form_type() : 'post';
|
||||
|
||||
/**
|
||||
* Search overlay = zibll .header-slider-search.abs-center
|
||||
* Uses aksrt_get_search_box() (zib_get_search_box parity) for form / keywords / type / cat.
|
||||
* Title/subtitle live in before_html (same flow stack as the form).
|
||||
*/
|
||||
$render_hero_search = static function (string $search_id) use ($search_placeholder, $search_value, $search_type, $search_cfg): void {
|
||||
$_kw = $search_cfg['keywords'] ?? [];
|
||||
$_cats = $search_cfg['categories'] ?? [];
|
||||
$_types = $search_cfg['type_options'] ?? [];
|
||||
$_show_cat = !empty($search_cfg['show_input_cat']) && !empty($_cats);
|
||||
$_show_type = !empty($search_cfg['show_type']) && !empty($_types);
|
||||
$_before = isset($search_cfg['before_html']) ? (string) $search_cfg['before_html'] : '';
|
||||
$_after = isset($search_cfg['after_html']) ? (string) $search_cfg['after_html'] : '';
|
||||
?>
|
||||
<div class="header-slider-search header-components-search abs-center">
|
||||
<?php if (trim($_before) !== '') : ?>
|
||||
<div class="header-slider-search-more text-center before">
|
||||
<?php echo wp_kses_post($_before); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="search-input">
|
||||
<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>" class="search-form" data-aksrt-search-form="hero">
|
||||
<input type="hidden" name="aksrt_search_type" value="<?php echo esc_attr($search_type); ?>">
|
||||
<div class="line-form<?php echo ($_show_cat || $_show_type) ? ' has-addons' : ''; ?>">
|
||||
<?php if ($_show_cat) : ?>
|
||||
<select name="cat" class="header-components-search__cat" aria-label="<?php esc_attr_e('选择分类', 'aksrt'); ?>">
|
||||
<option value=""><?php esc_html_e('全部分类', 'aksrt'); ?></option>
|
||||
<?php foreach ($_cats as $_c) : ?>
|
||||
<option value="<?php echo esc_attr($_c['id']); ?>"><?php echo esc_html($_c['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
<?php if ($_show_type) : ?>
|
||||
<div class="header-components-search__types">
|
||||
<?php foreach ($_types as $_idx => $_t) : ?>
|
||||
<label class="header-components-search__type-label">
|
||||
<input type="radio" name="aksrt_search_type" value="<?php echo esc_attr($_t['key']); ?>"<?php echo $_idx === 0 ? ' checked' : ''; ?> class="header-components-search__type-radio">
|
||||
<span class="header-components-search__type-text"><?php echo esc_html($_t['label']); ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="search-input-text">
|
||||
<label class="screen-reader-text" for="<?php echo esc_attr($search_id); ?>"><?php esc_html_e('搜索', 'aksrt'); ?></label>
|
||||
<input
|
||||
type="search"
|
||||
id="<?php echo esc_attr($search_id); ?>"
|
||||
name="s"
|
||||
class="line-form-input"
|
||||
value="<?php echo esc_attr($search_value); ?>"
|
||||
placeholder=" "
|
||||
autocomplete="off"
|
||||
>
|
||||
<i class="line-form-line"></i>
|
||||
<div class="scale-placeholder<?php echo $search_value !== '' ? ' is-focus' : ''; ?>" default="<?php echo esc_attr($search_placeholder); ?>">
|
||||
<?php echo esc_html($search_placeholder); ?>
|
||||
</div>
|
||||
<div class="abs-right">
|
||||
<button type="submit" class="null header-components-search__submit" aria-label="<?php echo esc_attr__('搜索', 'aksrt'); ?>">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||
<circle cx="11" cy="11" r="8"></circle>
|
||||
<path d="m21 21-4.3-4.3"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php if (!empty($_kw)) : ?>
|
||||
<div class="header-components-search__keywords search-keywords">
|
||||
<?php foreach ($_kw as $_kw_text) : ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('s', rawurlencode($_kw_text), home_url('/'))); ?>" class="header-components-search__kw-tag search_keywords"><?php echo esc_html($_kw_text); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (trim($_after) !== '') : ?>
|
||||
<div class="header-slider-search-more text-center after">
|
||||
<?php echo wp_kses_post($_after); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
$render_hero_search = static function () use ($search_cfg, $is_mobile_req): void {
|
||||
$_before = isset($search_cfg['before_html']) ? (string) $search_cfg['before_html'] : '';
|
||||
$_after = isset($search_cfg['after_html']) ? (string) $search_cfg['after_html'] : '';
|
||||
|
||||
$search_args = [
|
||||
'class' => '',
|
||||
'show_keywords' => !empty($search_cfg['show_keywords']),
|
||||
'popular_limit' => max(0, (int) ($search_cfg['popular_limit'] ?? 6)),
|
||||
'show_history' => false,
|
||||
'show_posts' => false,
|
||||
'show_input_cat' => !empty($search_cfg['show_input_cat']),
|
||||
'more_cats' => !empty($search_cfg['more_cats']) ? (array) $search_cfg['more_cats'] : [],
|
||||
'in_cat' => (string) ($search_cfg['in_cat'] ?? ''),
|
||||
'show_type' => !empty($search_cfg['show_type']),
|
||||
'in_type' => (string) ($search_cfg['in_type'] ?? 'post'),
|
||||
'in_user' => '',
|
||||
's' => is_search() ? (string) get_search_query() : '',
|
||||
];
|
||||
// Mobile: never show hot keywords (zibll).
|
||||
if ($is_mobile_req) {
|
||||
$search_args['show_keywords'] = false;
|
||||
}
|
||||
|
||||
$search_html = function_exists('aksrt_get_search_box')
|
||||
? (string) aksrt_get_search_box($search_args)
|
||||
: '';
|
||||
|
||||
$before_html = trim($_before) !== ''
|
||||
? '<div class="header-slider-search-more text-center before">' . wp_kses_post($_before) . '</div>'
|
||||
: '';
|
||||
$after_html = trim($_after) !== ''
|
||||
? '<div class="header-slider-search-more after">' . wp_kses_post($_after) . '</div>'
|
||||
: '';
|
||||
echo '<div class="header-slider-search header-components-search abs-center">'
|
||||
. $before_html
|
||||
. $search_html
|
||||
. $after_html
|
||||
. '</div>';
|
||||
};
|
||||
|
||||
$render_icon_cards = static function () use ($show_cards, $icon_cards, $card_bg_mode, $card_icon_shape): void {
|
||||
@@ -206,7 +222,7 @@ if (!empty($hero_banners)) :
|
||||
$slider_cfg = function_exists('aksrt_get_slider_config') ? aksrt_get_slider_config() : [];
|
||||
$_nav_color_for_header = sanitize_hex_color((string) ($slider_cfg['nav_color'] ?? '')) ?: '';
|
||||
if ($_nav_color_for_header !== '' && strtolower($_nav_color_for_header) !== '#ffffff') {
|
||||
echo '<style id="aksrt-header-slider-nav-color">.header.show-slide{--header-color:' . esc_attr($_nav_color_for_header) . ';}</style>';
|
||||
echo '<style id="aksrt-header-slider-nav-color">body.nav-fixed:not(.body-scroll):not(.mobile-navbar-show) .header.show-slide{--header-color:' . esc_attr($_nav_color_for_header) . ';}</style>';
|
||||
}
|
||||
|
||||
$swiper_config = [
|
||||
@@ -345,7 +361,7 @@ if (!empty($hero_banners)) :
|
||||
</div>
|
||||
|
||||
<?php if ($show_search) : ?>
|
||||
<?php $render_hero_search('header-search-input'); ?>
|
||||
<?php $render_hero_search(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $render_icon_cards(); ?>
|
||||
@@ -381,7 +397,7 @@ if (!empty($hero_banners)) :
|
||||
</div>
|
||||
|
||||
<?php if ($show_search) : ?>
|
||||
<?php $render_hero_search('header-search-input-fallback'); ?>
|
||||
<?php $render_hero_search(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $render_icon_cards(); ?>
|
||||
|
||||
Reference in New Issue
Block a user