переработал систему модалок и добавил блоки

main
GP_DEV 2 months ago
parent f23ac49f97
commit 6f6e9c0af6
  1. 56
      blocks/advantages-block/advantages-block.php
  2. 91
      blocks/form-block/form-block.css
  3. 73
      blocks/form-block/form-block.php
  4. 15
      functions/forms.php
  5. 20
      modals/modal-form-success.php

@ -0,0 +1,56 @@
<?php
$id = 'advantages-block-' . $block['id'];
if ( ! empty($block['anchor'] ) ) {
$id = $block['anchor'];
}
$classes = 'block-advantages-block';
if ( ! empty( $block['className'] ) ) {
$classes .= ' ' . $block['className'];
}
if ( ! empty( $block['align'] ) ) {
$classes .= ' align' . $block['align'];
}
$heading = get_field('heading');
?>
<section id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
<div class="container mx-auto mt-[24px]">
<?php if ($heading) : ?>
<h2 class="text-[48px] max-[768px]:text-[36px] font-bold text-center text-[#1f2937] mb-[40px]">
<?php echo esc_html($heading); ?>
</h2>
<?php endif; ?>
<?php if ( have_rows( 'advantages_repeater' ) ) : ?>
<div class="mt-[24px] grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[30px] max-[768px]:gap-[20px]">
<?php while ( have_rows( 'advantages_repeater' ) ) : the_row(); ?>
<div class="bg-[#ffffff] border-[1px] border-[#e5e7eb] rounded-[16px] p-[30px] max-[768px]:p-[20px] shadow-lg hover:shadow-xl transition-shadow ">
<?php $advantage_heading = get_sub_field('heading'); ?>
<?php if (!empty($advantage_heading)) : ?>
<h3 class="text-[48px] max-[768px]:text-[34px] font-semibold text-[#1f2937] mb-[16px] text-center leading-[120%]">
<?php echo esc_html($advantage_heading); ?>
</h3>
<?php endif; ?>
<?php $advantage_text = get_sub_field('text'); ?>
<?php if (!empty($advantage_text)) : ?>
<div class="text-[16px] max-[768px]:text-[14px] text-[#6b7280] leading-[150%] text-center">
<?php echo wp_kses_post($advantage_text); ?>
</div>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<?php else : ?>
<!-- No advantages found -->
<?php endif; ?>
</div>
</section>

@ -0,0 +1,91 @@
.form-block-wrapper .ff-el-group {
margin-bottom: 24px;
}
.form-block-wrapper .ff-el-input--label label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #374151;
font-size: 14px;
}
.form-block-wrapper .ff-el-form-control {
width: 100%;
padding: 12px 16px;
border: 2px solid #e5e7eb;
border-radius: 8px;
font-size: 16px;
transition: all 0.2s ease;
background: #ffffff;
box-sizing: border-box;
}
.form-block-wrapper .ff-el-form-control:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-block-wrapper .ff-btn-submit {
width: 100%;
padding: 14px 24px;
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: none;
}
.form-block-wrapper .ff-btn-submit:hover {
transform: translateY(-1px);
box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}
.form-block-wrapper .ff-btn-submit:active {
transform: translateY(0);
}
.form-block-wrapper .asterisk-right label::after {
content: ' *';
color: #ef4444;
font-weight: bold;
}
.form-block-wrapper .ff-message-success,
.form-block-wrapper .ff-message-container {
display: none !important;
}
.form-block-wrapper.form-loading .ff-btn-submit {
opacity: 0.7;
pointer-events: none;
}
@media (max-width: 768px) {
.form-block-wrapper {
margin: 20px;
padding: 20px;
}
.form-block-wrapper .ff-el-form-control {
font-size: 16px;
padding: 10px 14px;
}
.form-block-wrapper .ff-btn-submit {
font-size: 16px;
padding: 12px 20px;
}
}
@media (max-width: 1024px) and (min-width: 769px) {
.form-block-wrapper {
padding: 25px;
}
}

