shkola/wp-content/themes/dekart/front-page.php
Dekart Deploy Bot 0a6e9f88cf GLOBAL
2026-10-12 11:59:03 +00:00

405 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
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');
$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_postal_code') ?: get_option('branch_zip') ?: carbon_get_theme_option('site_index') ?: '';
$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');
$branch_lng = $branch_lng ?: get_option('branch_lng');
$area_served_raw = get_option('branch_area_served', 'Щёлково, Фрязино, Ивантеевка');
?>
<main class="main-page">
<?php get_template_part('template-parts/hero-front'); ?>
<?php get_template_part('template-parts/internal-links'); ?>
<?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
?>
<?php
$schema_website_desc = get_option('branch_schema_description') ?: get_option('branch_description_schema') ?: sprintf('Частная школа «%s» %s', $branch_name, $branch_city_prep);
if (function_exists('dekart_strip_grade_range')) {
$schema_website_desc = dekart_strip_grade_range($schema_website_desc);
}
$__range = function_exists('dekart_family_grade_range') ? dekart_family_grade_range() : '';
$__range_suffix = ('' !== $__range) ? 'Обучение ' . $__range . ' классы.' : '';
$__join = static function (string $text, string $suffix): string {
$text = trim($text);
if ('' === $suffix) {
return $text;
}
if ('' === $text) {
return $suffix;
}
return preg_match('/[.!?]$/u', $text) ? $text . ' ' . $suffix : rtrim($text, " ,;") . '. ' . $suffix;
};
$schema_website_desc = $__join($schema_website_desc, $__range_suffix);
$schema_webpage_desc = $__join(
function_exists('dekart_strip_grade_range') ? dekart_strip_grade_range($yoast_desc ?: $site_name) : ($yoast_desc ?: $site_name),
$__range_suffix
);
?>
<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); ?>",
"alternateName": ["Dekart", "Школа Декарт", "Учебный центр Декарт"],
"description": "<?php echo esc_attr($schema_website_desc); ?>",
"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($schema_webpage_desc); ?>",
"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 . '»' . ($branch_city_prep ? ' ' . $branch_city_prep : '')); ?>",
"alternateName": ["Dekart", "Школа Декарт", "Учебный центр Декарт"],
"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);
?>,
<?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 = '';
$__cnt = 0;
if (! empty($__ratings)) {
$__avg = round(array_sum($__ratings) / count($__ratings), 1);
$__cnt = count($__ratings);
} else {
$__cf_avg = str_replace(',', '.', (string) get_option('branch_avg_rating', ''));
if ('' !== $__cf_avg && is_numeric($__cf_avg)) {
$__avg = $__cf_avg;
$__cnt = (int) get_option('branch_reviews_count', 0);
}
}
if ('' !== (string) $__avg && $__cnt > 0) {
echo '"aggregateRating": ' . 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);
?>
<?php
$__price_range = trim((string) get_option('branch_price_range'));
if ('' !== $__price_range && ! preg_match('/^\$+$/', $__price_range)) {
echo '"priceRange": ' . wp_json_encode($__price_range, JSON_UNESCAPED_UNICODE) . ',';
}
unset($__price_range);
?>
"contactPoint": {
"@type": "ContactPoint",
<?php if ($branch_phone) : ?>
"telephone": "<?php echo esc_attr($branch_phone); ?>",
<?php endif; ?>
<?php if ($branch_email) : ?>
"email": "<?php echo esc_attr($branch_email); ?>",
<?php endif; ?>
"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); ?>",
<?php if ($branch_zip) : ?>
"postalCode": "<?php echo esc_attr($branch_zip); ?>",
<?php endif; ?>
"addressCountry": "RU"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": "<?php echo esc_attr($branch_lat); ?>",
"longitude": "<?php echo esc_attr($branch_lng); ?>"
},
<?php
$__hours = function_exists('dekart_schema_opening_hours') ? dekart_schema_opening_hours() : array();
if (! empty($__hours)) {
echo '"openingHoursSpecification": ' . wp_json_encode($__hours, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ',';
}
unset($__hours);
?>
"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');
$__offers = (! empty($__services) && is_array($__services))
? $__services
: (function_exists('dekart_front_offers') ? dekart_front_offers() : array());
// только свои услуги: чужие домены из каталога выкидываем
$__offers = function_exists('dekart_filter_offer_catalog') ? dekart_filter_offer_catalog($__offers) : $__offers;
echo wp_json_encode(array_values($__offers), JSON_UNESCAPED_UNICODE);
unset($__services, $__offers);
?> }
}
]
}
</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>
(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 });
})();
(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(); ?>