File: /home/ayxmplky/public_html/wp-content/themes/tactic/template-parts/contact/form.php
<?php
/**
* Template Part: Страница «Контакты»
* Структура по макету:
* — Hero: заголовок + описание слева, QR-код справа
* — Форма обратной связи (wp_mail через admin-ajax)
* — Контактная информация (офис, телефон, почта)
*
* @package tactic
*/
$qr_id = absint( get_theme_mod( 'tactic_wechat_qr_id', 0 ) );
$qr_src = $qr_id ? wp_get_attachment_image_url( $qr_id, 'full' ) : '';
$address_cn = get_theme_mod( 'tactic_address_cn', '' );
$address_en = get_theme_mod( 'tactic_address_en', '' );
$email_eu = get_theme_mod( 'tactic_email_eu', '' );
$email_gl = get_theme_mod( 'tactic_email_global', '' );
$phone = get_theme_mod( 'tactic_phone', '' );
$postal = get_theme_mod( 'tactic_postal_code', '' );
$main_website_url = trim( (string) get_theme_mod( 'tactic_contact_main_website_url', '' ) );
if ( $main_website_url === '' ) {
$main_website_url = home_url( '/' );
}
$is_en = tactic_current_lang() === 'en';
$address = $is_en ? $address_en : $address_cn;
?>
<section class="contact-hero">
<div class="contact-hero__inner">
<div class="contact-hero__content">
<nav class="contact-breadcrumb" aria-label="<?php echo esc_attr( tactic_s( 'common_breadcrumb_aria' ) ); ?>">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( tactic_s( 'nav_home' ) ); ?></a>
<span aria-hidden="true">›</span>
<span><?php echo esc_html( tactic_s( 'contact_title' ) ); ?></span>
</nav>
<h1 class="contact-hero__title"><?php echo esc_html( tactic_s( 'contact_title' ) ); ?></h1>
<?php if ( $qr_src ) : ?>
<p class="contact-hero__label"><?php echo esc_html( tactic_s( 'contact_qr_label' ) ); ?></p>
<p class="contact-hero__desc"><?php echo esc_html( tactic_s( 'contact_qr_desc' ) ); ?></p>
<?php endif; ?>
</div>
<?php if ( $qr_src ) : ?>
<div class="contact-hero__qr">
<img
src="<?php echo esc_url( $qr_src ); ?>"
alt="<?php echo esc_attr( tactic_s( 'contact_qr_alt' ) ); ?>"
width="120" height="120"
>
</div>
<?php endif; ?>
</div>
</section>
<!-- ── Форма обратной связи ── -->
<section class="contact-form-section">
<div class="contact-form-section__inner">
<h2 class="contact-form-section__title"><?php echo esc_html( tactic_s( 'contact_form_title' ) ); ?></h2>
<div id="contact-form-notice" class="contact-notice" hidden></div>
<form
class="contact-form"
id="contact-form"
novalidate
data-msg-success="<?php echo esc_attr( tactic_s( 'contact_success' ) ); ?>"
data-msg-error="<?php echo esc_attr( tactic_s( 'contact_error' ) ); ?>"
data-msg-invalid-email="<?php echo esc_attr( tactic_s( 'contact_invalid_email' ) ); ?>"
data-msg-invalid-phone="<?php echo esc_attr( tactic_s( 'contact_invalid_phone' ) ); ?>"
data-msg-required-name="<?php echo esc_attr( tactic_s( 'contact_required_name' ) ); ?>"
data-msg-required-company="<?php echo esc_attr( tactic_s( 'contact_required_company' ) ); ?>"
data-msg-required-mobile="<?php echo esc_attr( tactic_s( 'contact_required_mobile' ) ); ?>"
data-msg-required-email="<?php echo esc_attr( tactic_s( 'contact_required_email' ) ); ?>"
data-msg-required-phone="<?php echo esc_attr( tactic_s( 'contact_required_phone' ) ); ?>"
data-msg-required-address="<?php echo esc_attr( tactic_s( 'contact_required_address' ) ); ?>"
data-msg-required-gender="<?php echo esc_attr( tactic_s( 'contact_required_gender' ) ); ?>"
data-msg-required-message="<?php echo esc_attr( tactic_s( 'contact_required_message' ) ); ?>"
data-msg-required-terms="<?php echo esc_attr( tactic_s( 'contact_required_terms' ) ); ?>"
aria-label="<?php echo esc_attr( tactic_s( 'contact_form_title' ) ); ?>"
>
<?php wp_nonce_field( 'tactic_contact_form', 'contact_nonce' ); ?>
<div class="contact-form__row">
<div class="contact-form__field">
<label for="cf-name" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_name' ) ); ?></label>
<input type="text" id="cf-name" name="cf_name" autocomplete="name"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_name' ) ); ?>"
required maxlength="100">
</div>
<div class="contact-form__field contact-form__field--gender">
<div class="contact-form__radio-group" role="group" aria-label="<?php echo esc_attr( tactic_s( 'contact_gender_aria' ) ); ?>">
<label class="contact-form__radio-label">
<input type="radio" id="cf-gender-male" name="cf_gender" value="male" required>
<span><?php echo esc_html( tactic_s( 'contact_field_gender_male' ) ); ?></span>
</label>
<label class="contact-form__radio-label">
<input type="radio" id="cf-gender-female" name="cf_gender" value="female" checked>
<span><?php echo esc_html( tactic_s( 'contact_field_gender_female' ) ); ?></span>
</label>
</div>
</div>
</div>
<div class="contact-form__row">
<div class="contact-form__field">
<label for="cf-company" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_company' ) ); ?></label>
<input type="text" id="cf-company" name="cf_company" autocomplete="organization"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_company' ) ); ?>"
required maxlength="200">
</div>
<div class="contact-form__field">
<label for="cf-mobile" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_mobile' ) ); ?></label>
<input type="tel" id="cf-mobile" name="cf_mobile" autocomplete="tel"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_mobile' ) ); ?>"
required maxlength="50">
</div>
</div>
<div class="contact-form__row">
<div class="contact-form__field">
<label for="cf-email" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_email' ) ); ?></label>
<input type="email" id="cf-email" name="cf_email" autocomplete="email"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_email' ) ); ?>"
required maxlength="200">
</div>
<div class="contact-form__field">
<label for="cf-phone" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_phone' ) ); ?></label>
<input type="tel" id="cf-phone" name="cf_phone" autocomplete="tel"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_phone' ) ); ?>"
required maxlength="50">
</div>
</div>
<div class="contact-form__field contact-form__field--full">
<label for="cf-address" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_address' ) ); ?></label>
<input type="text" id="cf-address" name="cf_address" autocomplete="street-address"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_address' ) ); ?>"
required maxlength="300">
</div>
<div class="contact-form__field contact-form__field--full">
<label for="cf-message" class="sr-only"><?php echo esc_html( tactic_s( 'contact_field_message' ) ); ?></label>
<textarea id="cf-message" name="cf_message"
placeholder="<?php echo esc_attr( tactic_s( 'contact_field_message' ) ); ?>"
required maxlength="2000" rows="5"></textarea>
</div>
<label class="contact-form__terms" for="cf-terms">
<input type="checkbox" id="cf-terms" name="cf_terms" required>
<span><?php echo esc_html( tactic_s( 'contact_terms' ) ); ?></span>
</label>
<button type="submit" class="btn btn--primary contact-form__submit">
<span class="contact-form__submit-text"><?php echo esc_html( tactic_s( 'contact_submit' ) ); ?></span>
<span class="contact-form__submit-spinner" aria-hidden="true" hidden></span>
</button>
</form>
</div>
</section>
<div class="contact-redirect-modal" id="contact-redirect-modal" hidden>
<div class="contact-redirect-modal__backdrop" data-modal-close></div>
<div
class="contact-redirect-modal__dialog"
role="dialog"
aria-modal="true"
aria-labelledby="contact-redirect-modal-title"
>
<h3 class="contact-redirect-modal__title" id="contact-redirect-modal-title"><?php echo esc_html( tactic_s( 'contact_modal_title' ) ); ?></h3>
<p class="contact-redirect-modal__text"><?php echo esc_html( tactic_s( 'contact_modal_text' ) ); ?></p>
<div class="contact-redirect-modal__actions">
<button type="button" class="btn btn--outline contact-redirect-modal__btn-secondary" data-modal-close>
<?php echo esc_html( tactic_s( 'contact_modal_stay' ) ); ?>
</button>
<a class="btn btn--primary contact-redirect-modal__btn-primary" href="<?php echo esc_url( $main_website_url ); ?>">
<?php echo esc_html( tactic_s( 'contact_modal_go' ) ); ?>
</a>
</div>
</div>
</div>
<!-- ── Контактная информация ── -->
<section class="contact-info">
<div class="contact-info__inner">
<div class="contact-info__grid">
<div class="contact-info__item">
<span class="contact-info__label"><?php echo esc_html( tactic_s( 'contact_office_cn' ) ); ?></span>
<?php if ( $address ) : ?>
<span class="contact-info__value"><?php echo esc_html( $address ); ?></span>
<?php endif; ?>
</div>
<div class="contact-info__item">
<span class="contact-info__label"><?php echo esc_html( tactic_s( 'contact_email_cn_label' ) ); ?></span>
<?php if ( $email_gl ) : ?>
<a href="mailto:<?php echo esc_attr( sanitize_email( $email_gl ) ); ?>" class="contact-info__value contact-info__value--link">
<?php echo esc_html( $email_gl ); ?>
</a>
<?php else : ?>
<span class="contact-info__value contact-info__placeholder"><?php echo esc_html( tactic_s( 'contact_placeholder_email' ) ); ?></span>
<?php endif; ?>
</div>
<!-- <div class="contact-info__item">
<span class="contact-info__label"><?php echo esc_html( tactic_s( 'contact_postal_label' ) ); ?></span>
<?php if ( $postal ) : ?>
<span class="contact-info__value"><?php echo esc_html( $postal ); ?></span>
<?php else : ?>
<span class="contact-info__value contact-info__placeholder"><?php echo esc_html( tactic_s( 'contact_postal_label' ) ); ?></span>
<?php endif; ?>
</div>
<div class="contact-info__item">
<span class="contact-info__label"><?php echo esc_html( tactic_s( 'contact_email_eu_label' ) ); ?></span>
<?php if ( $email_eu ) : ?>
<a href="mailto:<?php echo esc_attr( sanitize_email( $email_eu ) ); ?>" class="contact-info__value contact-info__value--link">
<?php echo esc_html( $email_eu ); ?>
</a>
<?php else : ?>
<span class="contact-info__value contact-info__placeholder"><?php echo esc_html( tactic_s( 'contact_placeholder_email' ) ); ?></span>
<?php endif; ?>
</div> -->
</div>
</div>
</section>