shkola/wp-content/themes/dekart/front-page.php
2026-09-08 18:38:27 +00:00

390 lines
18 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
Template Name: шаблон главной страницы
*/
get_header();
$post_id = get_the_ID();
// Данные филиала
$branch_email = get_option('branch_email') ?: carbon_get_theme_option('site_mail') ?: '';
$branch_phone = get_option('branch_phone') ?: carbon_get_theme_option('site_phone') ?: '';
$branch_name = get_option('branch_name') ?: carbon_get_theme_option('site_name') ?: 'Декарт';
$branch_city = get_option('branch_city') ?: carbon_get_theme_option('site_city') ?: 'Щёлково';
$branch_city_prep = get_option('branch_city_prep') ?: 'в Щёлково';
$branch_addr = get_option('branch_address') ?: carbon_get_theme_option('site_address') ?: '';
// Рейтинги
$rating_ya = get_option('branch_rating_yandex', '5.0');
$rating_2gis = get_option('branch_rating_2gis', '4.7');
// Динамические URL для JSON-LD
$home_url = home_url('/');
$theme_url = get_template_directory_uri();
$page_url = get_permalink($post_id) ?: $home_url;
$logo_url = '';
if (has_custom_logo()) {
$logo_id = get_theme_mod('custom_logo');
$logo_url = wp_get_attachment_image_url($logo_id, 'full') ?: '';
}
$logo_url = $logo_url ?: $theme_url . '/assets/images/logo-svg.svg';
$site_name = get_option('blogname') ?: 'Декарт';
$yoast_title = get_post_meta($post_id, '_yoast_wpseo_title', true) ?: $site_name;
$yoast_desc = get_post_meta($post_id, '_yoast_wpseo_metadesc', true) ?: '';
$branch_region = get_option('branch_region', 'Московская обл.');
$branch_zip = get_option('branch_zip', '141100');
$branch_coords = get_option('branch_coords');
$branch_lat = '';
$branch_lng = '';
if (! empty($branch_coords) && is_string($branch_coords) && false !== strpos($branch_coords, ',')) {
$parts = explode(',', $branch_coords);
$branch_lat = isset($parts[0]) ? trim($parts[0]) : '';
$branch_lng = isset($parts[1]) ? trim($parts[1]) : '';
}
$branch_lat = $branch_lat ?: get_option('branch_lat', '55.928461');
$branch_lng = $branch_lng ?: get_option('branch_lng', '38.000991');
$area_served_raw = get_option('branch_area_served', 'Щёлково, Фрязино, Ивантеевка');
// FAQ для JSON-LD
$front_faq = carbon_get_post_meta($post_id, 'front_faq');
$faq_has = ! empty($front_faq) && is_array($front_faq);
?>
<main class="main-page">
<?php get_template_part('template-parts/svg-sprite'); ?>
<?php get_template_part('template-parts/hero-front'); ?>
<?php get_template_part('template-parts/answer-block'); ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_services')) : ?>
<?php get_template_part('template-parts/services'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_comparison')) : ?>
<?php get_template_part('template-parts/comparison'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_video')) : ?>
<?php get_template_part('template-parts/video-tour'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_daylife')) : ?>
<?php get_template_part('template-parts/day-in-life'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_teachers')) : ?>
<?php
// Преподаватели
$front_teachers_raw = carbon_get_post_meta($post_id, 'front_teachers');
$front_teacher_ids = array();
if (is_array($front_teachers_raw)) {
foreach ($front_teachers_raw as $item) {
if (! empty($item['teacher_id'])) {
$front_teacher_ids[] = (int) $item['teacher_id'];
}
}
}
$front_teachers_text = carbon_get_post_meta($post_id, 'front_teachers_text');
get_template_part('template-parts/teachers-cards', null, array(
'teacher_ids' => $front_teacher_ids,
'description' => $front_teachers_text ?: '',
));
?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_stories')) : ?>
<?php get_template_part('template-parts/success-stories'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_expert_quotes')) : ?>
<?php get_template_part('template-parts/expert-quotes'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_reviews')) : ?>
<?php get_template_part('template-parts/reviews-link'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_faq')) : ?>
<?php get_template_part('template-parts/faq-front'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_price')) : ?>
<?php get_template_part('template-parts/price-front'); ?>
<?php endif; ?>
<?php if (carbon_get_post_meta($post_id, 'section_visible_cta')) : ?>
<?php get_template_part('template-parts/cta-consultation'); ?>
<?php endif; ?>
<?php
?>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"@id": "<?php echo esc_url($home_url); ?>#website",
"url": "<?php echo esc_url($home_url); ?>",
"name": "<?php echo esc_attr($site_name); ?>",
"description": "<?php echo esc_attr(get_option('branch_description_schema', $site_name)); ?>",
"publisher": { "@id": "<?php echo esc_url($home_url); ?>#organization" },
"inLanguage": "<?php echo esc_attr(determine_locale() ?: 'ru-RU'); ?>",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "<?php echo esc_url($home_url); ?>?s={search_term_string}"
},
"query-input": "required name=search_term_string"
}
},
{
"@type": "WebPage",
"@id": "<?php echo esc_url($page_url); ?>",
"url": "<?php echo esc_url($page_url); ?>",
"name": "<?php echo esc_attr(wp_strip_all_tags($yoast_title)); ?>",
"isPartOf": { "@id": "<?php echo esc_url($home_url); ?>#website" },
"about": { "@id": "<?php echo esc_url($home_url); ?>#organization" },
"description": "<?php echo esc_attr($yoast_desc ?: $site_name); ?>",
"breadcrumb": { "@id": "<?php echo esc_url($page_url); ?>#breadcrumb" },
"inLanguage": "<?php echo esc_attr(determine_locale() ?: 'ru-RU'); ?>",
"dateModified": "<?php echo get_the_modified_date('c'); ?>"
},
{
"@type": "BreadcrumbList",
"@id": "<?php echo esc_url($page_url); ?>#breadcrumb",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Главная страница",
"item": "<?php echo esc_url($home_url); ?>"
}
]
},
{
"@type": ["Organization", "EducationalOrganization", "School", "LocalBusiness"],
"@id": "<?php echo esc_url($home_url); ?>#organization",
"name": "<?php echo esc_attr($branch_name); ?>",
"url": "<?php echo esc_url($home_url); ?>",
"logo": {
"@type": "ImageObject",
"url": "<?php echo esc_url($logo_url); ?>",
"width": 238,
"height": 70
},
"image": "<?php echo esc_url($logo_url); ?>",
"sameAs": <?php
$__sameas = array();
$__vk = get_option('branch_ext_vk') ?: 'https://vk.com/shkola_dekart';
if ($__vk) {
$__sameas[] = $__vk;
}
$__ya = get_option('branch_ext_yandex', '');
if ($__ya) {
$__sameas[] = $__ya;
}
$__gg = get_option('branch_ext_2gis', '');
if ($__gg) {
$__sameas[] = $__gg;
}
$__oz = get_option('branch_ext_otzovik', '');
if ($__oz) {
$__sameas[] = $__oz;
}
$__other_url = get_option('branch_ext_other_url', '');
if ($__other_url) {
$__sameas[] = $__other_url;
}
$__msgr_wa = get_option('branch_messenger_whatsapp', '');
if ($__msgr_wa) {
$__sameas[] = $__msgr_wa;
}
$__msgr_tg = get_option('branch_messenger_telegram', '');
if ($__msgr_tg) {
$__sameas[] = $__msgr_tg;
}
echo wp_json_encode(array_values(array_unique($__sameas)), JSON_UNESCAPED_SLASHES);
unset($__sameas, $__vk, $__ya, $__gg, $__oz, $__other_url, $__msgr_wa, $__msgr_tg);
?>,
"aggregateRating": <?php
$__review_query = new WP_Query(array(
'post_type' => 'reviews', 'post_status' => 'publish',
'posts_per_page' => -1, 'fields' => 'ids',
));
$__ratings = array();
foreach ($__review_query->posts as $__rid) {
$__s = get_post_meta($__rid, '_review_star', true);
if (is_numeric($__s) && $__s >= 1 && $__s <= 5) {
$__ratings[] = (int) $__s;
}
}
$__avg = count($__ratings) > 0 ? round(array_sum($__ratings) / count($__ratings), 1) : get_option('branch_avg_rating', '4.9');
$__cnt = count($__ratings) > 0 ? count($__ratings) : get_option('branch_ext_review_count', '190');
echo wp_json_encode(array(
'@type' => 'AggregateRating', 'ratingValue' => (string) $__avg,
'bestRating' => '5', 'ratingCount' => (string) $__cnt,
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
unset($__review_query, $__ratings, $__avg, $__cnt, $__rid, $__s);
?>,
"priceRange": "<?php echo esc_attr(get_option('branch_price_range', '$$')); ?>",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "<?php echo esc_attr($branch_phone ?: '+79303334151'); ?>",
"email": "<?php echo esc_attr($branch_email ?: 'shelkovo@dekart-school.ru'); ?>",
"contactType": "customer service",
"areaServed": "RU",
"availableLanguage": "Russian"
},
"address": {
"@type": "PostalAddress",
"streetAddress": "<?php echo esc_attr(get_option('branch_address', $branch_addr)); ?>",
"addressLocality": "<?php echo esc_attr($branch_city); ?>",
"addressRegion": "<?php echo esc_attr($branch_region); ?>",
"postalCode": "<?php echo esc_attr($branch_zip); ?>",
"addressCountry": "RU"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": "<?php echo esc_attr($branch_lat); ?>",
"longitude": "<?php echo esc_attr($branch_lng); ?>"
},
"openingHoursSpecification": [
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": [
"http://schema.org/Monday",
"http://schema.org/Tuesday",
"http://schema.org/Wednesday",
"http://schema.org/Thursday",
"http://schema.org/Friday"
],
"opens": "<?php echo esc_attr(get_option('branch_hours_open', '10:00')); ?>",
"closes": "<?php echo esc_attr(get_option('branch_hours_close', '21:00')); ?>"
}
],
"areaServed": <?php
$__areas = array_map('trim', explode(',', $area_served_raw));
echo wp_json_encode(array_map(function ($c) {
return array( '@type' => 'City', 'name' => wp_strip_all_tags($c) );
}, array_filter($__areas)), JSON_UNESCAPED_UNICODE);
unset($__areas);
?>,
"hasCredential": {
"@type": "EducationalOccupationalCredential",
"credentialCategory": "Лицензия на образовательную деятельность",
"recognizedBy": {
"@type": "GovernmentOrganization",
"name": "<?php echo esc_attr(get_option('branch_license_authority', 'Министерство образования Московской области')); ?>"
}
},
"hasOfferCatalog": {
"@type": "OfferCatalog",
"name": "Услуги школы Декарт",
"itemListElement": <?php
$__services = get_option('branch_schema_services');
if (! empty($__services) && is_array($__services)) {
echo wp_json_encode($__services, JSON_UNESCAPED_UNICODE);
} else {
echo wp_json_encode(array(
array( '@type' => 'Offer', 'itemOffered' => array( '@type' => 'Service', 'name' => 'Начальная школа (14 класс)', 'description' => 'Английский язык с 1 класса, мини-классы до 15 человек' ) ),
array( '@type' => 'Offer', 'itemOffered' => array( '@type' => 'Service', 'name' => 'Подготовка к школе', 'description' => 'Программа для будущих первоклассников' ) ),
array( '@type' => 'Offer', 'itemOffered' => array( '@type' => 'Service', 'name' => 'Подготовка к ОГЭ и ЕГЭ', 'description' => 'Интенсивная подготовка к ВПР, ОГЭ и ЕГЭ' ) ),
array( '@type' => 'Offer', 'itemOffered' => array( '@type' => 'Service', 'name' => 'Летний городской лагерь', 'description' => 'Образование, творчество и наука' ) ),
), JSON_UNESCAPED_UNICODE);
}
unset($__services);
?> }
}<?php
// FAQPage JSON-LD
if ($faq_has) :
$faq_main_entity = array();
foreach ($front_faq as $faq_item) {
$q = isset($faq_item['faq_question']) ? trim($faq_item['faq_question']) : '';
$a = isset($faq_item['faq_answer']) ? trim($faq_item['faq_answer']) : '';
if (empty($q) || empty($a)) {
continue;
}
$faq_main_entity[] = array(
'@type' => 'Question', 'name' => wp_strip_all_tags($q),
'acceptedAnswer' => array( '@type' => 'Answer', 'text' => wp_strip_all_tags($a) ),
);
}
if (! empty($faq_main_entity)) : ?>
,{
"@type": "FAQPage",
"@id": "<?php echo esc_url($home_url); ?>#faq",
"name": "Часто задаваемые вопросы о школе Декарт",
"mainEntity": <?php echo wp_json_encode($faq_main_entity, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>
}
<?php endif;
endif; ?>
]
}
</script>
<?php get_template_part('template-parts/contacts'); ?>
<?php get_template_part('template-parts/author-eaat'); ?>
<?php get_template_part('template-parts/sticky-cta'); ?>
<script>
// Scroll depth tracking (GA4)
(function() {
var depths = [25, 50, 75, 100], tracked = {};
function track() {
var pct = Math.round((window.scrollY + window.innerHeight) / document.documentElement.scrollHeight * 100);
depths.forEach(function(d) {
if (pct >= d && !tracked[d] && typeof gtag === 'function') {
tracked[d] = true;
gtag('event', 'scroll_depth', { 'event_category': 'engagement', 'event_label': d + '%', 'value': d, 'non_interaction': true });
}
});
}
var ticking = false;
window.addEventListener('scroll', function() { if (!ticking) { window.requestAnimationFrame(function() { track(); ticking = false; }); ticking = true; } }, { passive: true });
})();
// Exit-intent banner
(function() {
var shown = false, banner = document.getElementById('exit-banner');
if (!banner) return;
function show() { if (!shown) { shown = true; banner.classList.add('exit-banner--visible'); } }
setTimeout(show, 25000);
document.addEventListener('visibilitychange', function() { if (document.visibilityState === 'visible' && !shown) { setTimeout(show, 2000); } });
var lastY = window.scrollY, upCnt = 0;
window.addEventListener('scroll', function() {
var y = window.scrollY;
if (y < lastY && y > 200) { upCnt++; if (upCnt >= 3) { show(); } } else { upCnt = 0; }
lastY = y;
}, { passive: true });
})();
</script>
<?php $exit_phone = get_option('branch_phone') ?: carbon_get_theme_option('site_phone') ?: ''; ?>
<div id="exit-banner" class="exit-banner" aria-label="Остались вопросы?">
<div class="exit-banner__inner">
<div class="exit-banner__content">
<span class="exit-banner__title">Остались вопросы?</span>
<span class="exit-banner__text">Позвоните — расскажем о школе и запишем ребёнка на обучение</span>
</div>
<?php if ($exit_phone) : $exit_clean = preg_replace('/[\s\-\\(\)]/', '', $exit_phone); ?>
<a class="exit-banner__btn" href="tel:<?php echo esc_attr($exit_clean); ?>">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg>
<?php echo esc_html($exit_phone); ?>
</a>
<?php endif; ?>
<button class="exit-banner__close" aria-label="Закрыть" onclick="this.parentElement.parentElement.classList.remove('exit-banner--visible')">
<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"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
</div>
<?php get_footer(); ?>