From 409668ac50076ea3c116fa1fbb0c831b550ce0c5 Mon Sep 17 00:00:00 2001 From: "Anton.AE" Date: Sat, 4 Jul 2026 19:40:48 +0300 Subject: [PATCH] fix --- wp-config.php | 3 +- .../assets/css/layout.css | 73 ++++++++++++ .../assets/css/style-core.css | 4 + .../sevastopol-tort-child/assets/js/site.js | 104 ++++++++++++++++++ .../themes/sevastopol-tort-child/footer.php | 11 +- .../sevastopol-tort-child/front-page.php | 8 +- .../themes/sevastopol-tort-child/header.php | 7 +- .../sevastopol-tort-child/inc/forms.php | 22 +++- .../sevastopol-tort-child/inc/theme-data.php | 16 +-- .../page-templates/page-portfolio.php | 2 +- .../page-templates/page-service.php | 4 +- .../template-parts/lead-form.php | 9 +- 12 files changed, 236 insertions(+), 27 deletions(-) diff --git a/wp-config.php b/wp-config.php index 779acfb..ab6aec5 100644 --- a/wp-config.php +++ b/wp-config.php @@ -89,7 +89,8 @@ define( 'WP_DEBUG', false ); /* Add any custom values between this line and the "stop editing" line. */ - +define( 'SEV_TORT_TELEGRAM_BOT_TOKEN', '8607238298:AAH_dZ-EgzFOpT0LtmYuiy4ifcsvLZxXwPk' ); +define( 'SEV_TORT_TELEGRAM_CHAT_ID', '-1003995055932' ); /* That's all, stop editing! Happy publishing. */ diff --git a/wp-content/themes/sevastopol-tort-child/assets/css/layout.css b/wp-content/themes/sevastopol-tort-child/assets/css/layout.css index 5fa10c4..d487ac3 100644 --- a/wp-content/themes/sevastopol-tort-child/assets/css/layout.css +++ b/wp-content/themes/sevastopol-tort-child/assets/css/layout.css @@ -241,7 +241,10 @@ align-items: center; min-height: 46px; border-bottom: 1px solid var(--color-line); + color: var(--color-text); + font: inherit; font-weight: 700; + text-align: left; } .site-footer { @@ -315,6 +318,15 @@ box-shadow: var(--shadow-soft); } +.lead-form__trap { + position: absolute; + left: -10000px; + width: 1px; + height: 1px; + opacity: 0; + pointer-events: none; +} + .lead-form__head { display: grid; gap: 8px; @@ -381,6 +393,67 @@ color: var(--color-success); } +.lead-modal { + position: fixed; + inset: 0; + z-index: 120; + display: grid; + place-items: center; + padding: 20px; +} + +.lead-modal[hidden] { + display: none; +} + +.lead-modal__overlay { + position: absolute; + inset: 0; + background: rgba(44, 33, 29, 0.58); +} + +.lead-modal__dialog { + position: relative; + width: min(100%, 520px); + max-height: calc(100vh - 40px); + overflow: auto; +} + +.lead-modal__close { + position: absolute; + top: 14px; + right: 14px; + z-index: 2; + width: 36px; + height: 36px; + border-radius: 50%; + background: var(--color-surface-soft); +} + +.lead-modal__close::before, +.lead-modal__close::after { + position: absolute; + top: 17px; + left: 10px; + width: 16px; + height: 2px; + border-radius: 2px; + background: var(--color-text); + content: ""; +} + +.lead-modal__close::before { + transform: rotate(45deg); +} + +.lead-modal__close::after { + transform: rotate(-45deg); +} + +.lead-modal .lead-form { + padding-top: 54px; +} + .cookie-note { position: fixed; right: 24px; diff --git a/wp-content/themes/sevastopol-tort-child/assets/css/style-core.css b/wp-content/themes/sevastopol-tort-child/assets/css/style-core.css index c8d974f..2c3ddf2 100644 --- a/wp-content/themes/sevastopol-tort-child/assets/css/style-core.css +++ b/wp-content/themes/sevastopol-tort-child/assets/css/style-core.css @@ -48,6 +48,10 @@ body.menu-is-open { overflow: hidden; } +body.lead-modal-is-open { + overflow: hidden; +} + .button-main, .lead-form__button { display: inline-flex; diff --git a/wp-content/themes/sevastopol-tort-child/assets/js/site.js b/wp-content/themes/sevastopol-tort-child/assets/js/site.js index ae37dc5..9e52d81 100644 --- a/wp-content/themes/sevastopol-tort-child/assets/js/site.js +++ b/wp-content/themes/sevastopol-tort-child/assets/js/site.js @@ -7,6 +7,11 @@ var catalogButton = document.querySelector('.site-header__menu-button'); var cookieNote = document.querySelector('[data-cookie-note]'); var cookieButton = document.querySelector('[data-cookie-accept]'); + var leadModal = document.querySelector('[data-lead-modal]'); + var leadOpenNodes = document.querySelectorAll('[data-lead-open]'); + var leadCloseNodes = document.querySelectorAll('[data-lead-close]'); + var phoneInputs = document.querySelectorAll('[data-phone-mask]'); + var emailInputs = document.querySelectorAll('[data-email-mask]'); function setMenuState(isOpen) { if (!menu || !toggle) { @@ -19,6 +24,67 @@ toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); } + function setLeadModalState(isOpen, source) { + if (!leadModal) { + return; + } + + leadModal.hidden = !isOpen; + body.classList.toggle('lead-modal-is-open', isOpen); + + if (!isOpen) { + return; + } + + var pageInput = leadModal.querySelector('input[name="lead_page"]'); + var sourceInput = leadModal.querySelector('input[name="lead_source"]'); + var firstInput = leadModal.querySelector('input[name="lead_name"]'); + + if (pageInput) { + pageInput.value = document.title + ' | ' + window.location.pathname; + } + + if (sourceInput) { + sourceInput.value = source || 'Попап заявки'; + } + + if (firstInput) { + window.setTimeout(function () { + firstInput.focus(); + }, 80); + } + } + + function applyPhoneMask(input) { + var digits = input.value.replace(/\D/g, ''); + + if (digits.charAt(0) === '8') { + digits = '7' + digits.slice(1); + } + + if (digits.charAt(0) === '7') { + digits = digits.slice(1); + } + + digits = digits.slice(0, 10); + + var value = '+7'; + if (digits.length > 0) { + value += ' (' + digits.slice(0, 3); + } + if (digits.length >= 3) { + value += ') ' + digits.slice(3, 6); + } + if (digits.length >= 6) { + value += '-' + digits.slice(6, 8); + } + if (digits.length >= 8) { + value += '-' + digits.slice(8, 10); + } + + input.value = value; + } + if (menu && toggle) { toggle.addEventListener('click', function () { setMenuState(!menu.classList.contains('is-open')); @@ -46,6 +112,44 @@ }); } + leadOpenNodes.forEach(function (node) { + node.addEventListener('click', function (event) { + event.preventDefault(); + setMenuState(false); + setLeadModalState(true, node.getAttribute('data-lead-source') || node.textContent.trim()); + }); + }); + + leadCloseNodes.forEach(function (node) { + node.addEventListener('click', function () { + setLeadModalState(false); + }); + }); + + document.addEventListener('keydown', function (event) { + if (event.key === 'Escape') { + setLeadModalState(false); + } + }); + + phoneInputs.forEach(function (input) { + input.addEventListener('focus', function () { + if (!input.value) { + input.value = '+7'; + } + }); + + input.addEventListener('input', function () { + applyPhoneMask(input); + }); + }); + + emailInputs.forEach(function (input) { + input.addEventListener('input', function () { + input.value = input.value.replace(/\s/g, '').toLowerCase(); + }); + }); + if (cookieNote && cookieButton && window.localStorage) { if (localStorage.getItem('sevTortCookieAccepted') !== 'yes') { cookieNote.hidden = false; diff --git a/wp-content/themes/sevastopol-tort-child/footer.php b/wp-content/themes/sevastopol-tort-child/footer.php index 241deeb..c7d4ef2 100644 --- a/wp-content/themes/sevastopol-tort-child/footer.php +++ b/wp-content/themes/sevastopol-tort-child/footer.php @@ -35,8 +35,8 @@ if ( ! defined( 'ABSPATH' ) ) { Контакты @@ -48,6 +48,13 @@ if ( ! defined( 'ABSPATH' ) ) { + - 'Обсудить торт', 'page' => 'Главная' ) ); ?> + 'Обсудить торт', 'page' => 'Главная', 'source' => 'Встроенная форма: блок Как мы работаем' ) ); ?>
@@ -178,8 +178,8 @@ get_header();

Напишите нам в мессенджер или оставьте заявку, чтобы получить 2-3 идеи оформления и ориентир по цене.

diff --git a/wp-content/themes/sevastopol-tort-child/header.php b/wp-content/themes/sevastopol-tort-child/header.php index e557d56..3fbbc17 100644 --- a/wp-content/themes/sevastopol-tort-child/header.php +++ b/wp-content/themes/sevastopol-tort-child/header.php @@ -43,7 +43,7 @@ if ( ! defined( 'ABSPATH' ) ) {
  • Контакты
  • - Заказать торт + - WhatsApp - Telegram + diff --git a/wp-content/themes/sevastopol-tort-child/inc/forms.php b/wp-content/themes/sevastopol-tort-child/inc/forms.php index a8843d2..4867961 100644 --- a/wp-content/themes/sevastopol-tort-child/inc/forms.php +++ b/wp-content/themes/sevastopol-tort-child/inc/forms.php @@ -16,20 +16,32 @@ function sev_tort_handle_lead_form() { sev_tort_redirect_form_status( 'consent' ); } + if ( ! empty( $_POST['lead_company'] ) ) { + sev_tort_redirect_form_status( 'success' ); + } + $name = isset( $_POST['lead_name'] ) ? sanitize_text_field( wp_unslash( $_POST['lead_name'] ) ) : ''; $phone = isset( $_POST['lead_phone'] ) ? sanitize_text_field( wp_unslash( $_POST['lead_phone'] ) ) : ''; + $email = isset( $_POST['lead_email'] ) ? sanitize_email( wp_unslash( $_POST['lead_email'] ) ) : ''; $message = isset( $_POST['lead_message'] ) ? sanitize_textarea_field( wp_unslash( $_POST['lead_message'] ) ) : ''; $page = isset( $_POST['lead_page'] ) ? sanitize_text_field( wp_unslash( $_POST['lead_page'] ) ) : ''; + $source = isset( $_POST['lead_source'] ) ? sanitize_text_field( wp_unslash( $_POST['lead_source'] ) ) : ''; - if ( '' === $phone ) { + if ( '' === $phone || ! preg_match( '/^\+7 \([0-9]{3}\) [0-9]{3}-[0-9]{2}-[0-9]{2}$/', $phone ) ) { + sev_tort_redirect_form_status( 'error' ); + } + + if ( '' !== $email && ! is_email( $email ) ) { sev_tort_redirect_form_status( 'error' ); } $text = "Новая заявка с сайта sevastopol-tort.ru\n"; - $text .= "Страница: " . $page . "\n"; - $text .= "Имя: " . ( $name ? $name : 'не указано' ) . "\n"; - $text .= "Телефон: " . $phone . "\n"; - $text .= "Комментарий: " . ( $message ? $message : 'не указан' ); + $text .= 'Страница: ' . ( $page ? $page : 'не указана' ) . "\n"; + $text .= 'Источник: ' . ( $source ? $source : 'не указан' ) . "\n"; + $text .= 'Имя: ' . ( $name ? $name : 'не указано' ) . "\n"; + $text .= 'Телефон: ' . $phone . "\n"; + $text .= 'Почта: ' . ( $email ? $email : 'не указана' ) . "\n"; + $text .= 'Комментарий: ' . ( $message ? $message : 'не указан' ); $sent = sev_tort_send_telegram_message( $text ); diff --git a/wp-content/themes/sevastopol-tort-child/inc/theme-data.php b/wp-content/themes/sevastopol-tort-child/inc/theme-data.php index 41529f2..0f6d48b 100644 --- a/wp-content/themes/sevastopol-tort-child/inc/theme-data.php +++ b/wp-content/themes/sevastopol-tort-child/inc/theme-data.php @@ -5,20 +5,20 @@ if ( ! defined( 'ABSPATH' ) ) { } function sev_tort_site_phone() { - return '+7 (978) 000-00-00'; + return '+7 (911) 774-89-23'; } function sev_tort_site_phone_href() { - return 'tel:+79780000000'; + return 'tel:+7 (911) 774-8923'; } -function sev_tort_whatsapp_url() { - return 'https://wa.me/79780000000'; -} +// function sev_tort_whatsapp_url() { +// return 'https://wa.me/79780000000'; +// } -function sev_tort_telegram_url() { - return 'https://t.me/sevastopol_tort'; -} +// function sev_tort_telegram_url() { +// return 'https://t.me/sevastopol_tort'; +// } function sev_tort_pages() { return array( diff --git a/wp-content/themes/sevastopol-tort-child/page-templates/page-portfolio.php b/wp-content/themes/sevastopol-tort-child/page-templates/page-portfolio.php index 903b100..c9e9ef7 100644 --- a/wp-content/themes/sevastopol-tort-child/page-templates/page-portfolio.php +++ b/wp-content/themes/sevastopol-tort-child/page-templates/page-portfolio.php @@ -117,7 +117,7 @@ get_header();

    Понравился стиль из портфолио?

    Отправьте пример, дату и пожелания по весу. Подскажем начинку, стоимость и ближайший свободный срок.

    - 'portfolio' ) ); ?> + 'Оставить заявку', 'page' => 'Портфолио', 'source' => 'Встроенная форма: портфолио' ) ); ?>
    diff --git a/wp-content/themes/sevastopol-tort-child/page-templates/page-service.php b/wp-content/themes/sevastopol-tort-child/page-templates/page-service.php index 6f8ba93..303591b 100644 --- a/wp-content/themes/sevastopol-tort-child/page-templates/page-service.php +++ b/wp-content/themes/sevastopol-tort-child/page-templates/page-service.php @@ -20,7 +20,7 @@ get_header();

    - Получить расчет + Написать в Telegram
    @@ -115,7 +115,7 @@ get_header();

    Расскажите, какой торт нужен

    Укажите дату, повод, примерный вес и пожелания по декору. Если пока нет точной идеи, поможем подобрать варианты.

    - 'Получить расчет', 'page' => $page['title'] ) ); ?> + 'Получить расчет', 'page' => $page['title'], 'source' => 'Встроенная форма: страница ' . $page['label'] ) ); ?> diff --git a/wp-content/themes/sevastopol-tort-child/template-parts/lead-form.php b/wp-content/themes/sevastopol-tort-child/template-parts/lead-form.php index a75ddd0..85f770b 100644 --- a/wp-content/themes/sevastopol-tort-child/template-parts/lead-form.php +++ b/wp-content/themes/sevastopol-tort-child/template-parts/lead-form.php @@ -5,10 +5,13 @@ if ( ! defined( 'ABSPATH' ) ) { $form_title = isset( $args['title'] ) ? $args['title'] : 'Оставить заявку'; $form_page = isset( $args['page'] ) ? $args['page'] : ''; +$form_source = isset( $args['source'] ) ? $args['source'] : 'Встроенная форма'; ?>
    + +
    @@ -20,7 +23,11 @@ $form_page = isset( $args['page'] ) ? $args['page'] : ''; +