migrating acf blocks to plugin

This commit is contained in:
Antoine M 2023-12-20 10:02:40 +01:00
parent 576f542ab1
commit 691444fa51

View File

@ -21,6 +21,16 @@ function homegrade_add_block_categories($categories)
'icon' => 'heart', 'icon' => 'heart',
], ],
[
'slug' => 'homegrade-pages',
'title' => 'Homegrade Specific Page Blocks ',
'icon' => 'admin-page',
],
[
'slug' => 'homegrade-page-home',
'title' => 'Homegrade Blocks | Page d\'accueil',
'icon' => 'admin-page',
],
], ],
$categories $categories
); );
@ -83,6 +93,12 @@ function create_block_multiblocks_block_init()
// ACF // ACF
register_block_type(__DIR__ . '/acf-blocks/google-map'); register_block_type(__DIR__ . '/acf-blocks/google-map');
register_block_type(__DIR__ . '/acf-blocks/sitemap'); register_block_type(__DIR__ . '/acf-blocks/sitemap');
register_block_type(__DIR__ . '/acf-blocks/home/home-header');
register_block_type(__DIR__ . '/acf-blocks/home/latest-news');
register_block_type(__DIR__ . '/acf-blocks/home/show-thematiques');
register_block_type(__DIR__ . '/acf-blocks/home/aides-financieres');
register_block_type(__DIR__ . '/acf-blocks/home/demarches-administratives');
register_block_type(__DIR__ . '/acf-blocks/home/questions-frequentes');
} }
add_action('init', 'create_block_multiblocks_block_init'); add_action('init', 'create_block_multiblocks_block_init');
@ -114,7 +130,7 @@ add_action('enqueue_block_editor_assets', 'homegrade_blocks_enqueue_editor_asset
/* ------------------------------------- /* -------------------------------------
ENQUEUE SCRIPTS AND STYLES FOR FRONT ENQUEUE SCRIPTS AND STYLES FOR FRONT
-------------------------------------*/ -------------------------------------*/
function blocks_course_plugin_enqueue_assets() function homegrade_blocks_plugin_enqueue_assets()
{ {
$asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php'); $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php');
wp_enqueue_script('homegrade-blocks-tooltipjs', plugin_dir_url(__FILE__) . 'build/tooltipFront.js'); wp_enqueue_script('homegrade-blocks-tooltipjs', plugin_dir_url(__FILE__) . 'build/tooltipFront.js');
@ -123,24 +139,33 @@ function blocks_course_plugin_enqueue_assets()
// #PASSING TRANSLATIONS // #PASSING TRANSLATIONS
wp_register_script('homegrade-blocks-brochurejs', plugin_dir_url(__FILE__) . 'src/format-types/brochure/brochure-front.js'); wp_register_script('homegrade-blocks-brochurejs', plugin_dir_url(__FILE__) . 'src/format-types/brochure/brochure-front.js');
$translation_array_brochure_link = array( $translation_array_brochure_link = array(
'download' => __('Télécharger', 'homegrade-blocks'), 'download' => __('Télécharger', 'homegrade-blocks'),
); );
wp_localize_script('homegrade-blocks-brochurejs', 'textTranslationsBrochureLink', $translation_array_brochure_link); wp_localize_script('homegrade-blocks-brochurejs', 'textTranslationsBrochureLink', $translation_array_brochure_link);
wp_localize_script('homegrade-blocks-brochurejs', 'img_path_datas', array(
'downloadIconPath' => plugin_dir_url(__FILE__) . '/src/img/icon_brochure_download.svg'
));
wp_enqueue_script('homegrade-blocks-brochurejs'); wp_enqueue_script('homegrade-blocks-brochurejs');
wp_enqueue_style('homegrade-blocks-brochurecss', plugin_dir_url(__FILE__) . 'src/format-types/brochure/brochure.css'); wp_enqueue_style('homegrade-blocks-brochurecss', plugin_dir_url(__FILE__) . 'src/format-types/brochure/brochure.css');
$theme = wp_get_theme();
wp_localize_script('homegrade-blocks-brochurejs', 'img_path_datas', array( // SHOW THEMATIQUE
'downloadIconPath' => plugin_dir_url(__FILE__) . '/src/img/icon_brochure_download.svg' wp_register_script('showthematiquejs', plugin_dir_url(__FILE__) . '/acf-blocks/home/show-thematiques/show-thematiques.js', array('swiperjs'), $theme->get('Version'));
)); $translation_array = array(
'previousSlide' => __('Carte précédente', 'homegrade-theme__texte-fonctionnel'),
'nextSlide' => __('Carte suivante', 'homegrade-theme__texte-fonctionnel'),
'slideLabel' => __('Carte Thématique', 'homegrade-theme__texte-fonctionnel'),
);
wp_localize_script('showthematiquejs', 'textTranslations', $translation_array);
wp_enqueue_script('showthematiquejs');
// write_log(plugin_dir_path(__FILE__) . '/acf-blocks/home/show-thematiques/show-thematiques.js');
// write_log(__DIR__ . '/acf-blocks/home/show-thematiques/show-thematiques.js');
} }
add_action('wp_enqueue_scripts', 'blocks_course_plugin_enqueue_assets'); add_action('wp_enqueue_scripts', 'homegrade_blocks_plugin_enqueue_assets');
function add_type_attribute($tag, $handle, $src) function add_type_attribute($tag, $handle, $src)
@ -251,15 +276,12 @@ function enqueue_block_editor_adjustments()
// ###### PHP INTERNATIONNALISATION // ###### PHP INTERNATIONNALISATION
// load_plugin_textdomain('homegrade-blocks', false, plugin_basename(dirname(__FILE_)) . '/languages');
add_action('init', 'wpdocs_load_textdomain'); add_action('init', 'wpdocs_load_textdomain');
function wpdocs_load_textdomain() function wpdocs_load_textdomain()
{ {
load_plugin_textdomain('homegrade-blocks', false, dirname(plugin_basename(__FILE__)) . '/languages'); load_plugin_textdomain('homegrade-blocks', false, dirname(plugin_basename(__FILE__)) . '/languages');
// write_log(dirname(plugin_basename(__FILE__)) . '/languages');
// load_plugin_textdomain('wpdocs_textdomain', false,);
} }