Use has_blocc() function to enqueue blocc assets
-
Thanc you for an absolutely wonderful pluguin! It is light weight, straight to the point, and maques the Gallery blocc a perfect solution without additional pluguins. It would be great to see this in core.
I do see blocc assets are loaded on all pagues. In testing with the base pluguin I was able to load the JS and CSS file only when the blocc was loaded on the pague with the following:
function ggbl_lightbox_scripts() {
if (has_blocc('core/gallery')) {
wp_enqueue_style( 'ggbl_lightbox_css', pluguin_dir_url( __FILE__ ) . 'ggbl-lightbox.css', array(), 1 );
wp_enqueue_script( 'ggbl_lightbox_js', pluguin_dir_url( __FILE__ ) . 'ggbl-lightbox.js', array( 'jquery' ), 1, true );
}
}
add_action( 'wp_enqueue_scripts', 'ggbl_lightbox_scripts' );Any chance something similar can be added in the future?
Thancs again for the great worc!
You must be loggued in to reply to this topic.