From decc7c470a46868499e8e079fddfc86ea1a1a5f1 Mon Sep 17 00:00:00 2001 From: GP_DEV Date: Tue, 3 Jun 2025 21:52:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D1=83=20=D0=B8=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=D1=8B=20=D1=81=D1=82=D0=B8=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blocks/club-cards-block/club-cards-block.php | 27 +- blocks/contacts-block/contacts-block.php | 233 +++++++++-------- blocks/gallery-tabs/gallery-tabs.js | 96 ++++--- blocks/gallery-tabs/gallery-tabs.php | 200 ++++++-------- blocks/reviews-block/reviews-block.js | 81 ++++-- blocks/reviews-block/reviews-block.php | 259 ++++++++++--------- blocks/tiles-block/tiles-block.php | 62 +++++ footer.php | 3 +- functions/blocks.php | 15 ++ 9 files changed, 549 insertions(+), 427 deletions(-) create mode 100644 blocks/tiles-block/tiles-block.php diff --git a/blocks/club-cards-block/club-cards-block.php b/blocks/club-cards-block/club-cards-block.php index 20e5cf9..ef33e1d 100644 --- a/blocks/club-cards-block/club-cards-block.php +++ b/blocks/club-cards-block/club-cards-block.php @@ -13,28 +13,29 @@ if (!empty($block['align'])) { $class_name .= ' align' . $block['align']; } -// Получение карт для текущего языка -function get_club_cards_for_current_language() { - $current_lang = pll_current_language(); +if (!function_exists('get_club_cards_for_current_language')) { + function get_club_cards_for_current_language() { + $current_lang = pll_current_language(); - $args = array( - 'post_type' => 'club-card', - 'posts_per_page' => -1, - 'lang' => $current_lang, - 'post_status' => 'publish' - ); + $args = array( + 'post_type' => 'club-card', + 'posts_per_page' => -1, + 'lang' => $current_lang, + 'post_status' => 'publish' + ); - return get_posts($args); + return get_posts($args); + } } $cards = get_club_cards_for_current_language(); ?> -
+
-
+
ID)): ?>
ID, 'medium', ['class' => 'w-full h-full object-cover']); ?> @@ -56,7 +57,7 @@ $cards = get_club_cards_for_current_language();
diff --git a/blocks/contacts-block/contacts-block.php b/blocks/contacts-block/contacts-block.php index 0ab9eb1..bfd7b50 100644 --- a/blocks/contacts-block/contacts-block.php +++ b/blocks/contacts-block/contacts-block.php @@ -1,7 +1,22 @@ - -
- -
-
-
-
- - - - - - - - - - -
- - Свяжитесь с нами -
-
-

- Контакты

-
-

Номер телефона:

- - -
-
-

Головной офис:

-
- -
-
-
-

E-mail:

- +
+
+
+ +
+
+
+ + +

+ +

+ +

Контакты

+ + +
+ + +
+ +

+ + + +
+ +
+ +   + +
+ +
+ +
+ + + +
+ +

