shkola/wp-content/themes/dekart/template-parts/pksh/teachers.php
2026-07-17 16:10:56 +00:00

109 lines
4.5 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
/**
* Преподаватели (горизонтальный скролл)
* .bento .pksh-section .pksh-section--teachers #teachers
*
* @package Dekart
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$data = Pksh_Data::instance();
$teachers = $data->get_teachers();
?>
<section class="bento pksh-section pksh-section--teachers" id="teachers" aria-label="Преподаватели">
<div class="bento__full section-header--left">
<span class="bento-label">Преподаватели</span>
<h2 class="bento-h2">Наши преподаватели — практикующие педагоги</h2>
<p class="bento-p">Каждый педагог имеет опыт работы с дошкольниками от 5 лет. Все — действующие учителя начальных классов с высшим образованием.</p>
<div class="pksh-swipe-hint" aria-hidden="true">
<span class="pksh-swipe-hint__arrow">👇</span>
<span class="pksh-swipe-hint__text">Листайте, чтобы познакомиться с преподавателями</span>
</div>
</div>
<div class="bento__full">
<div class="pksh-teachers__scroll-x">
<div class="pksh-teachers__wrapper">
<?php if ( is_array( $teachers ) && ! empty( $teachers ) ) : ?>
<?php foreach ( $teachers as $item ) :
$t_id = $item['teacher_id'] ?? 0;
$t_subj = $item['teacher_subject'] ?? '';
$t_about = $item['teacher_about'] ?? '';
$t_badge = $item['teacher_badge'] ?? '';
$t_exp = $item['teacher_exp'] ?? '';
$t_post = $t_id ? get_post( $t_id ) : null;
$t_name = $t_post ? $t_post->post_title : '—';
$t_photo = 0;
if ( $t_post ) {
$t_photo = get_post_meta( $t_id, '_teacher_avatar', true );
if ( ! $t_photo ) {
$t_photo = get_post_meta( $t_id, '_thumbnail_id', true );
}
}
if ( empty( $t_subj ) && $t_post ) {
$t_subj = get_post_meta( $t_id, '_teacher_direction', true );
}
if ( empty( $t_about ) && $t_post ) {
$t_about = get_post_meta( $t_id, '_teacher_about', true );
}
if ( empty( $t_exp ) && $t_post ) {
$start_year = get_post_meta( $t_id, '_teacher_start_year', true );
if ( $start_year && is_numeric( $start_year ) ) {
$e = (int) date( 'Y' ) - (int) $start_year;
if ( $e > 0 ) {
$t_exp = $e . ' лет';
}
}
} elseif ( ! empty( $t_exp ) && ctype_digit( trim( $t_exp ) ) ) {
$t_exp = trim( $t_exp ) . ' лет';
}
?>
<div class="pksh-teachers__item">
<div class="pksh-teachers__card">
<div class="pksh-teachers__card-top">
<?php if ( $t_photo ) : ?>
<?php $photo_url = wp_get_attachment_image_url( $t_photo, array( 280, 280 ) ); ?>
<img class="pksh-teachers__photo" loading="lazy" width="140" height="140"
src="<?php echo esc_url( $photo_url ?: get_template_directory_uri() . '/assets/images/no-photo.png' ); ?>"
alt="<?php echo esc_attr( $t_name ); ?>">
<?php else : ?>
<img class="pksh-teachers__photo" loading="lazy" width="140" height="140"
src="<?php echo get_template_directory_uri(); ?>/assets/images/no-photo.png"
alt="<?php echo esc_attr( $t_name ); ?>">
<?php endif; ?>
</div>
<div class="pksh-teachers__card-body">
<h3 class="pksh-teachers__name"><?php echo esc_html( $t_name ); ?></h3>
<?php if ( $t_subj ) : ?>
<p class="pksh-teachers__subj"><?php echo esc_html( $t_subj ); ?></p>
<?php endif; ?>
<?php if ( $t_about ) : ?>
<p class="pksh-teachers__desc"><?php echo esc_html( wp_strip_all_tags( $t_about ) ); ?></p>
<?php endif; ?>
<div class="pksh-teachers__meta">
<?php if ( $t_badge ) : ?>
<span class="pksh-teachers__meta-badge"><?php echo esc_html( $t_badge ); ?></span>
<?php endif; ?>
<?php if ( $t_exp ) : ?>
<span class="pksh-teachers__meta-exp"><svg aria-hidden="true" width="14" height="14" style="vertical-align:-2px;margin-right:4px"><use href="#icon-calendar"/></svg> Стаж: <?php echo esc_html( $t_exp ); ?></span>
<?php endif; ?>
</div>
<button class="pksh-teachers__btn open-bitrix-form">Записаться к этому педагогу</button>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
</section>