enqueue_block_editor_assetsaction-hookWC 5.0.0

This is a WordPress - enqueue_block_editor_assets hook. The plugin just uses it.

Allows you to add styles or scripts to the block editor (Gutenberg) on the post editing screen.

Fires after block styles/scripts have been enqueued for output on the post editing screen.

wp_enqueue_script and wp_enqueue_style can be used in the callback function.

The hook must be used before the admin_enqueue_scripts event.

Use enqueue_block_assets when scripts and styles for blocks must be loaded on the front end, in the admin area, and inside the block editor iframe at the same time.

Usage

add_action( 'enqueue_block_editor_assets', 'wp_kama_enqueue_block_editor_assets_action' );

/**
 * Function for `enqueue_block_editor_assets` action-hook.
 * 
 * @return void
 */
function wp_kama_enqueue_block_editor_assets_action(){
	// action...
}

Examples

#1 Enqueue styles and scripts on the post editing screen (for Gutenberg)

add_action( 'enqueue_block_editor_assets', 'example_block_editor_scripts' );

function example_block_editor_scripts(){
	wp_enqueue_script( 'example', plugins_url( 'example.js', __FILE__ ), ['wp-blocks'], '', true );
	wp_enqueue_style( 'example', plugins_url( 'example.css', __FILE__ ) );
}

Where the hook is called

Assets_Manager::enqueue_admin_styles()
enqueue_block_editor_assets

Where the hook is used in WooCommerce

woocommerce/src/Blocks/BlockTypes/AbstractBlock.php 140
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_assets' ] );