2026-10-04 GLOBAL

This commit is contained in:
Dekart Deploy Bot 2026-10-04 20:02:48 +00:00
parent acc593a8c2
commit 453035ea4b
2 changed files with 29 additions and 26 deletions

View File

@ -285,11 +285,24 @@ foreach ((array) get_option('branch_programs', array()) as $bp) {
$teacher_subjects = (array) carbon_get_post_meta($tid, 'teacher_subjects'); $teacher_subjects = (array) carbon_get_post_meta($tid, 'teacher_subjects');
$subject_items = array(); // без дубликатов $subject_items = array(); // без дубликатов
foreach ($teacher_subjects as $ts) { foreach ($teacher_subjects as $ts) {
$sn = trim((string) ( $ts['teacher_subjects_title'] ?? '' )); // Название: CF-select «Программа» → легаси select_direction
$sn = $ts['teacher_subjects_title'] ?? '';
if (is_array($sn)) {
$sn = reset($sn);
}
$sn = trim((string) $sn);
if ('' === $sn) {
$sn_legacy = $ts['select_direction'] ?? '';
if (is_array($sn_legacy)) {
$sn_legacy = reset($sn_legacy);
}
$sn = trim((string) $sn_legacy);
}
if ('' === $sn) { if ('' === $sn) {
continue; continue;
} }
if (isset($subject_items[$sn])) { $sn_key = mb_strtolower($sn);
if (isset($subject_items[$sn_key])) {
continue; // дубликат заголовка — пропускаем continue; // дубликат заголовка — пропускаем
} }
$topics = array(); $topics = array();
@ -303,14 +316,14 @@ foreach ($teacher_subjects as $ts) {
} }
} }
$prog = $branch_programs_by_name[ $sn ] ?? null; $prog = $branch_programs_by_name[ $sn ] ?? null;
$subject_items[$sn] = array( $subject_items[$sn_key] = array(
'name' => $sn, 'name' => $sn,
'url' => ( $prog && '' !== $prog['url'] ) ? $prog['url'] : trim((string) ( $ts['teacher_subjects_url'] ?? '' )), 'url' => ( $prog && '' !== $prog['url'] ) ? $prog['url'] : trim((string) ( $ts['teacher_subjects_url'] ?? '')),
'price' => ( $prog && '' !== $prog['price'] ) ? $prog['price'] : '', 'price' => ( $prog && '' !== $prog['price'] ) ? $prog['price'] : '',
'topics' => $topics, 'topics' => $topics,
); );
} }
$subject_names = array_keys($subject_items); $subject_names = array_map(function ($it) { return $it['name']; }, array_values($subject_items));
// ─── Данные филиала ─── // ─── Данные филиала ───
$branch_price = get_option('branch_price'); $branch_price = get_option('branch_price');
@ -375,24 +388,12 @@ if ($sp_avg_num > 0 && $review_count > 0) {
'bestRating' => '5', 'bestRating' => '5',
); );
$teacher_reviews = get_posts(array( // Единый источник отзывов — тот же, что видимый блок
'post_type' => 'reviews', $teacher_reviews = function_exists('dekart_teacher_review_ids') ? dekart_teacher_review_ids($tid) : array();
'post_status' => 'publish',
'posts_per_page' => 5,
'orderby' => 'date',
'order' => 'DESC',
'fields' => 'ids',
'no_found_rows' => true,
'meta_query' => array(
array( 'key' => '_review_teacher|||0|id', 'value' => (string) $tid, 'compare' => '=' ),
),
));
$review_items = array(); $review_items = array();
foreach ($teacher_reviews as $rid) { foreach ($teacher_reviews as $rid) {
$star = (int) carbon_get_post_meta($rid, 'review_star'); $star = (int) ( carbon_get_post_meta($rid, 'review_star') ?: 5 );
if ($star < 1 || $star > 5) { $star = min(5, max(1, $star));
continue;
}
$item = array( $item = array(
'@type' => 'Review', '@type' => 'Review',
'author' => array( '@type' => 'Person', 'name' => wp_strip_all_tags(get_the_title($rid)) ), 'author' => array( '@type' => 'Person', 'name' => wp_strip_all_tags(get_the_title($rid)) ),
@ -456,7 +457,7 @@ $build_course = function ( $name, $cid, $availability = null, $description = '',
), ),
'offers' => array( 'offers' => array(
'@type' => 'Offer', '@type' => 'Offer',
'category' => 'Мини-группа 2–' . $group_size . ' человек', 'category' => 'Мини-группа ' . $group_size . ' человек',
), ),
); );
// Цена — микроразметка; число из строки // Цена — микроразметка; число из строки
@ -473,8 +474,10 @@ $build_course = function ( $name, $cid, $availability = null, $description = '',
}; };
$courses = array(); $courses = array();
if (! empty($subject_names)) { if (! empty($subject_items)) {
foreach ($subject_names as $i => $cn) { $ci = 0;
foreach ($subject_items as $item) {
$ci++;
// >0 Limited, =0 SoldOut, пусто — нет // >0 Limited, =0 SoldOut, пусто — нет
$availability = null; $availability = null;
if ('' !== (string) $seats_left) { if ('' !== (string) $seats_left) {
@ -482,7 +485,7 @@ if (! empty($subject_names)) {
? 'https://schema.org/LimitedAvailability' ? 'https://schema.org/LimitedAvailability'
: 'https://schema.org/SoldOut'; : 'https://schema.org/SoldOut';
} }
$courses[] = $build_course($cn, $i + 1, $availability, '', $subject_items[$cn]['price']); $courses[] = $build_course($item['name'], $ci, $availability, '', $item['price']);
} }
} else { } else {
$courses[] = $build_course( ( $subj ? $subj : 'Обучение' ) . ' — мини-группы ' . $group_size . ' чел.', 1 ); $courses[] = $build_course( ( $subj ? $subj : 'Обучение' ) . ' — мини-группы ' . $group_size . ' чел.', 1 );

View File

@ -32,7 +32,7 @@ if ($teacher_filter) {
} }
} }
foreach (array_slice($teacher_ids, 0, 3) as $rid) { foreach ($teacher_ids as $rid) {
$avatar_id = carbon_get_post_meta($rid, 'review_avatar'); $avatar_id = carbon_get_post_meta($rid, 'review_avatar');
$photo_url = ''; $photo_url = '';
if ($avatar_id && is_numeric($avatar_id)) { if ($avatar_id && is_numeric($avatar_id)) {