2026-09-08 18:38:27 +00:00

176 lines
9.8 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
/**
* Шаблон: Контакты + Яндекс.Карта
* Переиспользуемый — не зависит от Pksh_Data.
* Данные: get_option('branch_*') с fallback на carbon_get_theme_option('site_*')
*
* @package Dekart
*/
if (! defined('ABSPATH')) {
exit;
}
$opt_phone = get_option('branch_phone') ?: carbon_get_theme_option('site_phone') ?: '';
$opt_email = get_option('branch_email') ?: carbon_get_theme_option('site_mail') ?: '';
$opt_address = get_option('branch_address') ?: carbon_get_theme_option('site_address') ?: '';
$opt_name = get_option('branch_name') ?: carbon_get_theme_option('site_name') ?: 'Декарт';
$opt_coords = get_option('branch_coords') ?: carbon_get_theme_option('site_location') ?: '';
$opt_work_hours = get_option('branch_work_hours', '');
$opt_logistics_walk = get_option('branch_logistics_walk', '');
$opt_logistics_parking = get_option('branch_logistics_parking', '');
$opt_logistics_nearby = get_option('branch_logistics_schools', '');
$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_url && $msg_wa_on) {
$branch_messengers[] = array( 'name' => 'WhatsApp', 'url' => $msg_wa_url );
}
if ($msg_tg_url && $msg_tg_on) {
$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'] );
}
}
}
$opt_social = get_option('branch_social');
if (empty($opt_social) || ! is_array($opt_social)) {
$opt_social = carbon_get_theme_option('site_social');
}
?>
<section class="contacts" id="contacts" aria-label="Контакты">
<div class="container">
<div class="contacts__header section-header--centered">
<span class="bento-label">Контакты</span>
<h2 class="bento-h2">Наш адрес</h2>
<p class="bento-p">Ждём вас в гости — удобно добираться из любого района города</p>
</div>
<div class="contacts__wrapper">
<div class="contacts__info">
<?php if (! empty($opt_phone)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Телефон:</div>
<a class="contacts__value" href="tel:+<?php echo preg_replace('/[^0-9]/', '', $opt_phone); ?>"><?php echo esc_html($opt_phone); ?></a>
</div>
<?php endif; ?>
<?php if (! empty($branch_messengers)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Напишите нам:</div>
<div class="contacts__messengers">
<?php foreach ($branch_messengers as $m) :
$m_name = $m['name'] ?? '';
$m_url = $m['url'] ?? '';
if (! $m_url) {
continue;
}
?>
<a class="contacts__msg-link" href="<?php echo esc_url($m_url); ?>" target="_blank" rel="noopener noreferrer" title="<?php echo esc_attr($m_name); ?>">
<?php if ($m_name === 'Max') : ?>
<img loading="lazy" src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/max-logo.svg'); ?>" alt="MAX" width="16" height="16" style="vertical-align:middle;margin-right:4px;">
<?php endif; ?>
<?php echo esc_html($m_name); ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (! empty($opt_email)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Почта:</div>
<a class="contacts__value" href="mailto:<?php echo esc_attr($opt_email); ?>"><?php echo esc_html($opt_email); ?></a>
</div>
<?php endif; ?>
<?php if (! empty($opt_address)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Адрес:</div>
<div class="contacts__value"><?php echo esc_html($opt_address); ?></div>
<?php if ($opt_coords) :
$coords_parts = explode(',', str_replace(' ', '', $opt_coords));
if (count($coords_parts) === 2) :
$route_url = 'https://yandex.ru/maps/?rtext=~' . urlencode(trim($coords_parts[0]) . ',' . trim($coords_parts[1]));
?>
<a class="contacts__route-link" href="<?php echo esc_url($route_url); ?>" target="_blank" rel="noopener noreferrer">Построить маршрут →</a>
<?php endif;
endif; ?>
</div>
<?php endif; ?>
<?php if (! empty($opt_work_hours)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Часы работы:</div>
<div class="contacts__value contacts__value--hours"><?php echo esc_html($opt_work_hours); ?></div>
</div>
<?php endif; ?>
<?php if ($opt_logistics_walk || $opt_logistics_parking || $opt_logistics_nearby) : ?>
<div class="contacts__logistics">
<?php if (! empty($opt_logistics_walk)) : ?>
<span class="contacts__logistics-item">
<svg class="contacts__logistics-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z"/><path d="M12 20c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-2Z"/><path d="M10 20H5a2 2 0 0 0-2 2v2"/><path d="M14 22h5a2 2 0 0 0 2-2v-2"/></svg>
<span class="contacts__logistics-text"><?php echo esc_html($opt_logistics_walk); ?></span>
</span>
<?php endif; ?>
<?php if (! empty($opt_logistics_parking)) : ?>
<span class="contacts__logistics-item">
<svg class="contacts__logistics-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 17V7h4a3 3 0 0 1 0 6H9"/></svg>
<span class="contacts__logistics-text"><?php echo esc_html($opt_logistics_parking); ?></span>
</span>
<?php endif; ?>
<?php if (! empty($opt_logistics_nearby)) : ?>
<span class="contacts__logistics-item">
<svg class="contacts__logistics-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9.5 12 3l9 6.5"/><path d="M5 12v7a1 1 0 0 0 1 1h5v-5h2v5h5a1 1 0 0 0 1-1v-7"/><path d="M9 10h6v2H9z"/></svg>
<span class="contacts__logistics-text"><?php echo esc_html($opt_logistics_nearby); ?></span>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (! empty($opt_social) && is_array($opt_social)) : ?>
<div class="contacts__item">
<div class="contacts__subtitle">Наши соцсети:</div>
<div class="contacts__social">
<?php foreach ($opt_social as $item) :
$link = '';
$name = '';
if (is_array($item)) {
$link = $item['url'] ?? $item['link'] ?? '';
$name = $item['name'] ?? $item['title'] ?? '';
} elseif (is_string($item)) {
$link = $item;
}
if ($link) : ?>
<a class="contacts__social-link" href="<?php echo esc_url($link); ?>" target="_blank" rel="noopener noreferrer" title="<?php echo esc_attr($name); ?>">
<?php echo esc_html($name ?: $link); ?>
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="contacts__map">
<div id="ya-map" style="width: 100%; height: 100%;"
data-coords="<?php echo esc_attr($opt_coords ?: ( get_option('branch_lat', '55.928461') . ',' . get_option('branch_lng', '38.000991') )); ?>"
data-label="<?php echo esc_attr($opt_name ?: 'Частная школа «Декарт»'); ?>"></div>
</div>
</div>
</div>
</section>