From 6d42a2110346a19a9874a3121e40b1e472b2cbd4 Mon Sep 17 00:00:00 2001 From: gziolo Date: Wed, 31 Mar 2021 05:52:10 +0000 Subject: [PATCH] Editor: Enqueue assets for format library for the block editor Ensures that `wp-format-library` assets are always loaded for the block editor. Otherwise, they have to be loaded individually for every screen that needs it. It's similar to how `wp-block-directory` assets are handled. Props ellatrix. See #52920. Built from https://develop.svn.wordpress.org/trunk@50620 git-svn-id: http://core.svn.wordpress.org/trunk@50233 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-blocks.php | 2 -- wp-includes/default-filters.php | 1 + wp-includes/script-loader.php | 10 ++++++++++ wp-includes/version.php | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-admin/edit-form-blocks.php b/wp-admin/edit-form-blocks.php index 5ce8fba395..3a61483be0 100644 --- a/wp-admin/edit-form-blocks.php +++ b/wp-admin/edit-form-blocks.php @@ -39,7 +39,6 @@ add_filter( 'screen_options_show_screen', '__return_false' ); wp_enqueue_script( 'heartbeat' ); wp_enqueue_script( 'wp-edit-post' ); -wp_enqueue_script( 'wp-format-library' ); $rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; @@ -398,7 +397,6 @@ wp_enqueue_editor(); * Styles */ wp_enqueue_style( 'wp-edit-post' ); -wp_enqueue_style( 'wp-format-library' ); /** * Fires after block assets have been enqueued for the editing interface. diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 23bb302359..29a77af00d 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -538,6 +538,7 @@ add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); 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_editor_assets', 'wp_enqueue_editor_format_library_assets' ); add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' ); add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index ad38dae7b6..62bbda090c 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -2323,6 +2323,16 @@ function enqueue_editor_block_styles_assets() { wp_enqueue_script( 'wp-block-styles' ); } +/** + * Enqueues the assets required for the format library within the block editor. + * + * @since 5.8.0 + */ +function wp_enqueue_editor_format_library_assets() { + wp_enqueue_script( 'wp-format-library' ); + wp_enqueue_style( 'wp-format-library' ); +} + /** * Enqueues the assets required for the block directory within the block editor. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 9a31d17861..7d9e8fec06 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-50619'; +$wp_version = '5.8-alpha-50620'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.