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
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/** Render-level harness for the header multifunction component. */
|
||||
|
||||
namespace AKSRT\Core {
|
||||
final class Color {
|
||||
public static function sanitize(string $value): string { return $value; }
|
||||
}
|
||||
}
|
||||
|
||||
namespace AKSRT\Settings {
|
||||
final class Settings {
|
||||
public static array $headerSlider = [];
|
||||
public static function get_header_slider_settings(): array { return self::$headerSlider; }
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
define('ABSPATH', __DIR__);
|
||||
$GLOBALS['aksrt_mobile'] = false;
|
||||
$GLOBALS['aksrt_lazy'] = true;
|
||||
|
||||
final class WP_Query {
|
||||
public function get(string $key) { return 0; }
|
||||
}
|
||||
$GLOBALS['wp_query'] = new WP_Query();
|
||||
|
||||
function is_admin(): bool { return false; }
|
||||
function wp_is_mobile(): bool { return !empty($GLOBALS['aksrt_mobile']); }
|
||||
function is_author(): bool { return false; }
|
||||
function is_front_page(): bool { return true; }
|
||||
function is_category(): bool { return false; }
|
||||
function is_tag(): bool { return false; }
|
||||
function is_singular($type = ''): bool { return false; }
|
||||
function is_search(): bool { return false; }
|
||||
function is_page(): bool { return false; }
|
||||
function is_home(): bool { return false; }
|
||||
function get_query_var(string $key) { return ''; }
|
||||
function sanitize_key($value): string { return preg_replace('/[^a-z0-9_-]/', '', strtolower((string) $value)); }
|
||||
function sanitize_html_class($value): string { return preg_replace('/[^a-zA-Z0-9_-]/', '', (string) $value); }
|
||||
function wp_parse_args($args, array $defaults = []): array { return array_merge($defaults, is_array($args) ? $args : []); }
|
||||
function esc_url($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
|
||||
function esc_url_raw($value): string { return (string) $value; }
|
||||
function esc_attr($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
|
||||
function esc_html($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
|
||||
function wp_strip_all_tags($value): string { return strip_tags((string) $value); }
|
||||
function __($value, $domain = ''): string { return (string) $value; }
|
||||
function get_bloginfo($show = ''): string { return 'AKSRT'; }
|
||||
function home_url($path = ''): string { return 'https://example.test/' . ltrim((string) $path, '/'); }
|
||||
function wp_kses($value, $allowed = []): string { return (string) $value; }
|
||||
function aksrt_is_lazy(string $key): bool { return !empty($GLOBALS['aksrt_lazy']); }
|
||||
function aksrt_get_lazy_thumb(string $size = ''): string { return 'https://example.test/placeholder.svg'; }
|
||||
function aksrt_get_lazy_attr(string $key, string $src, string $class = '', string $lazy_src = ''): string {
|
||||
if (aksrt_is_lazy($key)) {
|
||||
return ' class="lazyload ' . esc_attr($class) . '" src="' . esc_url($lazy_src) . '" data-src="' . esc_url($src) . '"';
|
||||
}
|
||||
return ' class="' . esc_attr($class) . '" src="' . esc_url($src) . '"';
|
||||
}
|
||||
function aksrt_get_search_box(array $args = []): string { return '<div class="search-input">search-box</div>'; }
|
||||
function aksrt_icon_cover_card(array $card): string {
|
||||
return '<div class="icon-cover-card flex ac ' . esc_attr((string) ($card['class'] ?? '')) . '">' . esc_html((string) ($card['title'] ?? '')) . '</div>';
|
||||
}
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/inc/helpers/homepage/header-components.php';
|
||||
|
||||
$slides = [
|
||||
['background' => 'https://example.test/slide.jpg', 'link' => ['url' => 'https://example.test/one', 'target' => '_blank', 'text' => 'One'], 'text' => ['title' => 'Title', 'desc' => 'Description'], 'image_layer' => [['image' => 'https://example.test/layer.png', 'free_size' => true, 'align' => 'right', 'parallax' => 40, 'parallax_opacity' => 80, 'parallax_scale' => 110]]],
|
||||
['background_video' => 'https://example.test/background.mp4', 'background' => 'https://example.test/poster.jpg'],
|
||||
['video' => 'https://example.test/content.mp4', 'background' => 'https://example.test/content-poster.jpg'],
|
||||
['background' => 'https://example.test/pc-only.jpg', 'hide' => 'm'],
|
||||
['background' => 'https://example.test/mobile-only.jpg', 'hide' => 'pc'],
|
||||
];
|
||||
$settings = [
|
||||
'slides' => $slides,
|
||||
'show_on_pages' => ['home'],
|
||||
'show_type' => '',
|
||||
'nav_color' => '#ffffff',
|
||||
'slider_config' => ['loop' => true, 'autoplay' => true, 'interval' => 6, 'pagination' => true],
|
||||
'search_show' => ['pc_s', 'm_s'],
|
||||
'search_config' => ['before_html' => '<div>Search intro</div>'],
|
||||
'card_show' => ['pc_s', 'm_s'],
|
||||
'card_config' => ['show_widget_bg' => false, 'cards' => [['icon' => 'fa fas fa-star', 'title' => 'Card one']]],
|
||||
'filter_blur' => ['pc_s', 'm_s'],
|
||||
];
|
||||
\AKSRT\Settings\Settings::$headerSlider = $settings;
|
||||
|
||||
ob_start();
|
||||
aksrt_header_slide();
|
||||
$desktop = (string) ob_get_clean();
|
||||
|
||||
$GLOBALS['aksrt_mobile'] = true;
|
||||
ob_start();
|
||||
aksrt_header_slide();
|
||||
$mobile = (string) ob_get_clean();
|
||||
|
||||
$settings['card_config']['show_widget_bg'] = true;
|
||||
\AKSRT\Settings\Settings::$headerSlider = $settings;
|
||||
ob_start();
|
||||
aksrt_header_slide();
|
||||
$module_background = (string) ob_get_clean();
|
||||
|
||||
$GLOBALS['aksrt_mobile'] = false;
|
||||
$GLOBALS['aksrt_lazy'] = false;
|
||||
$lazy_disabled = aksrt_get_header_slider_markup([
|
||||
'slides' => [['background' => 'https://example.test/eager.jpg']],
|
||||
'class' => 'slide-index slide-header',
|
||||
]);
|
||||
$single_slide = aksrt_get_header_slider_markup([
|
||||
'slides' => [['background' => 'https://example.test/single.jpg']],
|
||||
'class' => 'slide-index slide-header',
|
||||
'pagination' => true,
|
||||
'button' => true,
|
||||
]);
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/src/Admin/PageConfigMetaBox.php';
|
||||
$sanitize_cards = new \ReflectionMethod('AKSRT\\Admin\\PageConfigMetaBox', 'sanitize_card_options');
|
||||
$page_config_save = $sanitize_cards->invoke(null, ['show_widget_bg' => true, 'cards' => []]);
|
||||
|
||||
echo json_encode([
|
||||
'desktop' => $desktop,
|
||||
'mobile' => $mobile,
|
||||
'module_background' => $module_background,
|
||||
'lazy_disabled' => $lazy_disabled,
|
||||
'single_slide' => $single_slide,
|
||||
'page_config_save' => $page_config_save,
|
||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
Reference in new issue
Block a user