fix(frontend): align search and header components with reference
This commit is contained in:
1 parent
4c13ef478c
commit
542daca457
34 files changed
+803
-705
No files matched your search
@@ -114,8 +114,11 @@ if (!function_exists('aksrt_header_slide_is_show')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// legacy (Zibll) renders the slider on paged archive pages too; no
|
||||
// pagination exclusion here.
|
||||
// Zibll only displays this component on the first archive page.
|
||||
if ((int) $wp_query->get('paged') > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = class_exists('\\AKSRT\\Settings\\Settings')
|
||||
? \AKSRT\Settings\Settings::get_header_slider_settings()
|
||||
: [];
|
||||
@@ -199,6 +202,18 @@ if (!function_exists('aksrt_header_slider_allowed_html')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_header_slider_image')) {
|
||||
/** @param string $src @param string $class @param string $alt */
|
||||
function aksrt_header_slider_image(string $src, string $class, string $alt): string {
|
||||
$lazy = function_exists('aksrt_is_lazy') && aksrt_is_lazy('lazy_sider');
|
||||
if ($lazy) {
|
||||
$class .= ' swiper-lazy';
|
||||
}
|
||||
$attrs = aksrt_get_lazy_attr('lazy_sider', $src, $class, aksrt_get_lazy_thumb('lg'));
|
||||
return '<img' . $attrs . ' alt="' . esc_attr($alt) . '">';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_get_header_slider_markup')) {
|
||||
/** @param array<string,mixed> $options */
|
||||
function aksrt_get_header_slider_markup(array $options): string {
|
||||
@@ -228,6 +243,7 @@ if (!function_exists('aksrt_get_header_slider_markup')) {
|
||||
}
|
||||
|
||||
$is_mobile = wp_is_mobile();
|
||||
$lazy = function_exists('aksrt_is_lazy') && aksrt_is_lazy('lazy_sider');
|
||||
$slides_html = '';
|
||||
$slide_count = 0;
|
||||
$allow = aksrt_header_slider_allowed_html();
|
||||
@@ -249,23 +265,30 @@ if (!function_exists('aksrt_get_header_slider_markup')) {
|
||||
$link = is_array($slide['link'] ?? null) ? $slide['link'] : [];
|
||||
$title = (string) ($text['title'] ?? '');
|
||||
$alt = trim(wp_strip_all_tags($title));
|
||||
if ($alt === '') {
|
||||
$alt = trim(wp_strip_all_tags((string) ($link['text'] ?? '')));
|
||||
}
|
||||
$alt = $alt !== '' ? $alt . $site_suffix : __('幻灯片', 'aksrt') . $site_suffix;
|
||||
$slide_class = trim((string) ($slide['class'] ?? ''));
|
||||
$background_html = '';
|
||||
|
||||
if ($background_video !== '' && !$is_mobile) {
|
||||
$slide_class .= ' slide-background-video';
|
||||
$background_html = '<video autoplay loop muted playsinline class="fit-cover radius8" src="' . esc_url($background_video) . '"'
|
||||
$background_html = '<video autoplay="" loop="" muted="" class="fit-cover radius8' . ($lazy ? ' lazyload' : '') . '"'
|
||||
. ($lazy ? ' data-src="' . esc_url($background_video) . '" src=""' : ' src="' . esc_url($background_video) . '"')
|
||||
. ($background !== '' ? ' poster="' . esc_url($background) . '"' : '') . '></video><div class="absolute"></div>';
|
||||
} elseif ($video !== '') {
|
||||
$slide_class .= ' slide-dplayer';
|
||||
$background_html = '<video controls playsinline preload="metadata" class="fit-cover radius8" src="' . esc_url($video) . '"'
|
||||
. ($background !== '' ? ' poster="' . esc_url($background) . '"' : '') . '></video>';
|
||||
$background_html = '<div class="new-dplayer" video-url="' . esc_url($video) . '" video-type="auto"><div class="graphic" style="padding-bottom:50%;"><div class="abs-center text-center"><i class="fa fa-play-circle fa-4x muted-3-color opacity5" aria-hidden="true"></i></div></div></div>';
|
||||
if ($background !== '') {
|
||||
$background_html .= '<div class="absolute dplayer-poster"><img class="no-imgbox radius8" src="' . esc_url($background) . '" alt="' . esc_attr($alt) . '"><div class="absolute flex jc play-icon"><span class="toggle-radius"><i class="fa fas fa-play" aria-hidden="true"></i></span></div></div>';
|
||||
$poster_class = 'absolute dplayer-poster' . (!empty($options['gradient_bg']) ? ' gradient-bg' : '');
|
||||
$poster_attrs = !empty($options['gradient_bg']) ? ' data-opacity="0.2"' : '';
|
||||
$background_html .= '<div class="' . esc_attr($poster_class) . '"' . $poster_attrs . '>'
|
||||
. aksrt_header_slider_image($background, 'no-imgbox radius8', $alt)
|
||||
. '<div class="absolute flex jc play-icon"><span class="toggle-radius"><i class="fa fa-play" aria-hidden="true"></i></span></div></div>';
|
||||
}
|
||||
} elseif ($background !== '') {
|
||||
$background_html = '<img class="radius8" src="' . esc_url($background) . '" alt="' . esc_attr($alt) . '">';
|
||||
$background_html = aksrt_header_slider_image($background, 'radius8', $alt);
|
||||
}
|
||||
|
||||
if ($background_html === '') {
|
||||
@@ -274,7 +297,7 @@ if (!function_exists('aksrt_get_header_slider_markup')) {
|
||||
|
||||
$blur_html = '';
|
||||
if (!empty($options['blur_bg']) && $background !== '') {
|
||||
$blur_html = '<div class="slide-blur-bg"><img class="no-imgbox" src="' . esc_url($background) . '" alt="' . esc_attr($alt) . '"></div>';
|
||||
$blur_html = '<div class="slide-blur-bg">' . aksrt_header_slider_image($background, 'no-imgbox', $alt) . '</div>';
|
||||
}
|
||||
|
||||
$layers_html = '';
|
||||
@@ -300,7 +323,7 @@ if (!function_exists('aksrt_get_header_slider_markup')) {
|
||||
if ($scale !== 100) {
|
||||
$layer_attrs .= ' data-swiper-parallax-scale="' . esc_attr((string) ($scale / 100)) . '"';
|
||||
}
|
||||
$layers_html .= '<div class="' . esc_attr($layer_class) . '"' . $layer_attrs . '><img class="radius8" src="' . esc_url((string) $layer['image']) . '" alt="' . esc_attr($alt) . '"></div>';
|
||||
$layers_html .= '<div class="' . esc_attr($layer_class) . '"' . $layer_attrs . '>' . aksrt_header_slider_image((string) $layer['image'], 'radius8', $alt) . '</div>';
|
||||
}
|
||||
|
||||
$text_html = '';
|
||||
|
||||
Reference in new issue
Block a user