243 lines
15 KiB
PHP
243 lines
15 KiB
PHP
<?php
|
||
|
||
/**
|
||
* Hero-секция главной страницы
|
||
* .section-bg .ds-hero
|
||
*
|
||
* @package Dekart
|
||
* @since 1.0.0
|
||
*/
|
||
|
||
if (! defined('ABSPATH')) {
|
||
exit;
|
||
}
|
||
|
||
// ─── ДАННЫЕ ФИЛИАЛА ───
|
||
$branch_phone = get_option('branch_phone') ?: crb_get_theme_option('site_phone');
|
||
$branch_city = get_option('branch_city') ?: crb_get_theme_option('site_city', 'Щёлково');
|
||
$branch_city_prep = get_option('branch_city_prep', 'в Щёлково');
|
||
$branch_addr = get_option('branch_address') ?: crb_get_theme_option('site_address');
|
||
|
||
// ─── УЧЕБНЫЙ ГОД ───
|
||
$current_year = (int) current_time('Y');
|
||
$next_year = $current_year + 1;
|
||
$school_year = $current_year . '/' . $next_year;
|
||
|
||
// ─── ДАННЫЕ СТРАНИЦЫ ───
|
||
$post_id = (int) get_the_ID();
|
||
$foto_id = crb_get_post_meta($post_id, 'banner_img_desktop');
|
||
$banner_src = '';
|
||
$banner_alt = 'Частная школа Декарт' . ( $branch_city ? ' в ' . $branch_city : '' );
|
||
|
||
if ($foto_id) {
|
||
$foto_id = absint($foto_id);
|
||
$banner_src = wp_get_attachment_url($foto_id);
|
||
$_alt = get_post_meta($foto_id, '_wp_attachment_image_alt', true);
|
||
if ($_alt) {
|
||
$banner_alt = $_alt;
|
||
}
|
||
}
|
||
|
||
// ─── СТАТИСТИКА ───
|
||
$hero_stats = crb_get_post_meta($post_id, 'hero_stats');
|
||
if (empty($hero_stats) || ! is_array($hero_stats)) {
|
||
$hero_stats = [
|
||
[ 'stat_number' => '12+', 'stat_label' => 'лет опыта' ],
|
||
[ 'stat_number' => '500+', 'stat_label' => 'выпускников' ],
|
||
[ 'stat_number' => 'до 10', 'stat_label' => 'человек в классе' ],
|
||
];
|
||
}
|
||
|
||
// ─── ЗВЁЗДЫ ───
|
||
$star_svg = '<svg width="18" height="18" viewBox="0 0 20 20" fill="none"><path d="M10 1l2.39 4.84 5.34.78-3.87 3.77.92 5.34L10 13.27l-4.78 2.51.92-5.34L2.27 6.6l5.34-.78L10 1z" fill="currentColor"/></svg>';
|
||
|
||
// ─── ПЛАШКИ (float-блоки) ───
|
||
$floats = [
|
||
[ 'icon' => 'teacher', 'text' => 'Педагоги с опытом от 10 лет' ],
|
||
[ 'icon' => 'users', 'text' => 'Малокомплектные классы — до 15 человек' ],
|
||
[ 'icon' => 'clock', 'text' => 'Уроки до 13:00, продлёнка до 19:00' ],
|
||
];
|
||
|
||
// ─── ФОРМАТИРОВАНИЕ ТЕЛЕФОНА ───
|
||
$phone_clean = $branch_phone ? preg_replace('/[\s\-\–\(\)]/', '', $branch_phone) : '';
|
||
|
||
// ─── СВОБОДНЫЕ МЕСТА ───
|
||
$remaining_seats = (int) get_option('branch_remaining_seats', 0);
|
||
|
||
// ─── МЕССЕНДЖЕРЫ ───
|
||
$branch_messengers = array();
|
||
$msg_wa_url = get_option('branch_messenger_whatsapp', '');
|
||
$msg_tg_url = get_option('branch_messenger_telegram', '');
|
||
$msg_max_url = get_option('branch_messenger_max', '');
|
||
$msg_wa_on = (bool) get_option('branch_messenger_whatsapp_on', 1);
|
||
$msg_tg_on = (bool) get_option('branch_messenger_telegram_on', 1);
|
||
$msg_max_on = (bool) get_option('branch_messenger_max_on', 1);
|
||
|
||
if ($msg_wa_on && $msg_wa_url) {
|
||
$branch_messengers[] = array( 'name' => 'WhatsApp', 'url' => $msg_wa_url );
|
||
}
|
||
if ($msg_tg_on && $msg_tg_url) {
|
||
$branch_messengers[] = array( 'name' => 'Telegram', 'url' => $msg_tg_url );
|
||
}
|
||
if ($msg_max_on) {
|
||
$branch_messengers[] = array( 'name' => 'Max', 'url' => $msg_max_url ?: '#' );
|
||
}
|
||
$extra_msgs = get_option('branch_messenger_extra', array());
|
||
if (! empty($extra_msgs) && is_array($extra_msgs)) {
|
||
foreach ($extra_msgs as $em) {
|
||
if (! empty($em['url'])) {
|
||
$branch_messengers[] = array( 'name' => $em['name'] ?? '', 'url' => $em['url'] );
|
||
}
|
||
}
|
||
}
|
||
?><section class="section-bg ds-hero" data-bg="hero" id="hero-front" aria-labelledby="hero-front-title">
|
||
<div class="ds-container">
|
||
<div class="ds-hero__inner">
|
||
|
||
<div class="ds-hero__content">
|
||
|
||
<?php if ($branch_addr || $branch_city) : ?>
|
||
<div class="ds-hero__address">
|
||
<svg aria-hidden="true" width="16" height="16"><use href="#icon-location-pin"/></svg>
|
||
<span><?php echo esc_html(trim($branch_addr . ( $branch_addr && $branch_city ? ' — ' : '' ) . $branch_city)); ?></span>
|
||
<?php $branch_hours = get_option('branch_hours'); if ($branch_hours) : ?>
|
||
<span class="ds-hero__hours-badge">🕐 <?php echo esc_html($branch_hours); ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<h1 id="hero-front-title" class="ds-hero__h1"><?php echo esc_html(crb_get_post_meta($post_id, 'banner_h1', 'Частная школа ' . $branch_city_prep)); ?></h1>
|
||
|
||
<p class="ds-hero__subtitle">Небольшие классы до 10 человек, опытные педагоги и углублённый английский с 1‑го класса. Учебные занятия проходят в первую половину дня (до 13:00). После обеда — продлёнка с досуговыми занятиями, прогулками и помощью с домашними заданиями (до 19:00). Можно забрать ребёнка после уроков или оставить на продлёнку. В продлёнку входят обед, полдник, помощь с ДЗ и кружки. Индивидуальный подход к каждому ученику. Приходите посмотреть школу и познакомиться с учителем. Открыт набор на <span class="ds-hero__year"><?php echo esc_html($school_year); ?></span> учебный год.</p>
|
||
|
||
<?php if (! empty($floats)) : ?>
|
||
<div class="ds-hero__mobile-usps">
|
||
<?php foreach ($floats as $float) : ?>
|
||
<span class="ds-hero__mobile-usp">
|
||
<svg aria-hidden="true" width="18" height="18"><use href="#icon-<?php echo esc_attr($float['icon']); ?>"/></svg>
|
||
<span><?php echo esc_html($float['text']); ?></span>
|
||
</span>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($hero_stats) : ?>
|
||
<div class="ds-hero__metrics">
|
||
<?php foreach ($hero_stats as $stat) :
|
||
$num = $stat['stat_number'] ?? '';
|
||
$lbl = $stat['stat_label'] ?? '';
|
||
if ('' === $num) {
|
||
continue;
|
||
}
|
||
?>
|
||
<div class="ds-hero__metric reveal">
|
||
<span class="ds-hero__metric-number"><?php echo esc_html($num); ?></span>
|
||
<span class="ds-hero__metric-label"><?php echo esc_html($lbl); ?></span>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<div class="ds-hero__rating-badge">
|
||
<span class="ds-hero__rating-stars" aria-hidden="true">
|
||
<?php for ($i = 1; $i <= 5; $i++) : ?>
|
||
<span class="ds-star ds-star--<?php echo esc_attr($i); ?>"><?php echo wp_kses($star_svg, array( 'svg' => array( 'width' => array(), 'height' => array(), 'viewBox' => array(), 'fill' => array() ), 'path' => array( 'd' => array(), 'fill' => array() ) )); ?></span>
|
||
<?php endfor; ?>
|
||
</span>
|
||
<span class="ds-hero__rating-text"><?php echo esc_html(get_option('branch_rating_text', '4.9 из 5 на основе 190 отзывов на внешних площадках')); ?></span>
|
||
</div>
|
||
|
||
<?php
|
||
$rating_ya = get_option('branch_rating_yandex', '');
|
||
$rating_2gis = get_option('branch_rating_2gis', '');
|
||
if ($rating_ya || $rating_2gis) :
|
||
?>
|
||
<div class="ds-hero__social-proof">
|
||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>
|
||
<span>Лучшая частная школа <?php echo esc_html($branch_city ?: 'Щёлково'); ?> по версии Яндекс.Карт (<?php echo esc_html($rating_ya ?: '5.0'); ?>) и 2GIS (<?php echo esc_html($rating_2gis ?: '4.7'); ?>)</span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($remaining_seats > 0) : ?>
|
||
<div class="ds-hero__seats">Осталось <strong><?php echo esc_html($remaining_seats); ?></strong> мест в 1 класс — успейте записаться!</div>
|
||
<?php endif; ?>
|
||
|
||
<button class="ds-hero__cta-btn btn-write open-bitrix-form">
|
||
Получить консультацию
|
||
</button>
|
||
<noscript>
|
||
<div class="ds-hero__cta-fallback">
|
||
Позвоните: <a href="tel:<?php echo esc_attr($phone_clean ?: '+74951200078'); ?>"><?php echo esc_html($branch_phone ?: '+7 (495) 120-00-78'); ?></a>
|
||
</div>
|
||
</noscript>
|
||
|
||
<div class="ds-hero__assurance">
|
||
<span class="ds-hero__assurance-item">Можно просто прийти и посмотреть</span>
|
||
<span class="ds-hero__assurance-item">Бесплатное тестирование ребёнка</span>
|
||
</div>
|
||
|
||
<?php if ($branch_phone && $phone_clean) : ?>
|
||
<p class="ds-hero__phone">Или позвоните: <a href="tel:<?php echo esc_attr($phone_clean); ?>" aria-label="Позвонить в школу Декарт: <?php echo esc_attr($branch_phone); ?>"><?php echo esc_html($branch_phone); ?></a></p>
|
||
<?php endif; ?>
|
||
|
||
<?php if (! empty($branch_messengers)) : ?>
|
||
<div class="ds-hero__messengers">
|
||
<?php foreach ($branch_messengers as $m) :
|
||
$m_name = $m['name'] ?? '';
|
||
$m_url = $m['url'] ?? '';
|
||
if (! $m_url) {
|
||
continue;
|
||
}
|
||
$m_lower = mb_strtolower($m_name);
|
||
$is_wa = mb_strpos($m_url, 'wa.me') !== false || $m_lower === 'whatsapp';
|
||
$is_tg = mb_strpos($m_url, 't.me') !== false || $m_lower === 'telegram';
|
||
$msg_slug = $is_wa ? 'wa' : ( $is_tg ? 'tg' : 'other' );
|
||
?>
|
||
<a class="ds-hero__msg ds-hero__msg--<?php echo esc_attr($msg_slug); ?>"
|
||
href="<?php echo esc_url($m_url); ?>"
|
||
target="_blank" rel="noopener noreferrer"
|
||
aria-label="<?php echo esc_attr($m_name); ?>">
|
||
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||
<?php if ($is_wa) : ?>
|
||
<path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 0 0 5.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413"/>
|
||
<?php elseif ($is_tg) : ?>
|
||
<path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 1.698 6.147L.02 24l6.469-1.796A12 12 0 0 0 12 24a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm7.502 17.21a7.498 7.498 0 0 1-1.356.807 8.486 8.486 0 0 1-1.82.6 7.44 7.44 0 0 1-2.266.13c-2.09-.27-4.082-1.05-5.61-2.103a18.57 18.57 0 0 1-3.967-3.751A14.8 14.8 0 0 1 2.8 6.106a7.68 7.68 0 0 1 .93-2.905 5.26 5.26 0 0 1 1.08-1.426c.078-.08.157-.149.246-.215.113-.081.226-.161.343-.226.397-.214.838-.221 1.252-.101.21.06.415.139.607.23.285.137.568.278.84.435.09.05.173.115.252.176.326.252.52.572.656.946.08.22.132.448.155.68.053.539.05 1.078-.003 1.611a4.12 4.12 0 0 1-.246.873 5.38 5.38 0 0 1-.34.715c-.104.172-.226.333-.387.446a3.09 3.09 0 0 0-.418.377c-.137.17-.139.375-.028.549a13.482 13.482 0 0 0 1.474 2.005c.018.018.036.035.054.053a13.659 13.659 0 0 0 2.058 1.603c.214.133.398.08.55-.067a4.37 4.37 0 0 1 .902-.72c.397-.24.778-.186 1.125.12.334.294.661.596.983.903.204.195.404.394.589.607.031.036.053.078.077.112a1.81 1.81 0 0 1 .324.603c.062.184.09.375.062.565a2.63 2.63 0 0 1-.218.68 4.98 4.98 0 0 1-.346.639.977.977 0 0 1-.333.322c-.233.148-.479.266-.72.378a3.12 3.12 0 0 1-.525.208c-.214.065-.43.123-.649.163"/>
|
||
<?php else : /* MAX / other */ ?>
|
||
<img loading="lazy" src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/max-logo.svg'); ?>" alt="MAX" width="18" height="18">
|
||
<?php endif; ?>
|
||
</svg>
|
||
<?php echo esc_html($m_name); ?>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
</div>
|
||
|
||
<div class="ds-hero__visual">
|
||
<div class="ds-hero__visual-glow" aria-hidden="true"></div>
|
||
|
||
<div class="ds-hero__photo-wrap">
|
||
<div class="ds-hero__photo-frame">
|
||
<img class="ds-hero__photo"
|
||
src="<?php echo esc_url($banner_src ?: get_template_directory_uri() . '/assets/images/logo-svg.svg'); ?>"
|
||
alt="<?php echo esc_attr($banner_alt); ?>"
|
||
loading="eager" decoding="async"
|
||
width="600" height="600">
|
||
</div>
|
||
<div class="ds-hero__photo-ring" aria-hidden="true"></div>
|
||
</div>
|
||
|
||
<?php foreach ($floats as $idx => $float) : ?>
|
||
<div class="ds-hero__float ds-hero__float--<?php echo esc_attr($idx + 1); ?>">
|
||
<span class="ds-hero__float-icon"><svg aria-hidden="true" width="24" height="24"><use href="#icon-<?php echo esc_attr($float['icon']); ?>"/></svg></span>
|
||
<span><?php echo esc_html($float['text']); ?></span>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|