2026-10-04 GLOBAL
This commit is contained in:
parent
acc593a8c2
commit
453035ea4b
@ -285,11 +285,24 @@ foreach ((array) get_option('branch_programs', array()) as $bp) {
|
||||
$teacher_subjects = (array) carbon_get_post_meta($tid, 'teacher_subjects');
|
||||
$subject_items = array(); // без дубликатов
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
if (isset($subject_items[$sn])) {
|
||||
$sn_key = mb_strtolower($sn);
|
||||
if (isset($subject_items[$sn_key])) {
|
||||
continue; // дубликат заголовка — пропускаем
|
||||
}
|
||||
$topics = array();
|
||||
@ -303,14 +316,14 @@ foreach ($teacher_subjects as $ts) {
|
||||
}
|
||||
}
|
||||
$prog = $branch_programs_by_name[ $sn ] ?? null;
|
||||
$subject_items[$sn] = array(
|
||||
$subject_items[$sn_key] = array(
|
||||
'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'] : '',
|
||||
'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');
|
||||
@ -375,24 +388,12 @@ if ($sp_avg_num > 0 && $review_count > 0) {
|
||||
'bestRating' => '5',
|
||||
);
|
||||
|
||||
$teacher_reviews = get_posts(array(
|
||||
'post_type' => 'reviews',
|
||||
'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' => '=' ),
|
||||
),
|
||||
));
|
||||
// Единый источник отзывов — тот же, что видимый блок
|
||||
$teacher_reviews = function_exists('dekart_teacher_review_ids') ? dekart_teacher_review_ids($tid) : array();
|
||||
$review_items = array();
|
||||
foreach ($teacher_reviews as $rid) {
|
||||
$star = (int) carbon_get_post_meta($rid, 'review_star');
|
||||
if ($star < 1 || $star > 5) {
|
||||
continue;
|
||||
}
|
||||
$star = (int) ( carbon_get_post_meta($rid, 'review_star') ?: 5 );
|
||||
$star = min(5, max(1, $star));
|
||||
$item = array(
|
||||
'@type' => 'Review',
|
||||
'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(
|
||||
'@type' => 'Offer',
|
||||
'category' => 'Мини-группа 2–' . $group_size . ' человек',
|
||||
'category' => 'Мини-группа ' . $group_size . ' человек',
|
||||
),
|
||||
);
|
||||
// Цена — микроразметка; число из строки
|
||||
@ -473,8 +474,10 @@ $build_course = function ( $name, $cid, $availability = null, $description = '',
|
||||
};
|
||||
|
||||
$courses = array();
|
||||
if (! empty($subject_names)) {
|
||||
foreach ($subject_names as $i => $cn) {
|
||||
if (! empty($subject_items)) {
|
||||
$ci = 0;
|
||||
foreach ($subject_items as $item) {
|
||||
$ci++;
|
||||
// >0 Limited, =0 SoldOut, пусто — нет
|
||||
$availability = null;
|
||||
if ('' !== (string) $seats_left) {
|
||||
@ -482,7 +485,7 @@ if (! empty($subject_names)) {
|
||||
? 'https://schema.org/LimitedAvailability'
|
||||
: '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 {
|
||||
$courses[] = $build_course( ( $subj ? $subj : 'Обучение' ) . ' — мини-группы ' . $group_size . ' чел.', 1 );
|
||||
|
||||
@ -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');
|
||||
$photo_url = '';
|
||||
if ($avatar_id && is_numeric($avatar_id)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user