You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

173 lines
7.4 KiB

<?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' => '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' => __('Блок с отзывами'),
'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);