Files
smilia/wp-content/themes/smilia/components/booking/booking.php
T

102 lines
5.7 KiB
PHP

<?php
use Smilia\Theme\Data;
defined( 'ABSPATH' ) || exit;
$smilia_form = Data::booking();
if ( ! $smilia_form ) {
return;
}
$smilia_messages = array(
'name' => __( 'Проверьте имя.', 'smilia' ),
'phone' => __( 'Проверьте номер телефона.', 'smilia' ),
'consent' => __( 'Нужно ваше согласие на обработку персональных данных.', 'smilia' ),
'network' => __( 'Не получилось отправить заявку. Проверьте интернет или позвоните нам.', 'smilia' ),
'limit' => __( 'Слишком много заявок подряд. Попробуйте через минуту.', 'smilia' ),
'guard' => __( 'Не удалось подтвердить отправку. Обновите страницу и отправьте заявку ещё раз.', 'smilia' ),
);
?>
<dialog class="booking" id="booking" aria-labelledby="booking-title">
<button type="button" class="booking__close" data-booking-close aria-label="<?php esc_attr_e( 'Закрыть', 'smilia' ); ?>">
<svg class="booking__close-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6L6 18"/></svg>
</button>
<form class="booking__form" method="post" action="<?php echo esc_url( $smilia_form['endpoint'] ); ?>" novalidate data-booking-form data-rest-nonce="<?php echo esc_attr( $smilia_form['rest'] ); ?>" data-altcha-script="<?php echo esc_url( $smilia_form['script'] ); ?>" data-messages="<?php echo esc_attr( wp_json_encode( $smilia_messages ) ); ?>">
<h2 class="booking__title" id="booking-title"><?php echo esc_html( Data::setting( 'booking_title' ) ); ?></h2>
<p class="booking__lead"><?php echo esc_html( Data::setting( 'booking_lead' ) ); ?></p>
<p class="booking__demo"><?php esc_html_e( 'Демонстрационный сайт: заявка не будет обработана.', 'smilia' ); ?></p>
<div class="booking__fields">
<label class="field">
<span class="field__label"><?php esc_html_e( 'Ваше имя', 'smilia' ); ?></span>
<input class="field__input" type="text" name="name" autocomplete="name" maxlength="80" required placeholder="<?php esc_attr_e( 'Как к вам обращаться', 'smilia' ); ?>">
</label>
<label class="field">
<span class="field__label"><?php esc_html_e( 'Телефон', 'smilia' ); ?></span>
<input class="field__input" type="tel" name="phone" autocomplete="tel" inputmode="tel" maxlength="24" required placeholder="<?php echo esc_attr( $smilia_form['phone']['example'] ); ?>" data-phone-code="<?php echo esc_attr( $smilia_form['phone']['code'] ); ?>" data-phone-digits="<?php echo esc_attr( (string) $smilia_form['phone']['digits'] ); ?>">
</label>
<div class="booking__row">
<label class="field">
<span class="field__label"><?php esc_html_e( 'Возраст', 'smilia' ); ?></span>
<input class="field__input" type="text" name="age" maxlength="20" placeholder="<?php esc_attr_e( '5 лет', 'smilia' ); ?>">
</label>
<label class="field">
<span class="field__label"><?php esc_html_e( 'Что беспокоит', 'smilia' ); ?></span>
<span class="field__select">
<select class="field__input" name="concern">
<?php foreach ( $smilia_form['concerns'] as $smilia_value => $smilia_label ) : ?>
<option value="<?php echo esc_attr( $smilia_value ); ?>"><?php echo esc_html( $smilia_label ); ?></option>
<?php endforeach; ?>
</select>
</span>
</label>
</div>
</div>
<div class="booking__trap" aria-hidden="true">
<label><?php esc_html_e( 'Сайт', 'smilia' ); ?><input type="text" name="website" tabindex="-1" autocomplete="off"></label>
</div>
<altcha-widget name="altcha" challenge="<?php echo esc_url( $smilia_form['captcha'] ); ?>" auto="onload" display="invisible"></altcha-widget>
<input type="hidden" name="smilia_nonce" value="<?php echo esc_attr( $smilia_form['nonce'] ); ?>">
<input type="hidden" name="started" value="<?php echo esc_attr( $smilia_form['started'] ); ?>">
<input type="hidden" name="page" value="">
<label class="consent">
<input class="consent__box" type="checkbox" name="consent" value="1" required>
<span class="consent__text">
<span class="consent__line">
<?php
printf(
wp_kses(
__( 'Нажимая «%1$s», я соглашаюсь на обработку <a href="%2$s" target="_blank">персональных данных</a> на условиях и для целей, определённых <a href="%3$s" target="_blank">Политикой конфиденциальности</a>.', 'smilia' ),
array(
'a' => array(
'href' => array(),
'target' => array(),
),
)
),
esc_html( Data::setting( 'booking_submit' ) ),
esc_url( $smilia_form['consent'] ),
esc_url( $smilia_form['privacy'] )
);
?>
</span>
</span>
</label>
<p class="booking__message" id="booking-message" role="alert" aria-live="assertive" data-booking-message></p>
<button type="submit" class="button button--primary button--lg booking__submit"><?php echo esc_html( Data::setting( 'booking_submit' ) ); ?></button>
</form>
<div class="booking__done" hidden data-booking-done>
<h2 class="booking__title"><?php echo esc_html( Data::setting( 'booking_done' ) ); ?></h2>
<p class="booking__lead" data-booking-done-text></p>
<p class="booking__demo"><?php esc_html_e( 'Демонстрационный сайт: заявка не будет обработана.', 'smilia' ); ?></p>
<button type="button" class="button button--primary" data-booking-close><?php esc_html_e( 'Хорошо', 'smilia' ); ?></button>
</div>
</dialog>