2026-07-28 17:16:40 +00:00

102 lines
5.3 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
/**
* Секция отзывов на главной странице
* Показывает заголовок + 3 отзыва из CF reviews_cards (страница 91 /otzyvy/) + ссылка на все
* Стиль карточек — как на /otzyvy/
*
* @package Dekart
* @since 1.0.0
*/
if (! defined('ABSPATH')) {
exit;
}
$reviews_page_id = 91;
$reviews_cards = carbon_get_post_meta($reviews_page_id, 'reviews_cards');
$has_reviews = ! empty($reviews_cards) && is_array($reviews_cards);
// Берём 3 последних (в CF они в обратном порядке, но на всякий случай переворачиваем)
if ($has_reviews) {
$reviews_cards = array_reverse($reviews_cards);
$reviews_cards = array_slice($reviews_cards, 0, 3);
}
?>
<section class="reviews-front-section reveal" id="reviews" aria-label="Отзывы">
<div class="container">
<div class="section-header--centered">
<span class="bento-label">Отзывы</span>
<h2 class="bento-h2">Узнайте, что говорят о нас родители и ученики</h2>
<p class="bento-p">Более 190 оценок на внешних площадках — средний балл 4,9 из 5</p>
</div>
<?php if ($has_reviews) : ?>
<div class="reviews-front__scroll-hint" aria-hidden="true">👆 Листайте отзывы →</div>
<div class="reviews-front__wrap">
<div class="reviews-front__grid">
<?php foreach ($reviews_cards as $card) :
$name = $card['review_author'] ?? '';
$stars = (int) ( $card['review_rating'] ?? 5 );
$text = $card['review_text'] ?? '';
$rdate_cf = $card['review_date'] ?? '';
$rdate = $rdate_cf ?: '';
$teacher = $card['review_teacher'] ?? array();
$has_teacher = ! empty($teacher[0]['id']);
$photo_url = $card['review_photo'] ?? '';
?>
<div class="reviews-front__card">
<div class="reviews-front__card-inner">
<div class="reviews-front__header">
<div class="reviews-front__avatar" style="background-color: <?php echo esc_attr(rand_color()); ?>">
<?php if ($photo_url) : ?>
<img class="reviews-front__avatar-img" src="<?php echo esc_url($photo_url); ?>" alt="" loading="lazy" width="57" height="57">
<?php else : ?>
<span class="reviews-front__avatar-letter"><?php echo esc_html(mb_substr($name, 0, 1)); ?></span>
<?php endif; ?>
</div>
<div class="reviews-front__client-data">
<div class="reviews-front__name"><?php echo esc_html($name); ?></div>
</div>
</div>
<div class="reviews-front__stars">
<?php for ($i = 1; $i <= $stars; $i++) : ?>
<svg width="20" height="20" viewBox="0 0 21 19" fill="#FFD43E" aria-hidden="true"><path d="M9.58463 1.50884C9.89101 0.602477 11.1729 0.602476 11.4793 1.50884L13.1158 6.35007C13.2531 6.75637 13.6343 7.02985 14.0631 7.02985H19.2721C20.2504 7.02985 20.6467 8.28958 19.8447 8.84971L15.6995 11.7446C15.335 11.9991 15.1823 12.4636 15.3247 12.8847L16.9239 17.6158C17.233 18.5302 16.1954 19.3085 15.404 18.7559L11.1045 15.7533C10.7606 15.5131 10.3033 15.5131 9.95941 15.7533L5.65991 18.7559C4.86857 19.3085 3.83092 18.5302 4.14001 17.6158L5.73926 12.8847C5.8816 12.4636 5.72891 11.9991 5.36448 11.7446L1.21924 8.84971C0.417196 8.28958 0.813532 7.02985 1.79181 7.02985H7.00081C7.42969 7.02985 7.81081 6.75637 7.94815 6.35007L9.58463 1.50884Z"/></svg>
<?php endfor; ?>
<?php if ($rdate) : ?>
<span class="reviews-front__date"><?php echo esc_html($rdate); ?></span>
<?php endif; ?>
</div>
<?php if ($has_teacher) : ?>
<p class="reviews-front__teacher">
<span>Преподаватель: </span>
<?php echo esc_html(get_the_title((int) $teacher[0]['id'])); ?>
</p>
<?php endif; ?>
<div class="reviews-front__text">
<?php echo wp_kses_post($text); ?>
</div>
<div class="reviews-front__badge">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
Проверенный отзыв
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<div class="reviews-front__all-link">
<a href="/otzyvy/" class="reviews-link__btn">Читать все отзывы →</a>
</div>
</div>
</section>