HEX
Server: LiteSpeed
System: Linux prometheus.hongkongserver.net 4.18.0-553.134.1.el8_10.x86_64 #1 SMP Tue Jun 16 16:05:57 EDT 2026 x86_64
User: ayxmplky (1112)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/ayxmplky/public_html/wp-content/themes/tactic/template-parts/home/global-map.php
<?php
/**
 * Template Part: Глобальное сотрудничество (全球工业合作)
 *
 * @package tactic
 */

$front_id  = (int) get_option( 'page_on_front' );
$map_admin_id = (int) get_option( 'tactic_map_image_id', 0 );
$map_id       = $map_admin_id ?: ( $front_id ? (int) get_post_meta( $front_id, '_map_bg_id', true ) : 0 );
$about_url = get_theme_mod( 'tactic_about_btn_url', home_url( '/about/' ) );

$map_fallback_rel  = '/assets/images/world-map-routes.png';
$map_fallback_path = get_template_directory() . $map_fallback_rel;
$map_fallback      = get_template_directory_uri() . $map_fallback_rel;

if ( file_exists( $map_fallback_path ) ) {
	$map_fallback = add_query_arg( 'v', (string) filemtime( $map_fallback_path ), $map_fallback );
}

$map_src = $map_fallback;

if ( $map_id ) {
	$map_from_admin = wp_get_attachment_image_url( $map_id, 'full' );
	if ( $map_from_admin ) {
		$map_src = $map_from_admin;
		$map_abs = get_attached_file( $map_id );
		if ( $map_abs && file_exists( $map_abs ) ) {
			$map_src = add_query_arg( 'v', (string) filemtime( $map_abs ), $map_src );
		}
	}
}

$saved_stats = get_option( 'tactic_map_stats', [] );
$stats       = [];

if ( is_array( $saved_stats ) && ! empty( $saved_stats ) ) {
	$lang = tactic_current_lang();

	foreach ( $saved_stats as $row ) {
		if ( ! is_array( $row ) ) {
			continue;
		}

		$text = '';
		if ( ! empty( $row[ $lang ] ) ) {
			$text = (string) $row[ $lang ];
		} elseif ( ! empty( $row['en'] ) ) {
			$text = (string) $row['en'];
		} elseif ( ! empty( $row['zh'] ) ) {
			$text = (string) $row['zh'];
		}

		$text = trim( $text );
		if ( '' !== $text ) {
			$stats[] = $text;
		}
	}
}

if ( empty( $stats ) ) {
	$stats = [
		get_theme_mod( 'tactic_stat1', tactic_s( 'stat1' ) ),
		get_theme_mod( 'tactic_stat2', tactic_s( 'stat2' ) ),
		get_theme_mod( 'tactic_stat3', tactic_s( 'stat3' ) ),
		get_theme_mod( 'tactic_stat4', tactic_s( 'stat4' ) ),
		get_theme_mod( 'tactic_stat5', tactic_s( 'stat5' ) ),
	];

	if ( tactic_current_lang() === 'en' ) {
		$stats = [
			tactic_s( 'stat1' ),
			tactic_s( 'stat2' ),
			tactic_s( 'stat3' ),
			tactic_s( 'stat4' ),
			tactic_s( 'stat5' ),
		];
	}

	$stats = array_values( array_filter( $stats ) );
}
$arrow_src = get_template_directory_uri() . '/assets/images/map-slider-arrow-v2.svg';
?>
<section class="section--map" id="global">

<!-- Шапка: заголовок + кнопка -->
<div class="map__header">
<div class="map__header-left">
<h2 class="map__title"><?php echo esc_html( tactic_s( 'map_title' ) ); ?></h2>
<p class="map__subtitle"><?php echo esc_html( tactic_s( 'map_subtitle' ) ); ?></p>
</div>
<a href="<?php echo esc_url( $about_url ); ?>" class="btn btn--dark map__cta">
<?php echo esc_html( tactic_s( 'map_cta' ) ); ?> <span aria-hidden="true">→</span>
</a>
</div>

<!-- Карта + статистика -->
<div class="map__grid">
<div class="map__image-wrap">
<img
src="<?php echo esc_url( $map_src ); ?>"
alt="<?php echo esc_attr( tactic_s( 'map_img_alt' ) ); ?>"
class="map__img"
loading="lazy"
/>
</div>
<div class="map__stats-slider" data-map-slider>
<ul class="map__stats" role="list">
<?php foreach ( $stats as $stat ) : ?>
<li class="map__stat-item"><?php echo esc_html( $stat ); ?></li>
<?php endforeach; ?>
</ul>
<div class="map__stats-nav" aria-label="<?php echo esc_attr( tactic_s( 'map_stats_controls_aria' ) ); ?>">
<button type="button" class="map__stats-nav-btn map__stats-nav-btn--up" data-dir="prev" aria-label="<?php echo esc_attr( tactic_s( 'map_stats_prev_aria' ) ); ?>">
<img src="<?php echo esc_url( $arrow_src ); ?>" alt="" loading="lazy" decoding="async" />
</button>
<button type="button" class="map__stats-nav-btn map__stats-nav-btn--down" data-dir="next" aria-label="<?php echo esc_attr( tactic_s( 'map_stats_next_aria' ) ); ?>">
<img src="<?php echo esc_url( $arrow_src ); ?>" alt="" loading="lazy" decoding="async" />
</button>
</div>
</div>
		</div>

</section>