2026-10-06 21:46:21 +00:00

97 lines
3.6 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
// Блок доверия
if (! defined('ABSPATH')) {
exit;
}
$post_id = (int) get_the_ID();
$trust = carbon_get_post_meta($post_id, 'teachers_trust');
$trust_items = array();
if (is_array($trust)) {
foreach ($trust as $t) {
$num = $t['trust_number'] ?? '';
$label = $t['trust_label'] ?? '';
if (! $num || ! $label) {
continue;
}
$trust_items[] = array( 'num' => $num, 'label' => $label );
}
}
if (empty($trust_items)) {
// Дефолт без хардкода — считаем из данных
$teachers_count = (int) wp_count_posts('teacher')->publish;
$years = array();
$cur = (int) current_time('Y');
foreach (get_posts(array(
'post_type' => 'teacher',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
'no_found_rows' => true,
)) as $tid) {
$sy = (int) get_post_meta($tid, '_teacher_start_year', true);
if ($sy > 1900 && $sy <= $cur) {
$years[] = $cur - $sy;
}
}
$avg_years = $years ? (int) round(array_sum($years) / count($years)) : 0;
$group = get_option('branch_group_size') ?: '2-6';
if ($teachers_count) {
$trust_items[] = array( 'num' => (string) $teachers_count, 'label' => 'педагогов в команде' );
}
if ($avg_years) {
$trust_items[] = array( 'num' => $avg_years, 'label' => 'лет — средний педагогический стаж' );
}
$trust_items[] = array( 'num' => $group, 'label' => 'человек в мини-группе — внимание как на репетиторе' );
}
if (empty($trust_items)) {
return;
}
// Внешние площадки школы
$trust_links = array();
$trust_map = array(
'Яндекс Бизнес' => get_option('branch_yandex_business_url'),
'2ГИС' => get_option('branch_ext_2gis'),
'Google' => get_option('branch_google_business_url'),
'VK' => '',
);
foreach ((array) get_option('branch_social', array()) as $s) {
$sn = mb_strtolower(trim((string) ( $s['name'] ?? '' )));
$su = trim((string) ( $s['url'] ?? '' ));
if ('' !== $su && ( false !== mb_strpos($sn, 'vk') || false !== mb_strpos($sn, 'вк') || false !== mb_strpos($sn, 'вконтакте') )) {
$trust_map['VK'] = $su;
}
}
foreach ($trust_map as $t_label => $t_url) {
if (! empty($t_url) && filter_var($t_url, FILTER_VALIDATE_URL)) {
$trust_links[ $t_label ] = $t_url;
}
}
?>
<section class="teachers-trust section-bg reveal" data-bg="teachers-trust" aria-label="Цифры о преподавателях">
<div class="container">
<div class="teachers-trust__grid">
<?php foreach ($trust_items as $ti) : ?>
<div class="teachers-trust__item">
<div class="teachers-trust__number"><?php echo esc_html($ti['num']); ?></div>
<div class="teachers-trust__label"><?php echo esc_html($ti['label']); ?></div>
</div>
<?php endforeach; ?>
</div>
<?php if (! empty($trust_links)) : ?>
<div class="teachers-trust__profiles">
<span class="teachers-trust__profiles-label">Мы на площадках:</span>
<?php foreach ($trust_links as $t_label => $t_url) : ?>
<a class="teachers-trust__profile" href="<?php echo esc_url($t_url); ?>" target="_blank" rel="noopener nofollow"><?php echo esc_html($t_label); ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</section>