@ -0,0 +1,73 @@
<?php
$form_id = get_field('form_id') ?: '3';
$form_title = get_field('form_title') ?: 'Форма обратной связи';
$submit_button_text = get_field('submit_button_text') ?: 'Отправить';
$unique_id = 'form-block-' . $block['id'];
$current_url = home_url($_SERVER['REQUEST_URI']);
$page_title = get_the_title() ?: 'Главная страница';
$form_name = $form_title;
$hidden_value = "Форма: {$form_name} | Страница: {$page_title} | URL: {$current_url}";
?>
<section class="container mx-auto mt-[22px]" id="<?php echo esc_attr($unique_id); ?>">
<div class="text-[24px] font-[700] mb-[20px] text-[#374151]">
<?php echo esc_html($form_title); ?>
</div>
<div class="form-block-wrapper bg-white p-[30px] rounded-[12px] max-w-[300px]"
data-form-id="<?php echo esc_attr($form_id); ?>"
data-submit-text="<?php echo esc_attr($submit_button_text); ?>"
data-hidden-value="<?php echo esc_attr($hidden_value); ?>">
<?php echo do_shortcode('[fluentform id="' . esc_attr($form_id) . '"]'); ?>
</div>
</section>
<script>
document.addEventListener('DOMContentLoaded', function() {
const section = document.getElementById('<?php echo esc_js($unique_id); ?>');
if (!section) return;
const block = section.querySelector('.form-block-wrapper');
if (!block) return;
const submitText = block.dataset.submitText;
const hiddenValue = block.dataset.hiddenValue;
function updateForm() {
const submitButton = block.querySelector('.ff-btn-submit');
const hiddenInput = block.querySelector('input[name="hidden"]');
let updated = false;
if (submitButton && submitText) {
submitButton.textContent = submitText;
updated = true;
}
if (hiddenInput && hiddenValue && !hiddenInput.value) {
hiddenInput.value = hiddenValue;
updated = true;
}
return updated;
}
if (!updateForm()) {
let attempts = 0;
const maxAttempts = 3;
const interval = setInterval(() => {
attempts++;
if (updateForm() || attempts >= maxAttempts) {
clearInterval(interval);
}
}, 150);
}
block.addEventListener('focusin', updateForm, { once: true });
});
</script>

@ -0,0 +1,15 @@
<?php
// Скрываем стандартный success message FluentForm
add_filter('fluentform/submission_message_success', function($message, $form, $formData) {
if ($form->id == 3) {
return ''; // Возвращаем пустое сообщение
}
return $message;
}, 10, 3);
// Опционально - логирование для отладки
add_action('fluentform/submission_inserted', function($submissionId, $formData, $form) {
if ($form->id == 3) {
error_log('FluentForm submission #' . $submissionId . ' inserted successfully');
}
}, 10, 3);

@ -0,0 +1,20 @@
<div class="p-[30px] max-[768px]:p-[20px] text-center">
<div class="w-[64px] h-[64px] bg-[#10b981] rounded-full mx-auto mb-[24px] flex items-center justify-center">
<svg class="w-[32px] h-[32px] text-[#ffffff]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7"></path>
</svg>
</div>
<h3 class="text-[24px] max-[768px]:text-[20px] font-bold text-[#1f2937] mb-[16px]">
Спасибо!
</h3>
<p class="text-[16px] max-[768px]:text-[14px] text-[#6b7280] leading-[150%] mb-[24px]">
Ваше сообщение успешно отправлено.<br>
Мы свяжемся с вами в ближайшее время.
</p>
<button data-modal-close class="bg-[#3b82f6] hover:bg-[#2563eb] text-[#ffffff] font-semibold py-[12px] px-[24px] rounded-[8px] transition-colors duration-300 focus:outline-none focus:ring-2 focus:ring-[#3b82f6] focus:ring-offset-2">
Закрыть
</button>
</div>
Loading…
Cancel
Save