Files
Fakel-Gym/template-parts/la-components/functions/blocks.php
GP_DEV d2bec21994 Add 'template-parts/la-components/' from commit '54eb8e266ffe2f57afb812d18c8f78030562f62a'
git-subtree-dir: template-parts/la-components
git-subtree-mainline: 7c5a7f373a
git-subtree-split: 54eb8e266f
2025-06-01 12:42:07 +03:00

158 lines
6.6 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' => '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
);
}
));
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_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
);
}
));
}
}
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);