From fdf86e09b97990f9e6167eb6bcfe135be5560782 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 27 Oct 2022 13:43:43 +0100 Subject: [PATCH 1/8] Update logic to match client-assets --- lib/compat/wordpress-6.1/template-parts-screen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.1/template-parts-screen.php b/lib/compat/wordpress-6.1/template-parts-screen.php index d9b785100b8d9..4310b04953a82 100644 --- a/lib/compat/wordpress-6.1/template-parts-screen.php +++ b/lib/compat/wordpress-6.1/template-parts-screen.php @@ -187,7 +187,7 @@ static function( $classes ) { wp_enqueue_media(); if ( - current_theme_supports( 'wp-block-styles' ) || + current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { wp_enqueue_style( 'wp-block-library-theme' ); From 5bff2b2f38e846a8c881aa5285ae1f8802230cd2 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 27 Oct 2022 13:50:25 +0100 Subject: [PATCH 2/8] Move gutenberg_override_style into if statement --- lib/client-assets.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index f1b94c0d46abf..fb7fe7cccb399 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -325,7 +325,14 @@ function gutenberg_register_packages_styles( $styles ) { global $editor_styles; if ( current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. - $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; + gutenberg_override_style( + $styles, + 'wp-block-library-theme', + gutenberg_url( 'build/block-library/theme.css' ), + $wp_edit_blocks_dependencies, + $version + ); + $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); } gutenberg_override_style( @@ -364,15 +371,6 @@ function gutenberg_register_packages_styles( $styles ) { ); $styles->add_data( 'wp-nux', 'rtl', 'replace' ); - gutenberg_override_style( - $styles, - 'wp-block-library-theme', - gutenberg_url( 'build/block-library/theme.css' ), - array(), - $version - ); - $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); - gutenberg_override_style( $styles, 'wp-list-reusable-blocks', From 50f21446717460d05286b8f79040263f01844a4f Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Tue, 6 Dec 2022 17:14:10 +0000 Subject: [PATCH 3/8] Update logic to match client-assets --- lib/compat/wordpress-6.2/script-loader.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index 84681b3151238..4cf0d26451005 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -70,7 +70,8 @@ static function () use ( $style ) { * Note for core merge: see inline comment on what's been updated. */ function gutenberg_resolve_assets_override() { - global $pagenow; + global $pagenow, $editor_styles; + $script_handles = array(); // Note for core merge: only 'wp-edit-blocks' should be in this array. @@ -78,7 +79,10 @@ function gutenberg_resolve_assets_override() { 'wp-edit-blocks', ); - if ( current_theme_supports( 'wp-block-styles' ) ) { + if ( + current_theme_supports( 'wp-block-styles' ) && + ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) + ) { $style_handles[] = 'wp-block-library-theme'; } From 89c3d7d2e3a8e63fd401cf269e3e2196e760dfcf Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 16 Dec 2022 16:51:35 +0000 Subject: [PATCH 4/8] Move wp-block-library-theme inside current_theme_supports logic --- lib/client-assets.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index b7537057b89ab..258acd97599a9 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -337,7 +337,15 @@ function gutenberg_register_packages_styles( $styles ) { global $editor_styles; if ( current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. - $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; + + gutenberg_override_style( + $styles, + 'wp-block-library-theme', + gutenberg_url( 'build/block-library/theme.css' ), + array(), + $version + ); + $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); } gutenberg_override_style( @@ -367,15 +375,6 @@ function gutenberg_register_packages_styles( $styles ) { ); $styles->add_data( 'wp-edit-blocks', 'rtl', 'replace' ); - gutenberg_override_style( - $styles, - 'wp-block-library-theme', - gutenberg_url( 'build/block-library/theme.css' ), - array(), - $version - ); - $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); - gutenberg_override_style( $styles, 'wp-list-reusable-blocks', From 0939f349334d315e9a66aebc4c65fbb40e6b7bee Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 16 Dec 2022 17:22:40 +0000 Subject: [PATCH 5/8] Revert "Move wp-block-library-theme inside current_theme_supports logic" This reverts commit 89c3d7d2e3a8e63fd401cf269e3e2196e760dfcf. --- lib/client-assets.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 258acd97599a9..b7537057b89ab 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -337,15 +337,7 @@ function gutenberg_register_packages_styles( $styles ) { global $editor_styles; if ( current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. - - gutenberg_override_style( - $styles, - 'wp-block-library-theme', - gutenberg_url( 'build/block-library/theme.css' ), - array(), - $version - ); - $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); + $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } gutenberg_override_style( @@ -375,6 +367,15 @@ function gutenberg_register_packages_styles( $styles ) { ); $styles->add_data( 'wp-edit-blocks', 'rtl', 'replace' ); + gutenberg_override_style( + $styles, + 'wp-block-library-theme', + gutenberg_url( 'build/block-library/theme.css' ), + array(), + $version + ); + $styles->add_data( 'wp-block-library-theme', 'rtl', 'replace' ); + gutenberg_override_style( $styles, 'wp-list-reusable-blocks', From b3b368bc57c62158d271f4c3c602b3e2e4c1de49 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 16 Dec 2022 17:27:48 +0000 Subject: [PATCH 6/8] Remove $editor_styles check --- lib/client-assets.php | 2 +- lib/compat/wordpress-6.1/template-parts-screen.php | 5 +---- lib/compat/wordpress-6.2/script-loader.php | 5 +---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index b7537057b89ab..e048d2f57208b 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -335,7 +335,7 @@ function gutenberg_register_packages_styles( $styles ) { } global $editor_styles; - if ( current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { + if ( current_theme_supports( 'wp-block-styles' ) ) { // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } diff --git a/lib/compat/wordpress-6.1/template-parts-screen.php b/lib/compat/wordpress-6.1/template-parts-screen.php index 9db531b99045e..2a18dc928eabb 100644 --- a/lib/compat/wordpress-6.1/template-parts-screen.php +++ b/lib/compat/wordpress-6.1/template-parts-screen.php @@ -177,10 +177,7 @@ static function( $classes ) { wp_enqueue_style( 'wp-format-library' ); wp_enqueue_media(); - if ( - current_theme_supports( 'wp-block-styles' ) && - ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) - ) { + if ( current_theme_supports( 'wp-block-styles' ) ) { wp_enqueue_style( 'wp-block-library-theme' ); } diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index 39a6fcfab7e95..21c237d142a3a 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -79,10 +79,7 @@ function gutenberg_resolve_assets_override() { 'wp-edit-blocks', ); - if ( - current_theme_supports( 'wp-block-styles' ) && - ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) - ) { + if ( current_theme_supports( 'wp-block-styles' ) ) { $style_handles[] = 'wp-block-library-theme'; } From ddbd3007fcdca1deaf58351155542a21e8c1bf55 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 16 Dec 2022 17:48:12 +0000 Subject: [PATCH 7/8] Revert "Remove $editor_styles check" This reverts commit b3b368bc57c62158d271f4c3c602b3e2e4c1de49. --- lib/client-assets.php | 2 +- lib/compat/wordpress-6.1/template-parts-screen.php | 5 ++++- lib/compat/wordpress-6.2/script-loader.php | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index e048d2f57208b..b7537057b89ab 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -335,7 +335,7 @@ function gutenberg_register_packages_styles( $styles ) { } global $editor_styles; - if ( current_theme_supports( 'wp-block-styles' ) ) { + if ( current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } diff --git a/lib/compat/wordpress-6.1/template-parts-screen.php b/lib/compat/wordpress-6.1/template-parts-screen.php index 2a18dc928eabb..9db531b99045e 100644 --- a/lib/compat/wordpress-6.1/template-parts-screen.php +++ b/lib/compat/wordpress-6.1/template-parts-screen.php @@ -177,7 +177,10 @@ static function( $classes ) { wp_enqueue_style( 'wp-format-library' ); wp_enqueue_media(); - if ( current_theme_supports( 'wp-block-styles' ) ) { + if ( + current_theme_supports( 'wp-block-styles' ) && + ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) + ) { wp_enqueue_style( 'wp-block-library-theme' ); } diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index 21c237d142a3a..39a6fcfab7e95 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -79,7 +79,10 @@ function gutenberg_resolve_assets_override() { 'wp-edit-blocks', ); - if ( current_theme_supports( 'wp-block-styles' ) ) { + if ( + current_theme_supports( 'wp-block-styles' ) && + ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) + ) { $style_handles[] = 'wp-block-library-theme'; } From 0c230f63357430cc2881c47da5a2ec18d547952c Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Wed, 25 Jan 2023 20:02:32 +0000 Subject: [PATCH 8/8] Remove empty line --- lib/compat/wordpress-6.2/script-loader.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index ea8bbbda2efc5..dde4b1ab1e47e 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -72,7 +72,6 @@ static function () use ( $style ) { function gutenberg_resolve_assets_override() { global $pagenow, $editor_styles; - $script_handles = array( 'wp-polyfill', );