Лагерь: SEO
This commit is contained in:
parent
127fd336ab
commit
9c2f0af493
@ -541,6 +541,10 @@ function add_carbon() {
|
||||
->add_tab('🖼️ Первый экран', array(
|
||||
Field::make( 'html', 'hero_tab_desc', '' )
|
||||
->set_html( '<p style="color: #64748b; font-size: 13px; margin: 0 0 12px;">Шаблон: <strong>page-camp.php</strong> · Секция: <strong>.hero-media-search</strong></p>' ),
|
||||
Field::make( 'text', 'camp_city', 'Город (в предложном падеже)' )
|
||||
->set_default_value( 'Щёлково' )
|
||||
->set_help_text( 'Используется для SEO-заголовков и микроразметки во всех секциях.' )
|
||||
->set_width( 50 ),
|
||||
Field::make( 'separator', 'hero_media_sep', 'Изображения' ),
|
||||
Field::make( 'image', 'banner_img', 'Фото на весь экран (десктоп)' )
|
||||
->set_help_text( 'Оптимально: 1920×1080 px, WebP/JPG. Дети в движении, эмоции.' )
|
||||
|
||||
@ -2,12 +2,54 @@
|
||||
/*
|
||||
Template Name: Шаблон страницы Лагерь
|
||||
*/
|
||||
|
||||
add_action('wp_head', function() {
|
||||
if ( ! is_page_template('page-camp.php') ) return;
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$theme_uri = get_template_directory_uri();
|
||||
$title = wp_get_document_title();
|
||||
$desc = get_post_meta( $post_id, '_yoast_wpseo_metadesc', true ) ?: get_the_excerpt();
|
||||
$img_id = carbon_get_post_meta( $post_id, 'banner_img' );
|
||||
if ( ! $img_id ) {
|
||||
$img_id = get_post_thumbnail_id( $post_id );
|
||||
}
|
||||
$img_url = $img_id ? wp_get_attachment_image_url( $img_id, 'full' ) : '';
|
||||
|
||||
echo "\n<!-- SEO meta (page-camp.php) -->\n";
|
||||
|
||||
if ( $title ) {
|
||||
echo '<meta property="og:title" content="' . esc_attr( wp_strip_all_tags( $title ) ) . '">' . "\n";
|
||||
}
|
||||
if ( $desc ) {
|
||||
echo '<meta property="og:description" content="' . esc_attr( wp_strip_all_tags( $desc ) ) . '">' . "\n";
|
||||
}
|
||||
echo '<meta property="og:type" content="website">' . "\n";
|
||||
echo '<meta property="og:url" content="' . esc_url( get_permalink( $post_id ) ) . '">' . "\n";
|
||||
echo '<meta property="og:site_name" content="' . esc_attr( get_bloginfo('name') ) . '">' . "\n";
|
||||
echo '<meta property="og:locale" content="ru_RU">' . "\n";
|
||||
if ( $img_url ) {
|
||||
echo '<meta property="og:image" content="' . esc_url( $img_url ) . '">' . "\n";
|
||||
}
|
||||
echo '<link rel="canonical" href="' . esc_url( get_permalink( $post_id ) ) . '">' . "\n";
|
||||
|
||||
$icon_id = get_option( 'site_icon' );
|
||||
if ( $icon_id ) {
|
||||
echo '<link rel="icon" href="' . esc_url( wp_get_attachment_url( $icon_id ) ) . '">' . "\n";
|
||||
} else {
|
||||
echo '<link rel="icon" href="' . esc_url( $theme_uri ) . '/assets/images/logo-svg.svg" type="image/svg+xml">' . "\n";
|
||||
}
|
||||
|
||||
echo "<!-- /SEO meta -->\n";
|
||||
}, 1);
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
get_header();
|
||||
$post_id = get_the_ID();
|
||||
$theme_uri = get_template_directory_uri();
|
||||
$city = carbon_get_post_meta( $post_id, 'camp_city' ) ?: carbon_get_theme_option( 'site_city' ) ?: 'Щёлково';
|
||||
|
||||
$priceMin = 1000000;
|
||||
$programs = carbon_get_post_meta($post_id, 'programs' );
|
||||
@ -19,10 +61,75 @@ if (is_array($programs)) {
|
||||
}
|
||||
}
|
||||
|
||||
$jsonld_social = array();
|
||||
$jsonld_social_raw = carbon_get_post_meta( $post_id, 'social_media' );
|
||||
if ( is_array( $jsonld_social_raw ) ) {
|
||||
foreach ( $jsonld_social_raw as $s ) {
|
||||
if ( ! empty( $s['social_media_link'] ) ) {
|
||||
$jsonld_social[] = esc_url( $s['social_media_link'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$jsonld_phone = carbon_get_theme_option( 'site_phone' ) ?: carbon_get_post_meta( $post_id, 'contact_tel' );
|
||||
$jsonld_addr = carbon_get_theme_option( 'site_address' ) ?: carbon_get_post_meta( $post_id, 'contact_address' );
|
||||
$jsonld_city = $city;
|
||||
$jsonld_name = carbon_get_theme_option( 'site_name' ) ?: 'Декарт';
|
||||
$jsonld_mail = carbon_get_theme_option( 'site_mail' ) ?: carbon_get_post_meta( $post_id, 'contact_mail' );
|
||||
$jsonld_coords = carbon_get_post_meta( $post_id, 'contact_location' );
|
||||
$jsonld_coord_arr = $jsonld_coords ? array_map( 'trim', explode( ',', $jsonld_coords ) ) : array( '55.9217', '37.9914' );
|
||||
$jsonld_img_id = carbon_get_post_meta( $post_id, 'banner_img' );
|
||||
$jsonld_img_url = $jsonld_img_id ? wp_get_attachment_url( $jsonld_img_id ) : '';
|
||||
|
||||
?>
|
||||
<style>.hidden{display:none}</style>
|
||||
<main class="camp container_camp">
|
||||
|
||||
<script type="application/ld+json">
|
||||
<?php
|
||||
$localbusiness = array(
|
||||
'@type' => 'LocalBusiness',
|
||||
'@id' => home_url('/') . '#localbusiness',
|
||||
'name' => $jsonld_name,
|
||||
'url' => get_permalink( $post_id ),
|
||||
);
|
||||
if ( $jsonld_phone ) $localbusiness['telephone'] = $jsonld_phone;
|
||||
if ( $jsonld_mail ) $localbusiness['email'] = $jsonld_mail;
|
||||
if ( $jsonld_img_url ) $localbusiness['image'] = $jsonld_img_url;
|
||||
|
||||
$localbusiness['address'] = array(
|
||||
'@type' => 'PostalAddress',
|
||||
'addressLocality' => $jsonld_city,
|
||||
'streetAddress' => $jsonld_addr,
|
||||
'addressCountry' => 'RU',
|
||||
);
|
||||
|
||||
if ( ! empty( $jsonld_coord_arr[0] ) && ! empty( $jsonld_coord_arr[1] ) ) {
|
||||
$localbusiness['geo'] = array(
|
||||
'@type' => 'GeoCoordinates',
|
||||
'latitude' => $jsonld_coord_arr[0],
|
||||
'longitude' => $jsonld_coord_arr[1],
|
||||
);
|
||||
}
|
||||
|
||||
$localbusiness['areaServed'] = $city . ', Московская область';
|
||||
$localbusiness['openingHours'] = 'Mo-Fr 08:30-18:30';
|
||||
|
||||
$organization = array(
|
||||
'@type' => 'Organization',
|
||||
'@id' => home_url('/') . '#organization',
|
||||
'name' => $jsonld_name,
|
||||
'url' => home_url('/'),
|
||||
);
|
||||
if ( ! empty( $jsonld_social ) ) {
|
||||
$organization['sameAs'] = $jsonld_social;
|
||||
}
|
||||
|
||||
$graph = array( $localbusiness, $organization );
|
||||
echo json_encode( array( '@context' => 'https://schema.org', '@graph' => $graph ), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
|
||||
?>
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
@ -66,7 +173,7 @@ $metrics = [
|
||||
<!-- Левая колонка -->
|
||||
<div class="hero-media-search__content">
|
||||
<h1 class="heading-1"><?php echo wp_kses_post( $hero['h1'] ); ?></h1>
|
||||
<h2 class="hero-subtitle-brand"><?php echo wp_kses_post( $hero['span'] ); ?></h2>
|
||||
<h2 id="camp-hero-subtitle" class="hero-subtitle-brand"><?php echo wp_kses_post( $hero['span'] ); ?></h2>
|
||||
|
||||
<!-- Метрики (десктоп) -->
|
||||
<div class="hero-media-search__propositions on-desktop">
|
||||
@ -158,7 +265,7 @@ $metrics = [
|
||||
</div>
|
||||
</div>
|
||||
<div class="about-us__content-col">
|
||||
<h2 class="camp_title about-us__title">Лето, которое не хочется ставить на паузу</h2>
|
||||
<h2 id="camp-about" class="camp_title about-us__title">Лето, которое не хочется ставить на паузу</h2>
|
||||
<div class="about-us__text">
|
||||
<?php echo wp_kses_post( carbon_get_post_meta( $post_id, 'about_us_text' ) ?: 'Всю зиму ребёнок в телефоне? Бабушка устала? А ведь лето может быть другим — ярким, живым, полезным.
|
||||
В Dekart дети не просто под присмотром. Они собирают роботов, ставят опыты, играют в театре, бегают на квестах и находят друзей.А главное — бегут в лагерь каждое утро без уговоров.' ); ?>
|
||||
@ -176,7 +283,7 @@ $metrics = [
|
||||
</section>
|
||||
<section class="section-reveal section-bg suggestions" data-bg="mint">
|
||||
<div class="container">
|
||||
<h2 class="camp_title">Почему мамы выбирают Dekart: дети бегут сюда сами</h2>
|
||||
<h2 id="camp-advantages" class="camp_title">Почему мамы выбирают Dekart: дети бегут сюда сами</h2>
|
||||
<p class="suggestions__subtitle">Никаких уговоров по утрам. Никаких «забери меня». Только горящие глаза и «а можно ещё?»</p>
|
||||
<div class="suggestions-wrapper"> <?php $suggestions = carbon_get_post_meta($post_id, 'suggestions' ); $icons = ['innovation-white.svg', 'steamprojects-35x35-1.svg', 'handson-35x35-1.svg', 'orangegear-white.svg', 'outdoor-white.svg', 'heart_sticker.svg'];
|
||||
if (is_array($suggestions)) {
|
||||
@ -187,7 +294,7 @@ $metrics = [
|
||||
?> <div class="suggestions__item">
|
||||
<div class="suggestions__icon-wrap">
|
||||
<img src="<?php echo $theme_uri; ?>/assets/images/doodles/galileo/<?php echo $icon_file; ?>"
|
||||
alt="" class="suggestions__icon">
|
||||
alt="<?php echo esc_attr( $suggestions_title ); ?>" class="suggestions__icon" loading="lazy">
|
||||
</div>
|
||||
<h3 class="suggestions__item_title"><?php echo esc_html( $suggestions_title ); ?></h3>
|
||||
<p class="suggestions__item_text"><?php echo esc_html( $suggestions_text ); ?></p>
|
||||
@ -198,14 +305,14 @@ $metrics = [
|
||||
<section class="section-reveal section-bg infograph" data-bg="white">
|
||||
<div class="container">
|
||||
<div class="infograph__header">
|
||||
<h2 class="camp_title">Цифры, которые говорят сами за себя</h2>
|
||||
<h2 id="camp-infograph" class="camp_title">Цифры, которые говорят сами за себя</h2>
|
||||
<p class="infograph__lead">Мы создаём среду, где каждый ребёнок раскрывает свой потенциал</p>
|
||||
</div>
|
||||
<div class="infograph__grid">
|
||||
|
||||
<div class="infograph__card">
|
||||
<div class="infograph__card-icon">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/age.svg" alt="" width="40" height="40">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/age.svg" alt="Возраст детей — Образовательный центр Декарт <?php echo $city; ?>" width="40" height="40">
|
||||
</div>
|
||||
<div class="infograph__card-body">
|
||||
<p class="infograph__stat">6,5−11 лет</p>
|
||||
@ -215,7 +322,7 @@ $metrics = [
|
||||
|
||||
<div class="infograph__card">
|
||||
<div class="infograph__card-icon">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/group.svg" alt="" width="40" height="40">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/group.svg" alt="Группы до 10 детей — Образовательный центр Декарт <?php echo $city; ?>" width="40" height="40">
|
||||
</div>
|
||||
<div class="infograph__card-body">
|
||||
<p class="infograph__stat">до 10 детей</p>
|
||||
@ -225,7 +332,7 @@ $metrics = [
|
||||
|
||||
<div class="infograph__card">
|
||||
<div class="infograph__card-icon">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/time.svg" alt="" width="40" height="40">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/time.svg" alt="Время посещения на выбор — Образовательный центр Декарт <?php echo $city; ?>" width="40" height="40">
|
||||
</div>
|
||||
<div class="infograph__card-body">
|
||||
<p class="infograph__stat">на выбор</p>
|
||||
@ -235,7 +342,7 @@ $metrics = [
|
||||
|
||||
<div class="infograph__card">
|
||||
<div class="infograph__card-icon">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/price.svg" alt="" width="40" height="40">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/price.svg" alt="Стоимость недели — Образовательный центр Декарт <?php echo $city; ?>" width="40" height="40">
|
||||
</div>
|
||||
<div class="infograph__card-body">
|
||||
<p class="infograph__stat">от <?php echo esc_html( number_format($priceMin, 0, ',', ' ') ); ?> ₽</p>
|
||||
@ -249,7 +356,7 @@ $metrics = [
|
||||
|
||||
<section class="section-bg programs" data-bg="mint" itemscope itemtype="https://schema.org/ItemList">
|
||||
<div class="container">
|
||||
<h2 class="camp_title" itemprop="name">Летние программы</h2>
|
||||
<h2 id="camp-programs" class="camp_title" itemprop="name">Летние программы</h2>
|
||||
<div class="programs__grid">
|
||||
<?php
|
||||
$programs = carbon_get_post_meta($post_id, 'programs');
|
||||
@ -263,7 +370,7 @@ $metrics = [
|
||||
$programs_days = $item['programs_days'];
|
||||
$programs_content = $item['programs_content'];?>
|
||||
<article class="programs__card">
|
||||
<img class="programs__image" loading="lazy" width="360" height="225" src="<?php echo $programs_img ? wp_get_attachment_url($programs_img) : $theme_uri . '/assets/images/placeholder.svg'; ?>" alt="<?php echo $programs_img ? esc_attr(get_post_meta($programs_img, '_wp_attachment_image_alt', true)) : ''; ?>">
|
||||
<img class="programs__image" loading="lazy" width="360" height="225" src="<?php echo $programs_img ? wp_get_attachment_url($programs_img) : $theme_uri . '/assets/images/placeholder.svg'; ?>" alt="<?php echo $programs_img && get_post_meta($programs_img, '_wp_attachment_image_alt', true) ? esc_attr(get_post_meta($programs_img, '_wp_attachment_image_alt', true)) : esc_attr($programs_title) . ' — Образовательный центр Декарт ' . $city; ?>">
|
||||
<div class="programs__body">
|
||||
<h3 class="programs__name"><?php echo esc_html($programs_title); ?></h3>
|
||||
<p class="programs__date"><?php echo esc_html($programs_date); ?></p>
|
||||
@ -290,7 +397,7 @@ $metrics = [
|
||||
$price_half_day = carbon_get_post_meta($post_id, 'price_half_day' );
|
||||
$price_full_day = carbon_get_post_meta($post_id, 'price_full_day' );
|
||||
?>
|
||||
<h2 class="camp_title">Приводите ребёнка, когда вам удобно</h2>
|
||||
<h2 id="camp-pricing" class="camp_title">Приводите ребёнка, когда вам удобно</h2>
|
||||
<div class="bring-child-wrapper">
|
||||
|
||||
<div class="pricing-card pricing-card--half">
|
||||
@ -322,7 +429,7 @@ $metrics = [
|
||||
<li>умные прогулки <b>1 раз в день</b></li>
|
||||
</ul>
|
||||
<div class="pricing-card__extra">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/calendar.png" width="20" height="20" alt="">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/calendar.png" width="20" height="20" alt="Календарь — Образовательный центр Декарт <?php echo $city; ?>">
|
||||
<span>Тематическая неделя на выбор</span>
|
||||
</div>
|
||||
<button class="pricing-card__btn btn-write-camp">Занять место</button>
|
||||
@ -354,7 +461,7 @@ $metrics = [
|
||||
<li>тематические экскурсии каждую неделю</li>
|
||||
</ul>
|
||||
<div class="pricing-card__extra">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/calendar+.png" width="20" height="20" alt="">
|
||||
<img loading="lazy" src="<?php echo $theme_uri; ?>/assets/images/calendar+.png" width="20" height="20" alt="Календарь — Образовательный центр Декарт <?php echo $city; ?>">
|
||||
<span>Тематическая неделя на выбор</span>
|
||||
</div>
|
||||
<button class="pricing-card__btn btn-write-camp">Занять место</button>
|
||||
@ -364,7 +471,7 @@ $metrics = [
|
||||
</section>
|
||||
|
||||
<section class="section-reveal section-bg mentors" data-bg="mint">
|
||||
<h2 class="camp_title">Наши наставники и ведущие мастер-классов</h2>
|
||||
<h2 id="camp-mentors" class="camp_title">Наши наставники и ведущие мастер-классов</h2>
|
||||
<div class="mentors-wrapper">
|
||||
<?php
|
||||
$mentors = carbon_get_post_meta($post_id, 'mentors' );
|
||||
@ -379,13 +486,13 @@ $metrics = [
|
||||
<div class="mentors__card">
|
||||
<div class="mentors__card-top">
|
||||
<?php if ( !$mentor_foto ) { ?>
|
||||
<img class="mentors__photo" loading="lazy" width="120" height="120" src="<?php echo $theme_uri; ?>/assets/images/no-photo.png" alt="">
|
||||
<img class="mentors__photo" loading="lazy" width="120" height="120" src="<?php echo $theme_uri; ?>/assets/images/no-photo.png" alt="<?php echo esc_attr( $mentorName ); ?> — Образовательный центр Декарт <?php echo $city; ?>">
|
||||
<?php } else { ?>
|
||||
<img class="mentors__photo" loading="lazy" width="120" height="120" src="<?php echo wp_get_attachment_url($mentor_foto); ?>" alt="">
|
||||
<img class="mentors__photo" loading="lazy" width="120" height="120" src="<?php echo wp_get_attachment_url($mentor_foto); ?>" alt="<?php echo esc_attr( $mentorName ); ?> — Образовательный центр Декарт <?php echo $city; ?>">
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="mentors__card-body">
|
||||
<span class="mentors__name"><?php echo esc_html($mentorName); ?></span>
|
||||
<h3 class="mentors__name"><?php echo esc_html($mentorName); ?></h3>
|
||||
<p class="mentors__job"><?php echo esc_html($mentor_job); ?></p>
|
||||
<?php if ($mentor_about) : ?>
|
||||
<p class="mentors__about"><?php echo esc_html($mentor_about); ?></p>
|
||||
@ -400,7 +507,7 @@ $metrics = [
|
||||
</section>
|
||||
|
||||
<section class="section-reveal section-bg routine" data-bg="white">
|
||||
<h2 class="camp_title">Распорядок дня в клубе</h2>
|
||||
<h2 id="camp-schedule" class="camp_title">Распорядок дня в клубе</h2>
|
||||
<div class="routine-wrapper">
|
||||
<?php
|
||||
$routine = carbon_get_post_meta($post_id, 'routine' );
|
||||
@ -415,7 +522,7 @@ $metrics = [
|
||||
<div class="routine__item_circle"></div>
|
||||
<div class="routine__item_text">
|
||||
<p class="routine__item_time-mobile"><?php echo esc_html($routine_time); ?></p>
|
||||
<p class="routine__item_text-title"><?php echo esc_html($routine_title); ?></p>
|
||||
<h3 class="routine__item_text-title"><?php echo esc_html($routine_title); ?></h3>
|
||||
<p class="routine__item_text-text"><?php echo esc_html($routine_text); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
@ -425,7 +532,7 @@ $metrics = [
|
||||
</section>
|
||||
|
||||
<section class="section-reveal section-bg foto" data-bg="mint">
|
||||
<h2 class="camp_title">Наши фотографии</h2>
|
||||
<h2 id="camp-gallery" class="camp_title">Наши фотографии</h2>
|
||||
<?php
|
||||
$fotos = carbon_get_post_meta($post_id, 'fotos' );
|
||||
if (is_array($fotos) && !empty($fotos)) :
|
||||
@ -437,6 +544,7 @@ $metrics = [
|
||||
$img_url = wp_get_attachment_url($img_id);
|
||||
$full_url = wp_get_attachment_image_url($img_id, 'full');
|
||||
$alt = esc_attr(get_post_meta($img_id, '_wp_attachment_image_alt', true));
|
||||
if ( ! $alt ) $alt = 'Фото лагеря — Образовательный центр Декарт ' . $city;
|
||||
?>
|
||||
<div class="lw-gallery__item">
|
||||
<img class="lw-gallery__thumb"
|
||||
@ -462,7 +570,7 @@ $metrics = [
|
||||
</section>
|
||||
|
||||
<section class="section-reveal section-bg camp-reviews" data-bg="white">
|
||||
<h2 class="camp_title">Что говорят о нас родители</h2>
|
||||
<h2 id="camp-reviews" class="camp_title">Что говорят о нас родители</h2>
|
||||
<?php
|
||||
$key = array(
|
||||
array(
|
||||
@ -523,7 +631,7 @@ $metrics = [
|
||||
</section>
|
||||
|
||||
<section class="section-reveal section-bg camp-faq" data-bg="mint">
|
||||
<h2 class="camp_title">Часто задаваемые вопросы</h2>
|
||||
<h2 id="camp-faq" class="camp_title">Часто задаваемые вопросы</h2>
|
||||
<div class="faq-wrapper" itemscope itemtype="https://schema.org/FAQPage">
|
||||
|
||||
<?php
|
||||
@ -574,7 +682,7 @@ $metrics = [
|
||||
$contact_location_text = carbon_get_post_meta($post_id, 'contact_location_text' );
|
||||
$contact_mail = carbon_get_post_meta($post_id, 'contact_mail' );
|
||||
?>
|
||||
<h2 class="camp_title">Контакты</h2>
|
||||
<h2 id="camp-contacts" class="camp_title">Контакты</h2>
|
||||
<div class="contact-wrapper">
|
||||
<div class="contact-content">
|
||||
<div class="contact_subtitle">Телефон:</div>
|
||||
@ -591,7 +699,7 @@ $metrics = [
|
||||
foreach( $social_media as $item ) {
|
||||
$icon = $item['social_media_img'];
|
||||
if ($item['social_media_link'] != '') { ?>
|
||||
<a class="social_item" href="<?php echo esc_url($item['social_media_link']); ?>" title="<?php echo esc_attr($item['social_media_name']); ?>">
|
||||
<a class="social_item" href="<?php echo esc_url($item['social_media_link']); ?>" target="_blank" rel="noopener noreferrer" title="<?php echo esc_attr($item['social_media_name']); ?>">
|
||||
<img loading="lazy" width="32" height="32" src="<?php echo wp_get_attachment_url($icon); ?>" alt="<?php echo esc_attr($item['social_media_name']); ?>">
|
||||
</a>
|
||||
<?php }
|
||||
@ -731,5 +839,115 @@ if (preg_match("/\\(window,document,'([^']+)'\\)/", $_b24_raw, $_m)) $_b24_url =
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// JSON-LD: Event (смены) + FAQ + AggregateRating (отзывы)
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
$ld_events = array();
|
||||
if ( is_array( $programs ) ) {
|
||||
foreach ( $programs as $item ) {
|
||||
$ev = array( '@type' => 'Event' );
|
||||
if ( ! empty( $item['programs_title'] ) ) {
|
||||
$ev['name'] = wp_strip_all_tags( $item['programs_title'] );
|
||||
}
|
||||
if ( ! empty( $item['programs_text'] ) ) {
|
||||
$ev['description'] = wp_strip_all_tags( $item['programs_text'] );
|
||||
}
|
||||
if ( ! empty( $item['programs_date'] ) ) {
|
||||
$raw = wp_strip_all_tags( $item['programs_date'] );
|
||||
if ( preg_match( '/\d{4}/', $raw, $y ) ) {
|
||||
$ev['startDate'] = $y[0];
|
||||
}
|
||||
$ev['description'] = ( isset( $ev['description'] ) ? $ev['description'] . ' — ' : '' ) . $raw;
|
||||
}
|
||||
if ( ! empty( $item['programs_img'] ) ) {
|
||||
$ev['image'] = esc_url( wp_get_attachment_url( $item['programs_img'] ) );
|
||||
}
|
||||
if ( ! empty( $item['programs_price'] ) ) {
|
||||
$ev['offers'] = array(
|
||||
'@type' => 'Offer',
|
||||
'price' => (int) $item['programs_price'],
|
||||
'priceCurrency' => 'RUB',
|
||||
);
|
||||
}
|
||||
if ( $jsonld_img_url && empty( $ev['image'] ) ) {
|
||||
$ev['image'] = esc_url( $jsonld_img_url );
|
||||
}
|
||||
$ld_events[] = $ev;
|
||||
}
|
||||
}
|
||||
|
||||
$ld_questions = carbon_get_post_meta( $post_id, 'questions' );
|
||||
$ld_faq = array();
|
||||
if ( is_array( $ld_questions ) ) {
|
||||
$faq_main_entity = array();
|
||||
foreach ( $ld_questions as $q ) {
|
||||
$name = ! empty( $q['questions_question'] ) ? wp_strip_all_tags( $q['questions_question'] ) : '';
|
||||
$answer = ! empty( $q['questions_answer'] ) ? wp_strip_all_tags( $q['questions_answer'] ) : '';
|
||||
if ( $name && $answer ) {
|
||||
$faq_main_entity[] = array(
|
||||
'@type' => 'Question',
|
||||
'name' => $name,
|
||||
'acceptedAnswer' => array(
|
||||
'@type' => 'Answer',
|
||||
'text' => $answer,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( ! empty( $faq_main_entity ) ) {
|
||||
$ld_faq[] = array(
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => $faq_main_entity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$agg_rating = null;
|
||||
$agg_reviews = new WP_Query( array(
|
||||
'post_type' => 'reviews',
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids',
|
||||
'suppress_filters' => true,
|
||||
'meta_query' => array( array(
|
||||
'key' => 'review_type',
|
||||
'value' => 'camp',
|
||||
'compare' => '=',
|
||||
) ),
|
||||
) );
|
||||
if ( $agg_reviews->have_posts() ) {
|
||||
$total_stars = 0;
|
||||
$review_cnt = 0;
|
||||
foreach ( $agg_reviews->posts as $rid ) {
|
||||
$star = (int) carbon_get_post_meta( $rid, 'review_star' );
|
||||
if ( $star > 0 ) {
|
||||
$total_stars += $star;
|
||||
$review_cnt++;
|
||||
}
|
||||
}
|
||||
if ( $review_cnt > 0 ) {
|
||||
$agg_rating = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => round( $total_stars / $review_cnt, 1 ),
|
||||
'reviewCount' => $review_cnt,
|
||||
'bestRating' => 5,
|
||||
'worstRating' => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_reset_postdata();
|
||||
|
||||
$ld_graph = array_merge( $ld_events, $ld_faq );
|
||||
if ( $agg_rating ) $ld_graph[] = $agg_rating;
|
||||
|
||||
if ( ! empty( $ld_graph ) ) {
|
||||
echo '<script type="application/ld+json">' . "\n";
|
||||
echo json_encode( array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@graph' => $ld_graph,
|
||||
), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT );
|
||||
echo "\n" . '</script>' . "\n";
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
get_footer();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user