init
This commit is contained in:
158
functions/blocks.php
Normal file
158
functions/blocks.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?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);
|
||||
58
functions/modals.php
Normal file
58
functions/modals.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
function enqueue_theme_scripts() {
|
||||
wp_enqueue_script(
|
||||
'modals-js',
|
||||
get_template_directory_uri() . '/template-parts/la-components/js/modals.js',
|
||||
array('jquery'),
|
||||
'1.0.0',
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'enqueue_theme_scripts');
|
||||
|
||||
// Вывод всех модалок в футере
|
||||
function modal_system_container() {
|
||||
// Получаем список всех модалок
|
||||
$modals_dir = get_template_directory() . '/template-parts/la-components/modals/';
|
||||
$modals = array();
|
||||
|
||||
if (is_dir($modals_dir)) {
|
||||
$files = scandir($modals_dir);
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/^modal-(.+)\.php$/', $file, $matches)) {
|
||||
$modals[] = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// общий контейнер
|
||||
?>
|
||||
<div id="modal-overlay" class="fixed inset-0 bg-[rgba(0,0,0,0.5)] backdrop-blur-sm z-50 flex items-center justify-center p-4 opacity-0 invisible transition-all duration-300">
|
||||
<div class="bg-white rounded-lg shadow-2xl max-w-2xl w-full max-h-[90vh] relative transform scale-90 transition-transform duration-300 overflow-hidden">
|
||||
|
||||
<button id="modal-close" class="absolute top-4 right-4 z-10 w-8 h-8 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors text-gray-500 hover:text-gray-700">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- Контейнер для контента модалок -->
|
||||
<div id="modal-content" class="overflow-y-auto max-h-[90vh]">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="modal-templates" class="hidden">
|
||||
<?php foreach ($modals as $modal_name): ?>
|
||||
<div id="modal-template-<?php echo esc_attr($modal_name); ?>" class="modal-template">
|
||||
<?php get_template_part('template-parts/la-components/modals/modal', $modal_name); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action('wp_footer', 'modal_system_container');
|
||||
?>
|
||||
Reference in New Issue
Block a user