homegrade_theme_production/includes/blocks.php
2023-05-10 11:42:44 +02:00

51 lines
1.1 KiB
PHP
Executable File

<?php
// ##### Blocks Category 🡒 Déclaration de la catégorie de blocks custom
function client_add_block_categories($categories)
{
return array_merge(
[
[
'slug' => 'homegrade-blocks',
'title' => 'Homegrade Generic Blocks ',
'icon' => 'heart',
],
],
$categories,
[
[
'slug' => 'homegrade-pages',
'title' => 'Homegrade Specific Page Blocks ',
'icon' => 'admin-page',
],
],
);
}
add_action('block_categories_all', 'client_add_block_categories', 10, 2);
function mywp_register_acf_blocks()
{
// Check availability of block editor
if (!function_exists('register_block_type')) {
return;
}
register_block_type(get_template_directory() . '/template-blocks/home/home-header');
register_block_type(get_template_directory() . '/template-blocks/home/latest-news');
}
add_action('init', 'mywp_register_acf_blocks');
// ##### Blocks style 🡒 Re-enqueue d'un style dans l'éditeur
// function block_newsfeed_add_editor_styles() {
// add_editor_style( get_stylesheet_directory_uri() . '/template-parts/blocks/editor.css' );
// }
// add_action( 'admin_init', 'block_newsfeed_add_editor_styles' );