shkola/wp-content/themes/dekart/page-class.php
2026-10-08 16:59:02 +00:00

131 lines
4.2 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;
}
get_header();
$post_id = (int) get_the_ID();
$class_page_url = get_permalink($post_id) ?: home_url('/');
$class_hero_title = crb_get_post_meta($post_id, 'class_hero_title', '');
$yoast_title = get_post_meta($post_id, '_yoast_wpseo_title', true);
$schema_title = crb_get_post_meta($post_id, 'class_seo_title', '') ?: ($yoast_title ?: wp_get_document_title());
$schema_desc = crb_get_post_meta($post_id, 'class_seo_description', '')
?: get_post_meta($post_id, '_yoast_wpseo_metadesc', true)
?: crb_get_post_meta($post_id, 'class_hero_subtitle', '');
$class_published = get_the_date('c', $post_id);
$class_modified = get_the_modified_time('c', $post_id);
?>
<main class="page-class">
<?php get_template_part('template-parts/class/hero'); ?>
<?php get_template_part('template-parts/class/program'); ?>
<?php get_template_part('template-parts/class/teachers'); ?>
<?php get_template_part('template-parts/class/schedule'); ?>
<?php get_template_part('template-parts/class/testimonials'); ?>
<?php get_template_part('template-parts/class/faq'); ?>
<?php get_template_part('template-parts/class/cta'); ?>
<?php get_template_part('template-parts/contacts'); ?>
</main>
<?php
$graph = array();
$graph[] = array(
'@type' => 'WebPage',
'@id' => $class_page_url . '#webpage',
'url' => $class_page_url,
'name' => wp_strip_all_tags($schema_title),
'description' => wp_strip_all_tags($schema_desc),
'inLanguage' => str_replace('_', '-', determine_locale() ?: 'ru'),
'isPartOf' => array('@id' => home_url('/') . '#website'),
'breadcrumb' => array('@id' => $class_page_url . '#breadcrumb'),
'speakable' => array(
'@type' => 'SpeakableSpecification',
'cssSelector' => array('h1.class-hero__h1', '.class-hero__subtitle'),
),
'datePublished' => $class_published,
'dateModified' => $class_modified,
);
$graph[] = array(
'@type' => 'BreadcrumbList',
'@id' => $class_page_url . '#breadcrumb',
'itemListElement' => array(
array(
'@type' => 'ListItem',
'position' => 1,
'name' => 'Главная страница',
'item' => home_url('/'),
),
array(
'@type' => 'ListItem',
'position' => 2,
'name' => 'Начальная школа',
'item' => home_url('/nachalnaya-shkola/'),
),
array(
'@type' => 'ListItem',
'position' => 3,
'name' => wp_strip_all_tags($schema_title),
),
),
);
if (function_exists('dekart_schema_organization')) {
$organization = dekart_schema_organization();
if (is_array($organization) && ! empty($organization)) {
$graph[] = $organization;
}
}
// FAQPage — из CF-полей класса
$class_faq_items = crb_get_post_meta($post_id, 'class_faq_items');
if (is_array($class_faq_items) && ! empty($class_faq_items)) {
$faq_main = array();
foreach ($class_faq_items as $item) {
$q = isset($item['faq_question']) ? trim($item['faq_question']) : '';
$a = isset($item['faq_answer']) ? trim($item['faq_answer']) : '';
if ('' === $q || '' === $a) {
continue;
}
$faq_main[] = array(
'@type' => 'Question',
'name' => wp_strip_all_tags($q),
'acceptedAnswer' => array(
'@type' => 'Answer',
'text' => wp_strip_all_tags($a),
),
);
}
if (! empty($faq_main)) {
$graph[] = array(
'@type' => 'FAQPage',
'@id' => $class_page_url . '#faq',
'name' => 'Часто задаваемые вопросы о ' . mb_strtolower(wp_strip_all_tags($schema_title)),
'mainEntity' => $faq_main,
);
}
}
if (count($graph) > 0) : ?>
<script type="application/ld+json">
<?php echo wp_json_encode(array('@context' => 'https://schema.org', '@graph' => $graph), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>
</script>
<?php endif; ?>
<?php
get_footer();