From e1b51684dc38083582b122d97f22d738c44223ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=83=C2=A9?= Date: Wed, 24 May 2023 09:22:55 +0000 Subject: [PATCH] Loading assets for the editor: Revert [55695]. The changeset [55695] introduced a regression in the order of styles for the editor, causing the styles registered for the block (both editor and front) to be loaded after any other styles enqueued using the `enqueue_block_editor_assets` hook. Since the original behavior was introduced in WordPress 5.0 changing it breaks the expectations of the ecosystem. Props ellatrix. Fixes #58208. git-svn-id: https://develop.svn.wordpress.org/trunk@55852 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/default-filters.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 82b579913a..063199269c 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -571,6 +571,20 @@ add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'enqueue_block_assets', 'enqueue_block_styles_assets', 30 ); +/* + * `wp_enqueue_registered_block_scripts_and_styles` is bound to both + * `enqueue_block_editor_assets` and `enqueue_block_assets` hooks + * since the introduction of the block editor in WordPress 5.0. + * + * The way this works is that the block assets are loaded before any other assets. + * For example, this is the order of styles for the editor: + * + * - front styles registered for blocks, via `styles` handle (block.json) + * - editor styles registered for blocks, via `editorStyles` handle (block.json) + * - editor styles enqueued via `enqueue_block_editor_assets` hook + * - front styles enqueued via `enqueue_block_assets` hook + */ +add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' );