From 691444fa5119c0cc247c2f8c4909634e93314ae1 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 20 Dec 2023 10:02:40 +0100 Subject: [PATCH] migrating acf blocks to plugin --- homegrade-blocks.php | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/homegrade-blocks.php b/homegrade-blocks.php index 5933587..fe16449 100644 --- a/homegrade-blocks.php +++ b/homegrade-blocks.php @@ -21,6 +21,16 @@ function homegrade_add_block_categories($categories) '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 ); @@ -83,6 +93,12 @@ function create_block_multiblocks_block_init() // ACF register_block_type(__DIR__ . '/acf-blocks/google-map'); 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'); @@ -114,7 +130,7 @@ add_action('enqueue_block_editor_assets', 'homegrade_blocks_enqueue_editor_asset /* ------------------------------------- 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'); 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 wp_register_script('homegrade-blocks-brochurejs', plugin_dir_url(__FILE__) . 'src/format-types/brochure/brochure-front.js'); - $translation_array_brochure_link = array( 'download' => __('Télécharger', 'homegrade-blocks'), ); 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_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( - 'downloadIconPath' => plugin_dir_url(__FILE__) . '/src/img/icon_brochure_download.svg' - )); + // SHOW THEMATIQUE + 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) @@ -251,15 +276,12 @@ function enqueue_block_editor_adjustments() // ###### PHP INTERNATIONNALISATION -// load_plugin_textdomain('homegrade-blocks', false, plugin_basename(dirname(__FILE_)) . '/languages'); add_action('init', 'wpdocs_load_textdomain'); function wpdocs_load_textdomain() { load_plugin_textdomain('homegrade-blocks', false, dirname(plugin_basename(__FILE__)) . '/languages'); - // write_log(dirname(plugin_basename(__FILE__)) . '/languages'); - // load_plugin_textdomain('wpdocs_textdomain', false,); }