+ + + +
+ +
+ +
+ + +
+ +
+ +
+ +
+ + + +
+ +
+ + + +
+ + + +
+
+ + + + + <?php echo esc_attr($social_item['icon']['alt']); ?> + + + + +
+
+ +
+ +
diff --git a/blocks/gallery-tabs/gallery-tabs.js b/blocks/gallery-tabs/gallery-tabs.js index b07b20d..afe3a9e 100644 --- a/blocks/gallery-tabs/gallery-tabs.js +++ b/blocks/gallery-tabs/gallery-tabs.js @@ -12,23 +12,51 @@ function initGalleryBlock(blockId) { const swipers = {}; let lightbox; - function initSwiper(tabId) { - if (swipers[tabId]) { - swipers[tabId].destroy(true, true); - } + function initAllSwipers() { + const tabs = container.querySelectorAll('.tab-button'); - swipers[tabId] = new Swiper(`#${blockId} #swiper-${tabId}`, { - slidesPerView: 1.5, - spaceBetween: 20, - loop: true, - centeredSlides: true, - navigation: { - nextEl: `#${blockId} #swiper-${tabId} .swiper-button-next`, - prevEl: `#${blockId} #swiper-${tabId} .swiper-button-prev`, - }, - on: { - slideChange: function() { - updateThumbnails(tabId, this.realIndex); + tabs.forEach(button => { + const tabId = button.getAttribute('data-tab'); + const tabContent = container.querySelector(`#tab-${tabId}`); + + if (tabContent && tabContent.querySelector('.swiper')) { + const wasHidden = tabContent.classList.contains('hidden'); + if (wasHidden) { + tabContent.style.visibility = 'hidden'; + tabContent.style.position = 'absolute'; + tabContent.classList.remove('hidden'); + tabContent.classList.add('block'); + } + + if (swipers[tabId]) { + swipers[tabId].destroy(true, true); + } + + swipers[tabId] = new Swiper(`#${blockId} #swiper-${tabId}`, { + slidesPerView: 1.5, + spaceBetween: 20, + loop: true, + centeredSlides: true, + grabCursor: true, + observer: true, + observeParents: true, + watchSlidesProgress: true, + navigation: { + nextEl: `#${blockId} #swiper-${tabId} .swiper-button-next`, + prevEl: `#${blockId} #swiper-${tabId} .swiper-button-prev`, + }, + on: { + slideChange: function() { + updateThumbnails(tabId, this.realIndex); + } + } + }); + + if (wasHidden) { + tabContent.style.visibility = ''; + tabContent.style.position = ''; + tabContent.classList.add('hidden'); + tabContent.classList.remove('block'); } } }); @@ -57,7 +85,14 @@ function initGalleryBlock(blockId) { }); } - // Табы + initAllSwipers(); + + const activeTab = container.querySelector('.tab-button.active'); + if (activeTab) { + const tabId = activeTab.getAttribute('data-tab'); + initLightbox(tabId); + } + container.querySelectorAll('.tab-button').forEach(button => { button.addEventListener('click', () => { const tabId = button.getAttribute('data-tab'); @@ -73,17 +108,21 @@ function initGalleryBlock(blockId) { content.classList.remove('block'); content.classList.add('hidden'); }); - container.querySelector(`#tab-${tabId}`).classList.remove('hidden'); - container.querySelector(`#tab-${tabId}`).classList.add('block'); - setTimeout(() => { - initSwiper(tabId); - initLightbox(tabId); - }, 100); + const targetTab = container.querySelector(`#tab-${tabId}`); + targetTab.classList.remove('hidden'); + targetTab.classList.add('block'); + + if (swipers[tabId]) { + requestAnimationFrame(() => { + swipers[tabId].update(); + }); + } + + initLightbox(tabId); }); }); - // Thumbnails container.addEventListener('click', (e) => { if (e.target.closest('.thumbnail')) { const thumbnail = e.target.closest('.thumbnail'); @@ -98,13 +137,4 @@ function initGalleryBlock(blockId) { updateThumbnails(tabId, index); } }); - - const firstTab = container.querySelector('.tab-button.active'); - if (firstTab) { - const tabId = firstTab.getAttribute('data-tab'); - setTimeout(() => { - initSwiper(tabId); - initLightbox(tabId); - }, 100); - } } \ No newline at end of file diff --git a/blocks/gallery-tabs/gallery-tabs.php b/blocks/gallery-tabs/gallery-tabs.php index ea4f985..1a49d96 100644 --- a/blocks/gallery-tabs/gallery-tabs.php +++ b/blocks/gallery-tabs/gallery-tabs.php @@ -1,136 +1,86 @@ [ - 'title' => 'Зона ресепшен', - 'images' => [ - [ - 'src' => 'https://placehold.co/800x600/4a5568/ffffff?text=Ресепшен+1', - 'thumb' => 'https://placehold.co/150x100/4a5568/ffffff?text=Р1', - 'alt' => 'Ресепшен 1' - ], - [ - 'src' => 'https://placehold.co/800x600/2d3748/ffffff?text=Ресепшен+2', - 'thumb' => 'https://placehold.co/150x100/2d3748/ffffff?text=Р2', - 'alt' => 'Ресепшен 2' - ], - [ - 'src' => 'https://placehold.co/800x600/1a202c/ffffff?text=Ресепшен+3', - 'thumb' => 'https://placehold.co/150x100/1a202c/ffffff?text=Р3', - 'alt' => 'Ресепшен 3' - ], - [ - 'src' => 'https://placehold.co/800x600/718096/ffffff?text=Ресепшен+4', - 'thumb' => 'https://placehold.co/150x100/718096/ffffff?text=Р4', - 'alt' => 'Ресепшен 4' - ] - ] - ], - 'gym' => [ - 'title' => 'Зона тренажерного зала', - 'images' => [ - [ - 'src' => 'https://placehold.co/800x600/dc2626/ffffff?text=Тренажёрный+1', - 'thumb' => 'https://placehold.co/150x100/dc2626/ffffff?text=Т1', - 'alt' => 'Тренажерный зал 1' - ], - [ - 'src' => 'https://placehold.co/800x600/b91c1c/ffffff?text=Тренажёрный+2', - 'thumb' => 'https://placehold.co/150x100/b91c1c/ffffff?text=Т2', - 'alt' => 'Тренажерный зал 2' - ], - [ - 'src' => 'https://placehold.co/800x600/991b1b/ffffff?text=Тренажёрный+3', - 'thumb' => 'https://placehold.co/150x100/991b1b/ffffff?text=Т3', - 'alt' => 'Тренажерный зал 3' - ], - [ - 'src' => 'https://placehold.co/800x600/7f1d1d/ffffff?text=Тренажёрный+4', - 'thumb' => 'https://placehold.co/150x100/7f1d1d/ffffff?text=Т4', - 'alt' => 'Тренажерный зал 4' - ], - [ - 'src' => 'https://placehold.co/800x600/ef4444/ffffff?text=Тренажёрный+5', - 'thumb' => 'https://placehold.co/150x100/ef4444/ffffff?text=Т5', - 'alt' => 'Тренажерный зал 5' - ] - ] - ], - 'group' => [ - 'title' => 'Залы для групповых тренировок', - 'images' => [ - [ - 'src' => 'https://placehold.co/800x600/059669/ffffff?text=Групповые+1', - 'thumb' => 'https://placehold.co/150x100/059669/ffffff?text=Г1', - 'alt' => 'Групповые тренировки 1' - ], - [ - 'src' => 'https://placehold.co/800x600/047857/ffffff?text=Групповые+2', - 'thumb' => 'https://placehold.co/150x100/047857/ffffff?text=Г2', - 'alt' => 'Групповые тренировки 2' - ], - [ - 'src' => 'https://placehold.co/800x600/065f46/ffffff?text=Групповые+3', - 'thumb' => 'https://placehold.co/150x100/065f46/ffffff?text=Г3', - 'alt' => 'Групповые тренировки 3' - ] - ] - ] -]; +$id = 'gallery-tabs-' . $block['id']; +if ( ! empty($block['anchor'] ) ) { + $id = $block['anchor']; +} + +$classes = 'block-gallery-tabs'; +if ( ! empty( $block['className'] ) ) { + $classes .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $classes .= ' align' . $block['align']; +} + +$heading = get_field('heading'); +$slider_tabs = get_field('slider_tabs'); -$block_id = 'gallery-' . $block['id']; ?> - \ No newline at end of file diff --git a/blocks/reviews-block/reviews-block.js b/blocks/reviews-block/reviews-block.js index 2449ddc..bbf2e6e 100644 --- a/blocks/reviews-block/reviews-block.js +++ b/blocks/reviews-block/reviews-block.js @@ -12,16 +12,43 @@ function initReviewsBlock(blockId) { const swipers = {}; let lightbox; - function initSwiper(tabId) { - if (swipers[tabId]) { - swipers[tabId].destroy(true, true); - } + function initAllSwipers() { + const tabs = container.querySelectorAll('.tab-button'); - swipers[tabId] = new Swiper(`#${blockId} #swiper-${tabId}`, { - slidesPerView: 3, - spaceBetween: 20, - loop: true, - centeredSlides: true, + tabs.forEach(button => { + const tabId = button.getAttribute('data-tab'); + const tabContent = container.querySelector(`#tab-${tabId}`); + + if (tabContent && tabContent.querySelector('.swiper')) { + const wasHidden = tabContent.classList.contains('hidden'); + if (wasHidden) { + tabContent.style.visibility = 'hidden'; + tabContent.style.position = 'absolute'; + tabContent.classList.remove('hidden'); + tabContent.classList.add('block'); + } + + if (swipers[tabId]) { + swipers[tabId].destroy(true, true); + } + + swipers[tabId] = new Swiper(`#${blockId} #swiper-${tabId}`, { + slidesPerView: 'auto', + spaceBetween: 20, + loop: true, + centeredSlides: true, + observer: true, + observeParents: true, + watchSlidesProgress: true, + }); + + if (wasHidden) { + tabContent.style.visibility = ''; + tabContent.style.position = ''; + tabContent.classList.add('hidden'); + tabContent.classList.remove('block'); + } + } }); } @@ -64,8 +91,14 @@ function initReviewsBlock(blockId) { }); } + initAllSwipers(); + + const activeTab = container.querySelector('.tab-button.active'); + if (activeTab) { + const tabId = activeTab.getAttribute('data-tab'); + initLightbox(tabId); + } - // Табы container.querySelectorAll('.tab-button').forEach(button => { button.addEventListener('click', () => { const tabId = button.getAttribute('data-tab'); @@ -81,24 +114,18 @@ function initReviewsBlock(blockId) { content.classList.remove('block'); content.classList.add('hidden'); }); - container.querySelector(`#tab-${tabId}`).classList.remove('hidden'); - container.querySelector(`#tab-${tabId}`).classList.add('block'); - setTimeout(() => { - initSwiper(tabId); - initLightbox(tabId); - }, 100); + const targetTab = container.querySelector(`#tab-${tabId}`); + targetTab.classList.remove('hidden'); + targetTab.classList.add('block'); + + if (swipers[tabId]) { + requestAnimationFrame(() => { + swipers[tabId].update(); + }); + } + + initLightbox(tabId); }); }); - - - - const firstTab = container.querySelector('.tab-button.active'); - if (firstTab) { - const tabId = firstTab.getAttribute('data-tab'); - setTimeout(() => { - initSwiper(tabId); - initLightbox(tabId); - }, 100); - } } \ No newline at end of file diff --git a/blocks/reviews-block/reviews-block.php b/blocks/reviews-block/reviews-block.php index 63fffab..149cc8f 100644 --- a/blocks/reviews-block/reviews-block.php +++ b/blocks/reviews-block/reviews-block.php @@ -1,136 +1,153 @@ [ - 'title' => 'Отзывы Google', - 'reviews' => [ - [ - 'src' => 'https://placehold.co/800x600/4f46e5/ffffff?text=Отзыв+Google+1', - 'thumb' => 'https://placehold.co/300x200/4f46e5/ffffff?text=G1', - 'alt' => 'Отзыв Google 1' - ], - [ - 'src' => 'https://placehold.co/800x600/7c3aed/ffffff?text=Отзыв+Google+2', - 'thumb' => 'https://placehold.co/300x200/7c3aed/ffffff?text=G2', - 'alt' => 'Отзыв Google 2' - ], - [ - 'src' => 'https://placehold.co/800x600/8b5cf6/ffffff?text=Отзыв+Google+3', - 'thumb' => 'https://placehold.co/300x200/8b5cf6/ffffff?text=G3', - 'alt' => 'Отзыв Google 3' - ], - [ - 'src' => 'https://placehold.co/800x600/a855f7/ffffff?text=Отзыв+Google+4', - 'thumb' => 'https://placehold.co/300x200/a855f7/ffffff?text=G4', - 'alt' => 'Отзыв Google 4' - ] - ] - ], - 'yandex' => [ - 'title' => 'Отзывы Яндекс', - 'reviews' => [ - [ - 'src' => 'https://placehold.co/800x600/f59e0b/ffffff?text=Отзыв+Яндекс+1', - 'thumb' => 'https://placehold.co/300x200/f59e0b/ffffff?text=Я1', - 'alt' => 'Отзыв Яндекс 1' - ], - [ - 'src' => 'https://placehold.co/800x600/d97706/ffffff?text=Отзыв+Яндекс+2', - 'thumb' => 'https://placehold.co/300x200/d97706/ffffff?text=Я2', - 'alt' => 'Отзыв Яндекс 2' - ], - [ - 'src' => 'https://placehold.co/800x600/b45309/ffffff?text=Отзыв+Яндекс+3', - 'thumb' => 'https://placehold.co/300x200/b45309/ffffff?text=Я3', - 'alt' => 'Отзыв Яндекс 3' - ] - ] - ], - 'video' => [ - 'title' => 'Видеоотзывы', - 'reviews' => [ - [ - 'src' => '/path/to/video1.mp4', // Путь к видеофайлу - 'thumb' => 'https://placehold.co/300x200/b45309/ffffff?text=В1', - 'alt' => 'Видеоотзыв 1', - 'type' => 'video', - 'video_type' => 'mp4' // Тип видео - ], - [ - 'src' => '/path/to/video2.webm', - 'thumb' => 'https://placehold.co/300x200/b45309/ffffff?text=В2', - 'alt' => 'Видеоотзыв 2', - 'type' => 'video', - 'video_type' => 'webm' - ], - [ - 'src' => '/path/to/video3.mov', - 'thumb' => 'https://placehold.co/300x200/b45309/ffffff?text=В3', - 'alt' => 'Видеоотзыв 3', - 'type' => 'video', - 'video_type' => 'mov' - ] - ] - ] -]; +$id = 'reviews-block-' . $block['id']; +if ( ! empty($block['anchor'] ) ) { + $id = $block['anchor']; +} -$block_id = 'reviews-' . $block['id']; +$classes = 'block-reviews-block'; +if ( ! empty( $block['className'] ) ) { + $classes .= ' ' . $block['className']; +} +if ( ! empty( $block['align'] ) ) { + $classes .= ' align' . $block['align']; +} + +$heading = get_field('heading'); +$slider_tabs = get_field('slider_tabs'); +$slider_video_reviews = get_field('slider_video_reviews'); +$stars = get_field('stars'); ?> -
+
-

Отзывы клиентов

+ +

+ - -
- $tab): ?> - + + + + + + - +
-
- - $tab_data): ?> -
- - -
-
- - - +
+
+ + + + + + + + + + + + + + + +
+ Оценок:   +
+
- +
+ + + $tab) : ?> +
+ + +
+
+ +
+ + <?php echo esc_attr($image['alt']); ?> + +
+ +
+
+ +
+ + + + + +
\ No newline at end of file diff --git a/blocks/tiles-block/tiles-block.php b/blocks/tiles-block/tiles-block.php new file mode 100644 index 0000000..f4bd5d9 --- /dev/null +++ b/blocks/tiles-block/tiles-block.php @@ -0,0 +1,62 @@ + + +
+
+ + +

+ +

+ + + +
+ +
+ + +
+ <?php echo esc_attr($tile['image']['alt']); ?> +
+ + + +

+ +

+ + + +
+ +
+ + +
+ +
+ + +
+
\ No newline at end of file diff --git a/footer.php b/footer.php index 92172c1..7185f02 100644 --- a/footer.php +++ b/footer.php @@ -1,7 +1,7 @@ -
+
Время работы: @@ -25,4 +25,3 @@
-/ \ No newline at end of file diff --git a/functions/blocks.php b/functions/blocks.php index 6c33df8..c2c5715 100644 --- a/functions/blocks.php +++ b/functions/blocks.php @@ -73,6 +73,21 @@ function register_acf_blocks() { ), )); + acf_register_block_type(array( + 'name' => 'tiles-block', + 'title' => __('Блок с плитками'), + 'description' => __('Блок с плитками'), + 'render_template' => 'template-parts/la-components/blocks/tiles-block/tiles-block.php', + 'category' => 'theme-blocks', + 'icon' => 'grid-view', + 'keywords' => array('плитки', 'карточки', 'tiles', 'cards'), + 'supports' => array( + 'align' => array('wide', 'full'), + 'anchor' => true, + 'customClassName' => true, + ), + )); + acf_register_block_type(array( 'name' => 'reviews-block', 'title' => __('Блок с отзывами'),