Hi everyone,
I’m lost with a syntax matter, I hope someone could clarify this.
I’m creating csutom ACF blocks for a website, everything fine but I don’t understand why I must use a different syntax to access my block template (plugin_dir_path) vs my block assets (plugin_dir_url) even if they are placed in the same folder?!
Thanks
acf_register_block_type(array(
'name' => 'lauto_video_player',
'title' => __('Lautobus Vidéo Player'),
'description' => __('Bloc vidéo pour Youtube et Viméo.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'templates/blocks/block-acf-plyr/block-acf-plyr.php',
'enqueue_assets' => function(){
wp_enqueue_style( 'plyr-style', plugin_dir_url( __FILE__ ) . 'templates/blocks/block-acf-plyr/plyr.css' );
wp_enqueue_script( 'plyr-script', plugin_dir_url( __FILE__ ) . 'templates/blocks/block-acf-plyr/plyr.min.js' );
wp_enqueue_script( 'acf-plyr-block-script', plugin_dir_url( __FILE__ ) . 'templates/blocks/block-acf-plyr/block-acf-plyr.js', array('jquery'), '', true );
},
'category' => 'formatting',
'icon' => 'video-alt3',
'keywords' => array( 'video', 'youtube', 'vimeo' ),
));
The difference is the styles are being enqueued for display on the frontend.
This is the equivalent difference to get_stylesheet_directory
and get_stylesheet_directory_uri
. One is executing a file and the other is displaying a path to a file.