From d9f169a02aa2aff6731537d5905c7af9ec27ca99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Mon, 17 May 2021 14:26:53 +0000 Subject: [PATCH] Editor: Rename `should_load_separate_core_block_assets` for consistency Changes introduced: - The `wp_should_load_separate_core_block_assets` function. - The `should_load_separate_core_block_assets` filter. Props hellofromTonya, SergeyBiryukov. Fixes #50328. git-svn-id: https://develop.svn.wordpress.org/trunk@50919 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 2 +- src/wp-includes/script-loader.php | 8 ++++---- tests/phpunit/tests/dependencies/styles.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 9a552835f7..e9dcdfbf7c 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -158,7 +158,7 @@ function register_block_style_handle( $metadata, $field_name ) { return false; } $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC ); - if ( $is_core_block && ! should_load_separate_core_block_assets() ) { + if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { return false; } diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 515622825a..16a5f07d09 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1572,7 +1572,7 @@ function wp_default_styles( $styles ) { $handle = 'wp-' . $package; $path = "/wp-includes/css/dist/$package/style$suffix.css"; - if ( 'block-library' === $package && should_load_separate_core_block_assets() ) { + if ( 'block-library' === $package && wp_should_load_separate_core_block_assets() ) { $path = "/wp-includes/css/dist/$package/common$suffix.css"; } $styles->add( $handle, $path, $dependencies ); @@ -2278,7 +2278,7 @@ function wp_should_load_block_editor_scripts_and_styles() { * * @return bool Whether separate assets will be loaded or not. */ -function should_load_separate_core_block_assets() { +function wp_should_load_separate_core_block_assets() { if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { return false; } @@ -2292,7 +2292,7 @@ function should_load_separate_core_block_assets() { * @param bool $load_separate_assets Whether separate assets will be loaded or not. * Default false. */ - return apply_filters( 'separate_core_block_assets', false ); + return apply_filters( 'should_load_separate_core_block_assets', false ); } /** @@ -2306,7 +2306,7 @@ function should_load_separate_core_block_assets() { function wp_enqueue_registered_block_scripts_and_styles() { global $current_screen; - if ( should_load_separate_core_block_assets() ) { + if ( wp_should_load_separate_core_block_assets() ) { return; } diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index c3b04bbdac..444430719a 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -429,7 +429,7 @@ CSS; * @covers ::wp_default_styles */ function test_block_styles_for_viewing_without_split_styles() { - add_filter( 'separate_core_block_assets', '__return_false' ); + add_filter( 'should_load_separate_core_block_assets', '__return_false' ); wp_default_styles( $GLOBALS['wp_styles'] ); $this->assertSame( @@ -446,7 +446,7 @@ CSS; * @covers ::wp_default_styles */ function test_block_styles_for_viewing_with_split_styles() { - add_filter( 'separate_core_block_assets', '__return_true' ); + add_filter( 'should_load_separate_core_block_assets', '__return_true' ); wp_default_styles( $GLOBALS['wp_styles'] ); $this->assertSame(