File: /home/ayxmplky/public_html/wp-content/themes/tactic/template-parts/home/about.php
<?php
/**
* Template Part: О компании (关于TACTIC)
* Контент берётся со страницы с slug "about",
* либо из настроек Customizer.
*
* @package tactic
*/
$btn_text = get_theme_mod( 'tactic_about_btn_text', tactic_s( 'about_btn' ) );
$btn_url = get_theme_mod( 'tactic_about_btn_url', home_url( '/about/' ) );
if ( tactic_current_lang() === 'en' ) {
$btn_text = tactic_s( 'about_btn' );
}
// Ищем страницу «О компании» — сначала по slug 'about', затем по 'o-kompanii' (на случай переименования).
$about_page = get_page_by_path( 'about' ) ?? get_page_by_path( 'o-kompanii' );
$about_building_id = (int) get_option( 'tactic_about_home_building_id', 0 );
if ( ! $about_building_id && $about_page ) {
$about_building_id = (int) get_post_meta( $about_page->ID, '_about_building_id', true );
}
$about_building_url = $about_building_id ? wp_get_attachment_image_url( $about_building_id, 'full' ) : '';
if ( ! $about_building_url ) {
$asset_path = TACTIC_DIR . '/assets/images/about-building.png';
if ( file_exists( $asset_path ) ) {
$about_building_url = TACTIC_URI . '/assets/images/about-building.png';
}
}
$about_badges = [];
$badge_posts = get_posts( [
'post_type' => 'tactic_testimonial',
'post_status' => 'publish',
'posts_per_page' => 2,
'orderby' => 'date',
'order' => 'DESC',
] );
foreach ( $badge_posts as $badge_post ) {
if ( has_post_thumbnail( $badge_post->ID ) ) {
$thumb = get_the_post_thumbnail_url( $badge_post->ID, 'thumbnail' );
if ( $thumb ) {
$about_badges[] = $thumb;
}
}
}
?>
<section class="section section--about" id="about">
<div class="about__inner">
<div class="about__content">
<h2 class="section__title"><?php echo esc_html( tactic_s( 'about_title' ) ); ?></h2>
<p class="section__subtitle"><?php echo esc_html( tactic_s( 'about_subtitle' ) ); ?></p>
<div class="about__body">
<?php
$about_content = $about_page ? trim( $about_page->post_content ) : '';
// Для EN не используем post_content страницы, чтобы ZH-контент
// не перебивал локализованные строки из админки переводов.
if ( tactic_current_lang() !== 'en' && $about_content ) :
?>
<?php echo wp_kses_post( apply_filters( 'the_content', $about_content ) ); ?>
<?php else : ?>
<p><?php echo esc_html( tactic_s( 'about_p1' ) ); ?></p>
<p><?php echo esc_html( tactic_s( 'about_p2' ) ); ?></p>
<p><?php echo esc_html( tactic_s( 'about_p3' ) ); ?></p>
<p><?php echo esc_html( tactic_s( 'about_p4' ) ); ?></p>
<?php endif; ?>
</div>
<a href="<?php echo esc_url( $btn_url ); ?>" class="btn btn--dark about__btn">
<?php echo esc_html( $btn_text ); ?> <span aria-hidden="true">→</span>
</a>
</div>
<div class="about__media" aria-hidden="true">
<span class="about__media-bg about__media-bg--blue"></span>
<span class="about__media-bg about__media-bg--gray"></span>
<?php if ( $about_building_url ) : ?>
<img src="<?php echo esc_url( $about_building_url ); ?>" alt="" class="about__building" loading="lazy">
<?php else : ?>
<div class="about__building about__building--placeholder"></div>
<?php endif; ?>
<?php foreach ( $about_badges as $i => $badge_url ) : ?>
<span class="about__badge <?php echo 0 === $i ? 'about__badge--top' : 'about__badge--bottom'; ?>">
<img src="<?php echo esc_url( $badge_url ); ?>" alt="" loading="lazy">
</span>
<?php endforeach; ?>
</div>
</div>
</section>