1
<?php
2
3
defined('ABSPATH') || exit;
4
5
get_header();
6
$config = \MeinWeimar\Settings::public_config();
7
$hero = (array) ($config['hero'] ?? []);
8
$hero_colors = (array) ($hero['colors'] ?? []);
9
$localization = (array) ($config['localization'] ?? []);
10
$available_locales = array_values(array_filter(array_map('sanitize_text_field', (array) ($config['locales'] ?? []))));
11
$locale = sanitize_text_field((string) get_locale());
12
$locale = in_array($locale, $available_locales, true) ? $locale : (string) ($localization['default_locale'] ?? ($available_locales[0] ?? 'de_DE'));
13
$fallback_locale = (string) ($localization['fallback_locale'] ?? ($available_locales[0] ?? $locale));
14
$localized = static function ($values) use ($locale, $fallback_locale): string {
15
$values = is_array($values) ? $values : [];
16
foreach ([$locale, $fallback_locale] as $candidate) {
17
$value = trim((string) ($values[$candidate] ?? ''));
18
if ('' !== $value) {
19
return $value;
20
}
21
}
22
foreach ($values as $value) {
23
$value = trim((string) $value);
24
if ('' !== $value) {
25
return $value;
26
}
27
}
28
return '';
29
};
30
$hero_image = (array) ($hero['image'] ?? []);
31
$hero_logo = (array) ($hero['logo'] ?? []);
32
$hero_image_url = (string) ($hero_image['url'] ?? $hero['image_url'] ?? '');
33
$hero_image_srcset = (string) ($hero_image['srcset'] ?? '');
34
$hero_image_alt = (string) ($hero_image['alt'] ?? '');
35
$hero_logo_url = (string) ($hero_logo['url'] ?? '');
36
$hero_logo_srcset = (string) ($hero_logo['srcset'] ?? '');
37
$hero_logo_alt = (string) ($hero_logo['alt'] ?? ($config['brand']['wordmark'] ?? ''));
38
$hero_title = $localized($hero['title'] ?? []);
39
$hero_body = $localized($hero['body'] ?? []);
40
$hero_eyebrow = $localized($hero['eyebrow'] ?? []);
41
$hero_primary_label = $localized($hero['primary_label'] ?? []);
42
$hero_primary_url = $localized($hero['primary_url'] ?? []);
43
$hero_secondary_label = $localized($hero['secondary_label'] ?? []);
44
$hero_secondary_url = $localized($hero['secondary_url'] ?? []);
45
$hero_height_mode = 'image' === ($hero['height_mode'] ?? '') ? 'image' : 'content';
46
$hero_image_fit = 'contain' === ($hero['image_fit'] ?? '') ? 'contain' : 'cover';
47
$brand_style = sprintf(
48
'--mw-primary:%s;--mw-secondary:%s;--mw-hero-title:%s;--mw-hero-body:%s;--mw-hero-eyebrow:%s;--mw-hero-button:%s;--mw-hero-button-text:%s;--mw-hero-secondary-button:%s;--mw-hero-secondary-button-text:%s;',
49
esc_attr((string) ($config['brand']['primary_color'] ?? '#ff1e6e')),
50
esc_attr((string) ($config['brand']['secondary_color'] ?? '#20242e')),
51
esc_attr((string) ($hero_colors['title'] ?? '#ffffff')),
52
esc_attr((string) ($hero_colors['body'] ?? '#ffffff')),
53
esc_attr((string) ($hero_colors['eyebrow'] ?? ($config['brand']['primary_color'] ?? '#ff1e6e'))),
54
esc_attr((string) ($hero_colors['button'] ?? ($config['brand']['primary_color'] ?? '#ff1e6e'))),
55
esc_attr((string) ($hero_colors['button_text'] ?? '#ffffff')),
56
esc_attr((string) ($hero_colors['secondary_button'] ?? ($config['brand']['secondary_color'] ?? '#20242e'))),
57
esc_attr((string) ($hero_colors['secondary_button_text'] ?? '#ffffff'))
58
);
59
?>
60
<main class="mw-front-page" style="<?php echo esc_attr($brand_style); ?>">
61
<section class="mw-front-page__hero mw-front-page__hero--<?php echo esc_attr($hero_height_mode); ?>" aria-labelledby="mw-front-page-title">
62
<?php if ($hero_image_url) : ?>
63
<img class="mw-front-page__hero-image" src="<?php echo esc_url($hero_image_url); ?>"<?php if ($hero_image_srcset) : ?> srcset="<?php echo esc_attr($hero_image_srcset); ?>" sizes="(max-width: 700px) 100vw, 1280px"<?php endif; ?> alt="<?php echo esc_attr($hero_image_alt); ?>" data-fit="<?php echo esc_attr($hero_image_fit); ?>">
64
<?php endif; ?>
65
<div class="mw-front-page__hero-overlay" aria-hidden="true"></div>
66
<div class="mw-front-page__hero-content">
67
<?php if ($hero_logo_url) : ?>
68
<img class="mw-front-page__hero-logo" src="<?php echo esc_url($hero_logo_url); ?>"<?php if ($hero_logo_srcset) : ?> srcset="<?php echo esc_attr($hero_logo_srcset); ?>" sizes="(max-width: 700px) 160px, 240px"<?php endif; ?> alt="<?php echo esc_attr($hero_logo_alt); ?>">
69
<?php endif; ?>
70
<?php if ($hero_eyebrow) : ?><p class="mw-front-page__eyebrow"><?php echo esc_html($hero_eyebrow); ?></p><?php endif; ?>
71
<?php if ($hero_title) : ?><h1 id="mw-front-page-title"><?php echo esc_html($hero_title); ?></h1><?php endif; ?>
72
<?php if ($hero_body) : ?><p class="mw-front-page__hero-body"><?php echo esc_html($hero_body); ?></p><?php endif; ?>
73
<?php if (($hero_primary_label && $hero_primary_url) || ($hero_secondary_label && $hero_secondary_url)) : ?>
74
<div class="mw-front-page__hero-actions">
75
<?php if ($hero_primary_label && $hero_primary_url) : ?><a class="mw-front-page__hero-button mw-front-page__hero-button--primary" href="<?php echo esc_url($hero_primary_url); ?>"><?php echo esc_html($hero_primary_label); ?></a><?php endif; ?>
76
<?php if ($hero_secondary_label && $hero_secondary_url) : ?><a class="mw-front-page__hero-button mw-front-page__hero-button--secondary" href="<?php echo esc_url($hero_secondary_url); ?>"><?php echo esc_html($hero_secondary_label); ?></a><?php endif; ?>
77
</div>
78
<?php endif; ?>
79
</div>
80
</section>
81
<section id="discover" aria-label="<?php echo esc_attr($hero_primary_label ?: $hero_title); ?>">
82
<?php echo \MeinWeimar\Renderer::discovery_markup(['type' => 'all', 'per_page' => 12]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
83
</section>
84
</main>
85
<?php
86
get_footer();
87