Files
Fakel-Gym/template-parts/la-components/functions/blocks.php
GP_DEV 21562852ca full
2025-07-08 14:21:19 +03:00

362 lines
16 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
function register_acf_blocks() {
if (function_exists('acf_register_block_type')) {
acf_register_block_type(array(
'name' => 'hero-block',
'title' => __('Hero Block'),
'description' => __('Заглавный блок со слайдером'),
'render_template' => 'template-parts/la-components/blocks/hero-block/hero-block.php',
'category' => 'theme-blocks',
'icon' => 'cover-image',
'keywords' => array('hero', 'banner', 'заголовок', 'слайдер'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_script(
'hero-block-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/hero-block/hero-block.js',
['jquery'],
'1.0.0',
true
);
wp_enqueue_style(
'hero-block-css',
get_template_directory_uri() . '/template-parts/la-components/blocks/hero-block/hero-block.css',
[],
'1.0.0'
);
}
));
acf_register_block_type(array(
'name' => 'contacts-block',
'title' => __('Блок с контактами'),
'description' => __('Блок с контактами>'),
'render_template' => 'template-parts/la-components/blocks/contacts-block/contacts-block.php',
'category' => 'theme-blocks',
'icon' => 'cover-image',
'keywords' => array('контакты', 'contacts', 'адрес'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_script(
'contacts-block-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/contacts-block/contacts-block.js',
['jquery'],
'1.0.0',
true
);
}
));
acf_register_block_type(array(
'name' => 'club-cards-block',
'title' => __('Блок с клубными картами'),
'description' => __('Блок с клубными картами для текущего зала'),
'render_template' => 'template-parts/la-components/blocks/club-cards-block/club-cards-block.php',
'category' => 'theme-blocks',
'icon' => 'id-alt',
'keywords' => array('карты', 'клуб', 'cards', 'club'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
));
acf_register_block_type(array(
'name' => 'trainer-block',
'title' => __('Блок с тренерами'),
'description' => __('Блок с тренерами для текущего зала'),
'render_template' => 'template-parts/la-components/blocks/trainers-block/trainer-block.php',
'category' => 'theme-blocks',
'icon' => 'id-alt',
'keywords' => array('тренеры', 'тренер', 'trainers'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
));
acf_register_block_type(array(
'name' => 'training-block',
'title' => __('Блок с тренировками'),
'description' => __('Блок с тренировками для текущего зала'),
'render_template' => 'template-parts/la-components/blocks/training-block/training-block.php',
'category' => 'theme-blocks',
'icon' => 'id-alt',
'keywords' => array('тренировки', 'тренеровка', 'trainings'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
));
acf_register_block_type(array(
'name' => 'form-block',
'title' => __('Блок формы'),
'description' => __('Блок формы обратной связи'),
'render_template' => 'template-parts/la-components/blocks/form-block/form-block.php',
'category' => 'theme-blocks',
'icon' => 'id-alt',
'keywords' => array('форма', 'форма записи', 'имя', 'телефон'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_style(
'form-block-css',
get_template_directory_uri() . '/template-parts/la-components/blocks/form-block/form-block.css',
[],
'1.0.0'
);
wp_enqueue_script(
'form-block-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/form-block/form-block.js',
['jquery'],
'1.0.0',
true
);
}
));
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' => 'line-block',
'title' => __('Блок преимуществ в линию'),
'description' => __('Блок преимуществ в линию'),
'render_template' => 'template-parts/la-components/blocks/line-block/line-block.php',
'category' => 'theme-blocks',
'icon' => 'grid-view',
'keywords' => array('плитки', 'преимущества', 'line', 'линия'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
));
acf_register_block_type(array(
'name' => 'masonry-tiles-block',
'title' => __('Блок с высокой первой плиткой'),
'description' => __('Блок с высокой первой плиткой'),
'render_template' => 'template-parts/la-components/blocks/masonry-tiles-1/masonry-tiles-1.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' => 'masonry-wide-tiles-block',
'title' => __('Блок с широкой последней плиткой'),
'description' => __('Блок с широкой последней плиткой'),
'render_template' => 'template-parts/la-components/blocks/masonry-tiles-2/masonry-tiles-2.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' => 'advantages-block',
'title' => __('Блок преимуществ'),
'description' => __('Блок с преимуществами'),
'render_template' => 'template-parts/la-components/blocks/advantages-block/advantages-block.php',
'category' => 'theme-blocks',
'icon' => 'grid-view',
'keywords' => array('преимущества', 'карточки', 'advantages', 'преимущество'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
));
acf_register_block_type(array(
'name' => 'reviews-block',
'title' => __('Блок с отзывами'),
'description' => __('Блок с отзывами'),
'render_template' => 'template-parts/la-components/blocks/reviews-block/reviews-block.php',
'category' => 'theme-blocks',
'icon' => 'cover-image',
'keywords' => array('отзывы', 'видеоотзывы', 'reviews'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_script(
'reviews-block-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/reviews-block/reviews-block.js',
['jquery'],
'1.0.0',
true
);
wp_enqueue_style(
'glightbox-css',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/css/glightbox.min.css',
[],
'3.2.0'
);
wp_enqueue_script(
'glightbox-js',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/js/glightbox.min.js',
[],
'3.2.0',
true
);
wp_enqueue_style(
'reviews-block-css',
get_template_directory_uri() . '/template-parts/la-components/blocks/reviews-block/reviews-block.css',
[],
'1.0.0'
);
}
));
acf_register_block_type(array(
'name' => 'gallery-tabs',
'title' => __('Галерея с табами'),
'description' => __('Галерея с табами, слайдером и лайтбоксом'),
'render_template' => 'template-parts/la-components/blocks/gallery-tabs/gallery-tabs.php',
'category' => 'theme-blocks',
'icon' => 'images-alt2',
'keywords' => array('gallery', 'tabs', 'slider', 'галерея', 'слайдер'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_style(
'glightbox-css',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/css/glightbox.min.css',
[],
'3.2.0'
);
wp_enqueue_script(
'glightbox-js',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/js/glightbox.min.js',
[],
'3.2.0',
true
);
wp_enqueue_style(
'gallery-block-css',
get_template_directory_uri() . '/template-parts/la-components/blocks/gallery-tabs/gallery-tabs.css',
[],
'1.0.0'
);
wp_enqueue_script(
'gallery-tabs-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/gallery-tabs/gallery-tabs.js',
['swiper-js', 'glightbox-js'],
'1.0.0',
true
);
}
));
acf_register_block_type(array(
'name' => 'simple-gallery',
'title' => __('Галерея с текстом'),
'description' => __('Галерея с текстом'),
'render_template' => 'template-parts/la-components/blocks/simple-gallery/simple-gallery.php',
'category' => 'theme-blocks',
'icon' => 'images-alt2',
'keywords' => array('gallery', 'tabs', 'slider', 'галерея', 'слайдер'),
'supports' => array(
'align' => array('wide', 'full'),
'anchor' => true,
'customClassName' => true,
),
'enqueue_assets' => function() {
wp_enqueue_style(
'glightbox-css',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/css/glightbox.min.css',
[],
'3.2.0'
);
wp_enqueue_script(
'glightbox-js',
'https://cdnjs.cloudflare.com/ajax/libs/glightbox/3.2.0/js/glightbox.min.js',
[],
'3.2.0',
true
);
wp_enqueue_script(
'simple-gallery-js',
get_template_directory_uri() . '/template-parts/la-components/blocks/simple-gallery/simple-gallery.js',
['swiper-js', 'glightbox-js'],
'1.0.0',
true
);
}
));
}
}
add_action('acf/init', 'register_acf_blocks');
function register_custom_block_category($categories, $post) {
return array_merge(
$categories,
array(
array(
'slug' => 'theme-blocks',
'title' => __('Блоки темы'),
'icon' => 'admin-customizer',
),
)
);
}
add_filter('block_categories_all', 'register_custom_block_category', 10, 2);