shkola/wp-content/themes/dekart/template-parts/author-eaat.php
2026-07-18 16:05:15 +00:00

68 lines
2.6 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
/**
* E-E-A-T автор и даты — универсальный шаблон.
*
* Автор: поле на странице → OG: Site Name → «Частная школа Декарт».
* Годы на рынке: из branch_founded.
* Даты: из WordPress (публикация/обновление).
*
* @package Dekart
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$post_id = get_the_ID();
// Автор: CF на странице → OG: Site Name → fallback
$author_name = carbon_get_post_meta( $post_id, 'pksh_author_name' )
?: get_option( 'branch_og_site_name', 'Частная школа Декарт' );
// Годы на рынке
$founded = get_option( 'branch_founded', '' );
$years = $founded ? (int) date( 'Y' ) - (int) $founded : 0;
$author_title = 'Образовательный центр с гослицензией';
if ( $years > 0 ) {
$author_title .= ', ' . $years . ' лет на рынке';
}
// Даты
$publish_date = $post_id ? get_the_date( 'c', $post_id ) : '';
$modified_date = $post_id ? get_the_modified_date( 'c', $post_id ) : '';
$publish_fmt = $publish_date ? date_i18n( 'j F Y', strtotime( $publish_date ) ) : '';
$modified_fmt = $modified_date ? date_i18n( 'j F Y', strtotime( $modified_date ) ) : '';
if ( empty( $author_name ) && empty( $publish_fmt ) && empty( $modified_fmt ) && $years < 1 ) {
return;
}
?>
<section class="bento pksh-section pksh-section--author" aria-label="Информация об авторе">
<div class="bento__full">
<div class="author-info">
<?php if ( ! empty( $author_name ) ) : ?>
<div class="author-info__block">
<span class="author-info__label">Автор:</span>
<span class="author-info__name"><?php echo esc_html( $author_name ); ?></span>
<?php if ( ! empty( $author_title ) ) : ?>
<span class="author-info__title">, <?php echo esc_html( $author_title ); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( ! empty( $publish_fmt ) ) : ?>
<div class="author-info__block">
<span class="author-info__label">Опубликовано:</span>
<time class="author-info__date" datetime="<?php echo esc_attr( $publish_date ); ?>"><?php echo esc_html( $publish_fmt ); ?></time>
</div>
<?php endif; ?>
<?php if ( ! empty( $modified_fmt ) && $modified_fmt !== $publish_fmt ) : ?>
<div class="author-info__block">
<span class="author-info__label">Обновлено:</span>
<time class="author-info__date" datetime="<?php echo esc_attr( $modified_date ); ?>"><?php echo esc_html( $modified_fmt ); ?></time>
</div>
<?php endif; ?>
</div>
</div>
</section>