Микроразметка Лагеря

This commit is contained in:
Dekart Deploy Bot 2026-05-20 00:31:46 +03:00
parent 758c988599
commit a24b83c27d

View File

@ -6,6 +6,23 @@ Template Name: Шаблон страницы Лагерь
Поля контента страницы (hero, about, programs, mentors, faq, etc.) в Carbon Fields в метабоксе ниже. Поля контента страницы (hero, about, programs, mentors, faq, etc.) в Carbon Fields в метабоксе ниже.
*/ */
add_filter( 'wpseo_json_ld_output', '__return_false' ); add_filter( 'wpseo_json_ld_output', '__return_false' );
add_filter( 'wpseo_opengraph_type', function( $type ) {
if ( is_page_template( 'page-camp.php' ) ) {
return 'website';
}
return $type;
} );
add_filter( 'wpseo_frontend_presenter_classes', function( $presenters ) {
if ( is_page_template( 'page-camp.php' ) ) {
$presenters = array_filter( $presenters, function( $p ) {
return strpos( $p, 'Article_Modified_Time' ) === false
&& strpos( $p, 'Article_Published_Time' ) === false
&& strpos( $p, 'Article_Author' ) === false
&& strpos( $p, 'Article_Publisher' ) === false;
} );
}
return $presenters;
} );
add_action('wp_head', function() { echo '<style>.hidden{display:none}</style>'; }, 100); add_action('wp_head', function() { echo '<style>.hidden{display:none}</style>'; }, 100);
get_header(); get_header();
?> ?>
@ -314,9 +331,9 @@ $metrics = [
</div> </div>
</section> </section>
<section class="section-bg programs" data-bg="mint" itemscope itemtype="https://schema.org/ItemList"> <section class="section-bg programs" data-bg="mint">
<div class="container"> <div class="container">
<h2 id="camp-programs" class="camp_title" itemprop="name">Летние программы</h2> <h2 id="camp-programs" class="camp_title">Летние программы</h2>
<div class="programs__grid"> <div class="programs__grid">
<?php <?php
$programs = carbon_get_post_meta($post_id, 'programs'); $programs = carbon_get_post_meta($post_id, 'programs');
@ -350,10 +367,7 @@ $metrics = [
</div> </div>
</section> </section>
<section class="section-bg bring-child" data-bg="white" itemscope itemtype="https://schema.org/Product"> <section class="section-bg bring-child" data-bg="white">
<meta itemprop="name" content="Городской лагерь Декарт">
<meta itemprop="description" content="Стоимость пребывания в городском лагере Декарт">
<link itemprop="offeredBy" href="<?php echo esc_url( home_url('/') ); ?>#organization">
<?php <?php
$price_half_day = carbon_get_post_meta($post_id, 'price_half_day' ); $price_half_day = carbon_get_post_meta($post_id, 'price_half_day' );
$price_full_day = carbon_get_post_meta($post_id, 'price_full_day' ); $price_full_day = carbon_get_post_meta($post_id, 'price_full_day' );
@ -369,10 +383,9 @@ $metrics = [
<h3 class="pricing-card__title">Половина дня</h3> <h3 class="pricing-card__title">Половина дня</h3>
<p class="pricing-card__desc">Время пребывания на выбор (до обеда или до вечера)</p> <p class="pricing-card__desc">Время пребывания на выбор (до обеда или до вечера)</p>
</div> </div>
<div class="pricing-card__price" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <div class="pricing-card__price">
<span class="pricing-card__amount" itemprop="price" content="<?php echo esc_attr($price_half_day); ?>"><?php echo number_format($price_half_day, 0, ',', ' '); ?> ₽</span> <span class="pricing-card__amount"><?php echo number_format($price_half_day, 0, ',', ' '); ?> ₽</span>
<span class="pricing-card__period">за 5 дней</span> <span class="pricing-card__period">за 5 дней</span>
<meta itemprop="priceCurrency" content="RUB">
</div> </div>
<div class="pricing-card__slots"> <div class="pricing-card__slots">
<div class="pricing-card__slot"> <div class="pricing-card__slot">
@ -404,10 +417,9 @@ $metrics = [
<h3 class="pricing-card__title">Полный день</h3> <h3 class="pricing-card__title">Полный день</h3>
<p class="pricing-card__desc">Пребывание в клубе с утра до вечера, дополнительные активности</p> <p class="pricing-card__desc">Пребывание в клубе с утра до вечера, дополнительные активности</p>
</div> </div>
<div class="pricing-card__price" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <div class="pricing-card__price">
<span class="pricing-card__amount" itemprop="price" content="<?php echo esc_attr($price_full_day); ?>"><?php echo number_format($price_full_day, 0, ',', ' '); ?> ₽</span> <span class="pricing-card__amount"><?php echo number_format($price_full_day, 0, ',', ' '); ?> ₽</span>
<span class="pricing-card__period">за 5 дней</span> <span class="pricing-card__period">за 5 дней</span>
<meta itemprop="priceCurrency" content="RUB">
</div> </div>
<div class="pricing-card__slots"> <div class="pricing-card__slots">
<div class="pricing-card__slot"> <div class="pricing-card__slot">
@ -549,34 +561,29 @@ $metrics = [
if (!$stars) $stars = 5; if (!$stars) $stars = 5;
if (!$text) continue; if (!$text) continue;
?> ?>
<div class="lw-card" itemprop="review" itemscope itemtype="https://schema.org/Review"> <div class="lw-card">
<meta itemprop="itemReviewed" itemscope itemtype="https://schema.org/School" itemid="<?php echo esc_url( get_permalink( $post_id ) ); ?>">
<div class="lw-flex lw-flex--row lw-gap-12 lw-items-center"> <div class="lw-flex lw-flex--row lw-gap-12 lw-items-center">
<div class="lw-avatar lw-avatar--48" itemprop="author" itemscope itemtype="https://schema.org/Person"> <div class="lw-avatar lw-avatar--48">
<?php if ($avatar) : ?> <?php if ($avatar) : ?>
<img class="lw-avatar__img" src="<?php echo wp_get_attachment_url($avatar); ?>" alt="<?php echo esc_attr($name); ?>" loading="lazy"> <img class="lw-avatar__img" src="<?php echo wp_get_attachment_url($avatar); ?>" alt="<?php echo esc_attr($name); ?>" loading="lazy">
<?php else : ?> <?php else : ?>
<img class="lw-avatar__img" src="https://ui-avatars.com/api/?name=<?php echo urlencode($name); ?>&amp;background=random&amp;color=fff&amp;size=96" alt="<?php echo esc_attr($name); ?>" loading="lazy"> <img class="lw-avatar__img" src="https://ui-avatars.com/api/?name=<?php echo urlencode($name); ?>&amp;background=random&amp;color=fff&amp;size=96" alt="<?php echo esc_attr($name); ?>" loading="lazy">
<?php endif; ?> <?php endif; ?>
<meta itemprop="name" content="<?php echo esc_attr($name); ?>">
</div> </div>
<div class="lw-flex lw-flex--col"> <div class="lw-flex lw-flex--col">
<div class="lw-text-dark lw-font-semibold"><?php echo esc_html($name); ?></div> <div class="lw-text-dark lw-font-semibold"><?php echo esc_html($name); ?></div>
<div class="lw-text-xs lw-text-gray"><time itemprop="datePublished" datetime="<?php echo esc_attr(get_the_date('Y-m-d')); ?>"><?php echo esc_html($date); ?></time></div> <div class="lw-text-xs lw-text-gray"><time datetime="<?php echo esc_attr(get_the_date('Y-m-d')); ?>"><?php echo esc_html($date); ?></time></div>
</div> </div>
<div class="lw-badge lw-badge--verified">Проверенный отзыв</div> <div class="lw-badge lw-badge--verified">Проверенный отзыв</div>
</div> </div>
<div class="lw-stars lw-mt-8" itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating"> <div class="lw-stars lw-mt-8">
<meta itemprop="ratingValue" content="<?php echo esc_attr($stars); ?>">
<meta itemprop="bestRating" content="5">
<meta itemprop="worstRating" content="1">
<?php for ($i = 1; $i <= 5; $i++) : ?> <?php for ($i = 1; $i <= 5; $i++) : ?>
<svg class="lw-star <?php echo $i <= $stars ? 'lw-star--filled' : ''; ?>" width="16" height="16" viewBox="0 0 21 19" fill="none"> <svg class="lw-star <?php echo $i <= $stars ? 'lw-star--filled' : ''; ?>" width="16" height="16" viewBox="0 0 21 19" fill="none">
<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" fill="currentColor"></path> <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" fill="currentColor"></path>
</svg> </svg>
<?php endfor; ?> <?php endfor; ?>
</div> </div>
<div class="lw-card__text lw-mt-8" itemprop="reviewBody"><?php echo wp_kses_post($text); ?></div> <div class="lw-card__text lw-mt-8"><?php echo wp_kses_post($text); ?></div>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
@ -586,7 +593,7 @@ $metrics = [
<section class="section-bg camp-faq" data-bg="mint"> <section class="section-bg camp-faq" data-bg="mint">
<h2 id="camp-faq" class="camp_title">Часто задаваемые вопросы</h2> <h2 id="camp-faq" class="camp_title">Часто задаваемые вопросы</h2>
<div class="faq-wrapper" itemscope itemtype="https://schema.org/FAQPage"> <div class="faq-wrapper">
<?php <?php
$questions = carbon_get_post_meta($post_id, 'questions' ); $questions = carbon_get_post_meta($post_id, 'questions' );
@ -599,8 +606,8 @@ $metrics = [
$questions_question = $item['questions_question']; $questions_question = $item['questions_question'];
$questions_answer = $item['questions_answer']; $questions_answer = $item['questions_answer'];
$accordion_item = "<div class='box__accordion'> $accordion_item = "<div class='box__accordion'>
<div class='box__accordion_label' role='button' tabindex='0' itemscope itemprop='mainEntity' itemtype='https://schema.org/Question'> <div class='box__accordion_label' role='button' tabindex='0'>
<span itemprop='name'>" . esc_html($questions_question) . "</span> <span>" . esc_html($questions_question) . "</span>
<svg role='presentation' focusable='false' width='24px' height='24px' viewBox='0 0 24 24'> <svg role='presentation' focusable='false' width='24px' height='24px' viewBox='0 0 24 24'>
<g stroke='none' stroke-width='2px' fill='none' fill-rule='evenodd' stroke-linecap='square'> <g stroke='none' stroke-width='2px' fill='none' fill-rule='evenodd' stroke-linecap='square'>
<g transform='translate(1.000000, 1.000000)' stroke='#3bb273'> <g transform='translate(1.000000, 1.000000)' stroke='#3bb273'>
@ -610,8 +617,8 @@ $metrics = [
</g> </g>
</svg> </svg>
</div> </div>
<div class='box__accordion_content' itemscope itemprop='acceptedAnswer' itemtype='https://schema.org/Answer'> <div class='box__accordion_content'>
<div class='box__accordion_content-text' itemprop='text'>" . wp_kses_post($questions_answer) . "</div> <div class='box__accordion_content-text'>" . wp_kses_post($questions_answer) . "</div>
</div> </div>
</div>"; </div>";
if ($count % 2 === 0) { if ($count % 2 === 0) {
@ -806,6 +813,7 @@ if ( is_array( $programs ) ) {
} }
$ev = array( $ev = array(
'@type' => 'Event', '@type' => 'Event',
'eventStatus' => 'https://schema.org/EventScheduled',
'organizer' => array( '@id' => home_url('/') . '#organization' ), 'organizer' => array( '@id' => home_url('/') . '#organization' ),
'location' => array( '@id' => get_permalink( $post_id ) ), 'location' => array( '@id' => get_permalink( $post_id ) ),
); );
@ -817,12 +825,30 @@ if ( is_array( $programs ) ) {
} }
if ( ! empty( $item['programs_date'] ) ) { if ( ! empty( $item['programs_date'] ) ) {
$raw = wp_strip_all_tags( $item['programs_date'] ); $raw = wp_strip_all_tags( $item['programs_date'] );
// ISO: 2025-05-26
if ( preg_match( '/(\d{4})-(\d{2})-(\d{2})/', $raw, $m ) ) { if ( preg_match( '/(\d{4})-(\d{2})-(\d{2})/', $raw, $m ) ) {
$ev['startDate'] = $m[1] . '-' . $m[2] . '-' . $m[3]; $ev['startDate'] = $m[1] . '-' . $m[2] . '-' . $m[3];
// DD.MM.YYYY
} elseif ( preg_match( '/(\d{2})\.(\d{2})\.(\d{4})/', $raw, $m ) ) { } elseif ( preg_match( '/(\d{2})\.(\d{2})\.(\d{4})/', $raw, $m ) ) {
$ev['startDate'] = $m[3] . '-' . $m[2] . '-' . $m[1]; $ev['startDate'] = $m[3] . '-' . $m[2] . '-' . $m[1];
// Русские месяцы: "2630 мая 2025" или "30 июня4 июля 2025"
} elseif ( preg_match( '/(\d{1,2})\s*(?:[–—\-]|\s*\s*)\d{1,2}\s+([а-яё]+)/ui', $raw, $m )
|| preg_match( '/(\d{1,2})\s+([а-яё]+)\s*[–—\-]/ui', $raw, $m )
|| preg_match( '/(\d{1,2})\s+([а-яё]+)\s+\d{4}/ui', $raw, $m ) ) {
$ru_months = array(
'января' => '01', 'февраля' => '02', 'марта' => '03',
'апреля' => '04', 'мая' => '05', 'июня' => '06',
'июля' => '07', 'августа' => '08', 'сентября' => '09',
'октября' => '10', 'ноября' => '11', 'декабря' => '12',
);
$month_name = mb_strtolower( trim( $m[2] ) );
if ( isset( $ru_months[ $month_name ] ) ) {
preg_match( '/(\d{4})/u', $raw, $y );
$ev['startDate'] = ( $y[1] ?? date('Y') ) . '-' . $ru_months[ $month_name ] . '-' . str_pad( $m[1], 2, '0', STR_PAD_LEFT );
}
// Fallback: только год
} elseif ( preg_match( '/\d{4}/', $raw, $y ) ) { } elseif ( preg_match( '/\d{4}/', $raw, $y ) ) {
$ev['startDate'] = $y[0]; $ev['startDate'] = $y[0] . '-06-01';
} }
if ( isset( $ev['description'] ) && $ev['description'] ) { if ( isset( $ev['description'] ) && $ev['description'] ) {
$ev['description'] .= ' — ' . $raw; $ev['description'] .= ' — ' . $raw;
@ -951,12 +977,17 @@ $organization = array(
'name' => $jsonld_name, 'name' => $jsonld_name,
'url' => home_url('/'), 'url' => home_url('/'),
); );
if ( $jsonld_img_url ) {
$organization['logo'] = $jsonld_img_url;
}
if ( ! empty( $jsonld_social ) ) { if ( ! empty( $jsonld_social ) ) {
$organization['sameAs'] = $jsonld_social; $organization['sameAs'] = $jsonld_social;
} }
if ( $agg_rating ) {
$localbusiness['aggregateRating'] = $agg_rating;
}
$ld_graph = array_merge( array( $localbusiness, $organization ), $ld_events, $ld_faq ); $ld_graph = array_merge( array( $localbusiness, $organization ), $ld_events, $ld_faq );
if ( $agg_rating ) $ld_graph[] = $agg_rating;
if ( ! empty( $ld_graph ) ) { if ( ! empty( $ld_graph ) ) {
$jsonld_data = array( $jsonld_data = array(