133 lines
4.4 KiB
PHP
133 lines
4.4 KiB
PHP
<?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,
|
||
);
|
||
|
||
$__crumbs = array(
|
||
array( 'name' => 'Главная страница', 'item' => home_url('/') ),
|
||
);
|
||
$__school_url = function_exists('dekart_resolve_page_url')
|
||
? dekart_resolve_page_url(array( 'template' => 'page-elementary-school.php', 'slugs' => array( 'nachalnaya-shkola', 'programma-zankova' ) ))
|
||
: '';
|
||
if ('' !== $__school_url) {
|
||
$__crumbs[] = array( 'name' => 'Начальная школа', 'item' => $__school_url );
|
||
}
|
||
$__crumbs[] = array( 'name' => wp_strip_all_tags($schema_title) );
|
||
|
||
$graph[] = array(
|
||
'@type' => 'BreadcrumbList',
|
||
'@id' => $class_page_url . '#breadcrumb',
|
||
'itemListElement' => array_map(static function ($c, $i) {
|
||
$item = array(
|
||
'@type' => 'ListItem',
|
||
'position' => $i + 1,
|
||
'name' => $c['name'],
|
||
);
|
||
if (! empty($c['item'])) {
|
||
$item['item'] = $c['item'];
|
||
}
|
||
return $item;
|
||
}, $__crumbs, array_keys($__crumbs)),
|
||
);
|
||
unset($__crumbs, $__school_url);
|
||
|
||
if (function_exists('dekart_schema_organization')) {
|
||
$organization = dekart_schema_organization();
|
||
if (is_array($organization) && ! empty($organization)) {
|
||
$graph[] = $organization;
|
||
}
|
||
}
|
||
|
||
$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();
|