Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Editor: add new parameter to hook when enqueuing block assets
This would allow one to use the enqueue_block_editor_assets hook just like we use the admin_enqueue_scripts hook today: we can easily add conditionals and decide in which editor (post, widget, site) we want a block asset to be enqueued.
  • Loading branch information
jeherve committed Jan 5, 2023
commit 6ee55485c4c9ad7e05e59cec083f67b617e39742
8 changes: 6 additions & 2 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
}

/**
* @global string $hook_suffix
* @global string $post_type
* @global WP_Post_Type $post_type_object
* @global WP_Post $post Global post object.
* @global string $title
* @global array $wp_meta_boxes
*/
global $post_type, $post_type_object, $post, $title, $wp_meta_boxes;
global $hook_suffix, $post_type, $post_type_object, $post, $title, $wp_meta_boxes;

$block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) );

Expand Down Expand Up @@ -268,8 +269,11 @@ static function( $classes ) {
* `wp_enqueue_style` to add your functionality to the block editor.
*
* @since 5.0.0
* @since 6.2.0 Added the $hook_suffix parameter.
*
* @param string $hook_suffix The current admin page.
*/
do_action( 'enqueue_block_editor_assets' );
do_action( 'enqueue_block_editor_assets', $hook_suffix );

// In order to duplicate classic meta box behavior, we need to run the classic meta box actions.
require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
Expand Down