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

75 lines
2.7 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
/**
* Преподаватели — FAQ (блок + FAQPage JSON-LD)
* Вопросы из CF teachers_faq (complex). Скрывается если нет данных.
*
* @package Dekart
*/
if (! defined('ABSPATH')) {
exit;
}
$post_id = (int) get_the_ID();
$faq = carbon_get_post_meta($post_id, 'teachers_faq');
if (empty($faq) || ! is_array($faq)) {
return;
}
$faq_items = array();
foreach ($faq as $item) {
$q = $item['faq_question'] ?? '';
$a = $item['faq_answer'] ?? '';
if (! $q || ! $a) {
continue;
}
$faq_items[] = array( 'q' => $q, 'a' => $a );
}
if (empty($faq_items)) {
return;
}
?>
<section class="teachers-faq section-bg reveal" data-bg="teachers-faq" aria-label="Вопросы о преподавателях">
<div class="container">
<div class="section-header--centered">
<span class="bento-label">FAQ</span>
<h2 class="bento-h2">Вопросы о преподавателях</h2>
<p class="bento-p">Как мы знакомим детей с учителями и почему команда годами остаётся стабильной</p>
</div>
<div class="faq-front__list" itemscope itemtype="https://schema.org/FAQPage">
<?php foreach ($faq_items as $i => $fi) : ?>
<details class="faq-front__item" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question" id="teachers-faq-<?php echo esc_attr($i); ?>">
<summary class="faq-front__question" itemprop="name">
<span><?php echo esc_html($fi['q']); ?></span>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
</summary>
<div class="faq-front__answer" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
<div itemprop="text"><?php echo wp_kses_post($fi['a']); ?></div>
</div>
</details>
<?php endforeach; ?>
</div>
</div>
</section>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
<?php foreach ($faq_items as $i => $fi) : ?>
{
"@type": "Question",
"name": <?php echo wp_json_encode($fi['q'], JSON_UNESCAPED_UNICODE); ?>,
"acceptedAnswer": {
"@type": "Answer",
"text": <?php echo wp_json_encode($fi['a'], JSON_UNESCAPED_UNICODE); ?>
}
}<?php echo $i < count($faq_items) - 1 ? ',' : ''; ?>
<?php endforeach; ?>
]
}
</script>