112 lines
5.7 KiB
PHP
112 lines
5.7 KiB
PHP
<?php
|
||
/**
|
||
* Секция «Герой» страницы класса начальной школы.
|
||
* Управляется вкладкой «🖼️ HERO» (Настройки Страницы Класса).
|
||
*
|
||
* @package Dekart
|
||
*/
|
||
|
||
if (! defined('ABSPATH')) {
|
||
exit;
|
||
}
|
||
|
||
$post_id = (int) get_the_ID();
|
||
|
||
$hero_title = crb_get_post_meta($post_id, 'class_hero_title', 'Частная школа 1 класс в Щёлково');
|
||
$hero_subtitle = crb_get_post_meta($post_id, 'class_hero_subtitle', 'Мини-класс до 15 учеников, учитель начальных классов и английский каждый день. Официальное прикрепление к московской школе — аттестат государственного образца.');
|
||
$hero_image = crb_get_post_meta($post_id, 'class_hero_image');
|
||
$hero_btn_text = crb_get_post_meta($post_id, 'class_hero_btn_text', 'Записаться на пробный урок');
|
||
$hero_btn_url = crb_get_post_meta($post_id, 'class_hero_btn_url', '#form');
|
||
|
||
$hero_stats = crb_get_post_meta($post_id, 'class_hero_stats');
|
||
if (empty($hero_stats) || ! is_array($hero_stats)) {
|
||
$hero_stats = array(
|
||
array('stat_number' => 'до 15', 'stat_label' => 'человек в классе'),
|
||
array('stat_number' => '5', 'stat_label' => 'дней в неделю'),
|
||
array('stat_number' => '8:30', 'stat_label' => 'старт занятий'),
|
||
);
|
||
}
|
||
|
||
// ─── Данные филиала ───
|
||
$branch_city = get_option('branch_city') ?: crb_get_theme_option('site_city', 'Щёлково');
|
||
$branch_phone = get_option('branch_phone') ?: crb_get_theme_option('site_phone');
|
||
$phone_clean = $branch_phone ? preg_replace('/[\s\-\–\(\)]/', '', $branch_phone) : '';
|
||
$rating_ya = get_option('branch_rating_yandex', '');
|
||
$rating_2gis = get_option('branch_rating_2gis', '');
|
||
|
||
// ─── Фото героя ───
|
||
$hero_src = '';
|
||
$hero_alt = wp_strip_all_tags($hero_title);
|
||
if ($hero_image) {
|
||
$hero_img = wp_get_attachment_image_src((int) $hero_image, 'large');
|
||
if (is_array($hero_img)) {
|
||
$hero_src = $hero_img[0];
|
||
}
|
||
$hero_alt = get_post_meta((int) $hero_image, '_wp_attachment_image_alt', true) ?: $hero_alt;
|
||
}
|
||
if (! $hero_src) {
|
||
$hero_src = get_template_directory_uri() . '/assets/images/logo-svg.svg';
|
||
}
|
||
?>
|
||
|
||
<section class="class-hero section-bg" data-bg="class-hero" id="class-hero" aria-labelledby="class-hero-title">
|
||
<div class="ds-container">
|
||
<div class="class-hero__inner">
|
||
|
||
<div class="class-hero__content">
|
||
<span class="class-hero__badge">Набор 2026/27 учебный год</span>
|
||
|
||
<h1 id="class-hero-title" class="class-hero__h1"><?php echo esc_html($hero_title); ?></h1>
|
||
|
||
<p class="class-hero__subtitle"><?php echo wp_kses_post($hero_subtitle); ?></p>
|
||
|
||
<?php if ($rating_ya || $rating_2gis) : ?>
|
||
<div class="class-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'); ?>) <span class="ds-hero__rating-nowrap">и 2GIS (<?php echo esc_html($rating_2gis ?: '4.7'); ?>)</span></span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<div class="class-hero__actions">
|
||
<?php if ($hero_btn_url && '#' !== $hero_btn_url) : ?>
|
||
<a class="btn-write btn-primary class-hero__cta" href="<?php echo esc_url($hero_btn_url); ?>"><?php echo esc_html($hero_btn_text); ?></a>
|
||
<?php else : ?>
|
||
<button class="btn-write btn-primary class-hero__cta open-bitrix-form" type="button"><?php echo esc_html($hero_btn_text); ?></button>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($branch_phone && $phone_clean) : ?>
|
||
<a class="class-hero__phone" href="tel:<?php echo esc_attr($phone_clean); ?>"><?php echo esc_html($branch_phone); ?></a>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php if (count($hero_stats) > 0) : ?>
|
||
<ul class="class-hero__stats">
|
||
<?php foreach ($hero_stats as $stat) :
|
||
$num = isset($stat['stat_number']) ? trim($stat['stat_number']) : '';
|
||
$label = isset($stat['stat_label']) ? trim($stat['stat_label']) : '';
|
||
if ('' === $num) {
|
||
continue;
|
||
}
|
||
?>
|
||
<li class="class-hero__stat">
|
||
<span class="class-hero__stat-number"><?php echo esc_html($num); ?></span>
|
||
<span class="class-hero__stat-label"><?php echo esc_html($label); ?></span>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<div class="class-hero__visual">
|
||
<div class="class-hero__visual-glow" aria-hidden="true"></div>
|
||
<img class="class-hero__photo"
|
||
src="<?php echo esc_url($hero_src); ?>"
|
||
alt="<?php echo esc_attr($hero_alt); ?>"
|
||
loading="eager" fetchpriority="high" decoding="async"
|
||
width="1200" height="800">
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|