Лагерь: Секция Hero FINAL

This commit is contained in:
Dekart Deploy Bot 2026-05-09 13:47:26 +03:00
parent 3f032b2ebb
commit c8d3ac75dc

View File

@ -30,44 +30,49 @@ var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
<main class="camp container_camp">
<?php
// === Получаем данные Carbon Fields один раз ===
$hero_h1 = carbon_get_post_meta( $post_id, 'hero_title_h1' ) ?: 'Детский лагерь Декарт.';
$hero_span = carbon_get_post_meta( $post_id, 'hero_title_span' ) ?: 'Яркое лето без забот!';
$btn_text = carbon_get_post_meta( $post_id, 'hero_btn_primary' ) ?: 'Записаться на пробный день';
$hero_img_id = carbon_get_post_meta( $post_id, 'banner_img' );
/**
* === Все данные из Carbon Fields собираем в одном месте ===
*/
$hero = [
'h1' => carbon_get_post_meta( $post_id, 'hero_title_h1' ) ?: 'Детский лагерь Декарт.',
'span' => carbon_get_post_meta( $post_id, 'hero_title_span' ) ?: 'Яркое лето без забот!',
'btn_text' => carbon_get_post_meta( $post_id, 'hero_btn_primary' ) ?: 'Записаться на пробный день',
'image_id' => carbon_get_post_meta( $post_id, 'banner_img' ),
];
$metrics = [
[
'img' => carbon_get_post_meta( $post_id, 'hero_metric_1_img' ),
'img_id' => carbon_get_post_meta( $post_id, 'hero_metric_1_img' ),
'number' => carbon_get_post_meta( $post_id, 'hero_metric_1_number' ) ?: '90+',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_1_label' ) ?: 'Количество клубов',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_1_label' ) ?: 'Количество клубов',
'default_icon' => get_template_directory_uri() . '/assets/images/doodles/icon-home.png',
],
[
'img' => carbon_get_post_meta( $post_id, 'hero_metric_2_img' ),
'img_id' => carbon_get_post_meta( $post_id, 'hero_metric_2_img' ),
'number' => carbon_get_post_meta( $post_id, 'hero_metric_2_number' ) ?: '570K+',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_2_label' ) ?: 'Юных инноваторов',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_2_label' ) ?: 'Юных инноваторов',
'default_icon' => get_template_directory_uri() . '/assets/images/doodles/icon-bulb.png',
],
[
'img' => carbon_get_post_meta( $post_id, 'hero_metric_3_img' ),
'img_id' => carbon_get_post_meta( $post_id, 'hero_metric_3_img' ),
'number' => carbon_get_post_meta( $post_id, 'hero_metric_3_number' ) ?: '49K+',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_3_label' ) ?: 'Стипендий',
'label' => carbon_get_post_meta( $post_id, 'hero_metric_3_label' ) ?: 'Стипендий',
'default_icon' => get_template_directory_uri() . '/assets/images/doodles/icon-award.png',
],
];
/**
* Вывод одной метрики (встроенная функция для удобства деплоя)
* Вспомогательная функция для вывода одной метрики
*/
if ( ! function_exists( 'render_hero_metric' ) ) :
function render_hero_metric( array $metric ): void {
$icon_url = ! empty( $metric['img'] )
? wp_get_attachment_url( $metric['img'] )
$icon = ! empty( $metric['img_id'] )
? wp_get_attachment_url( $metric['img_id'] )
: $metric['default_icon'];
?>
<div class="wrapper__propositions">
<img src="<?php echo esc_url( $icon_url ); ?>" alt="">
<img src="<?php echo esc_url( $icon ); ?>" alt="">
<h3><?php echo esc_html( $metric['number'] ); ?></h3>
<p><?php echo esc_html( $metric['label'] ); ?></p>
</div>
@ -82,8 +87,8 @@ endif;
<!-- Левая колонка -->
<div class="hero-media-search__content">
<h1 class="heading-1"><?php echo wp_kses_post( $hero_h1 ); ?></h1>
<h2 class="hero-subtitle-brand"><?php echo wp_kses_post( $hero_span ); ?></h2>
<h1 class="heading-1"><?php echo wp_kses_post( $hero['h1'] ); ?></h1>
<h2 class="hero-subtitle-brand"><?php echo wp_kses_post( $hero['span'] ); ?></h2>
<!-- Метрики (десктоп) -->
<div class="hero-media-search__propositions on-desktop">
@ -93,27 +98,28 @@ endif;
<!-- CTA (десктоп) -->
<div class="hero-cta on-desktop">
<p class="hero-cta__text">Записаться на бесплатный пробный день</p>
<a href="#camp-form" class="btn-write-camp" aria-label="<?php echo esc_attr( $btn_text ); ?>">
<?php echo esc_html( $btn_text ); ?>
<a href="#camp-form" class="btn-write-camp" aria-label="<?php echo esc_attr( $hero['btn_text'] ); ?>">
<?php echo esc_html( $hero['btn_text'] ); ?>
</a>
</div>
</div>
<!-- Правая колонка -->
<!-- Правая колонка (изображение + мобильные элементы) -->
<div class="hero-media-search__media">
<div class="hero-media-search__frame">
<?php if ( $hero_img_id ) : ?>
<?php echo wp_get_attachment_image( $hero_img_id, 'large', false, [
<?php if ( $hero['image_id'] ) : ?>
<?php echo wp_get_attachment_image( $hero['image_id'], 'large', false, [
'class' => 'hero-media-search__image',
'loading' => 'eager',
'alt' => 'Дети в лагере Декарт'
'alt' => esc_attr( $hero['h1'] )
] ); ?>
<?php else : ?>
<img class="hero-media-search__image"
src="<?php echo get_template_directory_uri(); ?>/assets/images/camp-hero.jpg"
alt="Дети в лагере Декарт" loading="eager">
alt="<?php echo esc_attr( $hero['h1'] ); ?>" loading="eager">
<?php endif; ?>
<!-- Декоративные элементы -->
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/doodles/hero-doodle-gears.svg"
alt="" class="doodle doodle--top-left">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/doodles/hero-doodle-pencils.svg"
@ -128,8 +134,8 @@ endif;
<div class="hero-cta on-mobile">
<p class="hero-cta__text">Записаться на бесплатный пробный день</p>
<a href="#camp-form" class="btn-write-camp" aria-label="<?php echo esc_attr( $btn_text ); ?>">
<?php echo esc_html( $btn_text ); ?>
<a href="#camp-form" class="btn-write-camp" aria-label="<?php echo esc_attr( $hero['btn_text'] ); ?>">
<?php echo esc_html( $hero['btn_text'] ); ?>
</a>
</div>
</div>