slider | search overlay (before + form + after) | cards * * @package AKSRT * @version 4.2.0 */ defined('ABSPATH') || exit; // Visibility (page type + device) is decided by aksrt_header_slide_is_show(). // This partial only renders content when already gated by aksrt_header_slide(). $cfg = get_query_var('aksrt_module_config', []); if (!is_array($cfg)) { $cfg = []; } $hero_banners = function_exists('aksrt_get_banners') ? aksrt_get_banners(8, 'hero') : []; $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, 'show_keywords' => false, 'popular_limit' => 6, 'show_input_cat' => false, 'show_type' => false, 'in_cat' => '', 'in_type' => 'post', 'more_cats' => [], 'before_html' => '', 'after_html' => '', ]; // 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_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); // 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 ($filter_blur_on) { $container_classes[] = 'filter-blur'; } if (in_array('pc', $filter_blur_devices, true)) { $container_classes[] = 'has-blur-pc'; } if (in_array('mobile', $filter_blur_devices, true)) { $container_classes[] = 'has-blur-mobile'; } /** * 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 () 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) !== '' ? '
' : ''; $after_html = trim($_after) !== '' ? '' : ''; echo ''; }; $render_icon_cards = static function () use ($show_cards, $icon_cards, $card_bg_mode, $card_icon_shape): void { if (!$show_cards || empty($icon_cards)) { return; } /** * Overlay icon cards — 1:1 zibll zib_header_slide() card module. * * show_widget_bg (shared) → outer .zib-widget.padding-10 + each card class=padding-10 in .relative-h * individual (default) → outer empty div + each card class=zib-widget in .flex1 * Row: .flex.jse.flex-row.gutters-5.flex-col-sm-2 */ $show_widget_bg = ($card_bg_mode === 'shared'); $icon_radius4 = ($card_icon_shape === 'square'); $slider_card_html = ''; foreach ($icon_cards as $raw) { if (!is_array($raw)) { continue; } $card = $raw; $card['class'] = $show_widget_bg ? 'padding-10' : 'zib-widget'; $extra = trim((string) ($card['icon_class'] ?? '')); if ($icon_radius4 && !str_contains($extra, 'radius4')) { $extra = trim($extra . ' radius4'); } $card['icon_class'] = $extra; unset($card['icon_shape']); $wrap_class = $show_widget_bg ? 'relative-h' : 'flex1'; $inner = function_exists('aksrt_icon_cover_card') ? aksrt_icon_cover_card($card) : (function_exists('aksrt_render_icon_cover_card') ? aksrt_render_icon_cover_card($card) : ''); if ($inner === '') { continue; } $slider_card_html .= '