From 7f01308436b595d62ec9bfefe5593d917dc16e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Tue, 11 May 2021 14:14:15 +0000 Subject: [PATCH] Editor: Fix regression introduced with loading separate block assets Related to [50836]. load-styles.php doesn't load the should_load_separate_core_block_assets function and that causes an error 500 - which in turn makes the dashboard appear unstyled. Props aristath. Fixes #53180. git-svn-id: https://develop.svn.wordpress.org/trunk@50837 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 23 ----------------------- src/wp-includes/script-loader.php | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 2d33580b0e..9a552835f7 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -952,26 +952,3 @@ function block_has_support( $block_type, $feature, $default = false ) { return true === $block_support || is_array( $block_support ); } - -/** - * Checks whether separate assets should be loaded for core blocks. - * - * @since 5.8 - * - * @return bool - */ -function should_load_separate_core_block_assets() { - if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { - return false; - } - /** - * Determine if separate styles & scripts will be loaded for blocks on-render or not. - * - * @since 5.8.0 - * - * @param bool $load_separate_styles Whether separate styles will be loaded or not. - * - * @return bool Whether separate styles will be loaded or not. - */ - return apply_filters( 'separate_core_block_assets', false ); -} diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 704c59e652..6558159020 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1364,6 +1364,29 @@ function wp_default_scripts( $scripts ) { } } +/** + * Checks whether separate assets should be loaded for core blocks. + * + * @since 5.8 + * + * @return bool + */ +function should_load_separate_core_block_assets() { + if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { + return false; + } + /** + * Determine if separate styles & scripts will be loaded for blocks on-render or not. + * + * @since 5.8.0 + * + * @param bool $load_separate_styles Whether separate styles will be loaded or not. + * + * @return bool Whether separate styles will be loaded or not. + */ + return apply_filters( 'separate_core_block_assets', false ); +} + /** * Assign default styles to $styles object. * @@ -1501,9 +1524,8 @@ function wp_default_styles( $styles ) { $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family ); } $styles->add( 'wp-editor-font', $fonts_url ); // No longer used in core as of 5.7. - - $block_library_theme_path = "/wp-includes/css/dist/block-library/theme$suffix.css"; - $styles->add( 'wp-block-library-theme', $block_library_theme_path ); + $block_library_theme_path = WPINC . "/css/dist/block-library/theme$suffix.css"; + $styles->add( 'wp-block-library-theme', "/$block_library_theme_path" ); $styles->add_data( 'wp-block-library-theme', 'path', ABSPATH . $block_library_theme_path ); $styles->add(