From 508fe0d611dc0ee033ec0235113ec824809dee46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 30 Jul 2020 19:28:47 +0200 Subject: [PATCH 1/5] Add support for more style properties in the global context --- lib/global-styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 1b6d5aa6bc2c8..6ba173fac5f24 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -298,7 +298,7 @@ function gutenberg_experimental_global_styles_get_block_data() { $block_data = array( 'global' => array( 'selector' => ':root', - 'supports' => array( 'background-color' ), + 'supports' => array( '--wp--style--color--link', 'background-color', 'font-size' ), ), ); From 89e4a6837b9ba4c2fc0c148a2bfa037e7d7d974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 21:07:17 +0200 Subject: [PATCH 2/5] Use a block type to represent the global context --- lib/global-styles.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 6ba173fac5f24..fe342b608f863 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -295,15 +295,27 @@ function gutenberg_experimental_global_styles_get_supported_styles( $supports ) * @return array */ function gutenberg_experimental_global_styles_get_block_data() { - $block_data = array( - 'global' => array( - 'selector' => ':root', - 'supports' => array( '--wp--style--color--link', 'background-color', 'font-size' ), - ), - ); + $block_data = array(); $registry = WP_Block_Type_Registry::get_instance(); - foreach ( $registry->get_all_registered() as $block_name => $block_type ) { + $blocks = array_merge( + $registry->get_all_registered(), + array( + 'global' => new WP_Block_Type( + 'global', + array( + 'supports' => array( + '__experimentalSelector' => ':root', + '__experimentalFontSize' => true, + '__experimentalColor' => array( + 'linkColor' => true + ) + ) + ) + ) + ) + ); + foreach ( $blocks as $block_name => $block_type ) { if ( empty( $block_type->supports ) || ! is_array( $block_type->supports ) ) { continue; } From 364252c03cb8c8d349cbd8ef7121724b28fac34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 3 Aug 2020 20:40:40 +0200 Subject: [PATCH 3/5] Add support for gradients --- lib/global-styles.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index fe342b608f863..0e5ff9fceead0 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -308,7 +308,8 @@ function gutenberg_experimental_global_styles_get_block_data() { '__experimentalSelector' => ':root', '__experimentalFontSize' => true, '__experimentalColor' => array( - 'linkColor' => true + 'linkColor' => true, + 'gradients' => true, ) ) ) From ace4c216a0fcd547c5d405e5f37941a068bf2c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 3 Aug 2020 20:44:18 +0200 Subject: [PATCH 4/5] Make linter happy --- lib/global-styles.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 0e5ff9fceead0..5423f251ff0c4 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -298,7 +298,7 @@ function gutenberg_experimental_global_styles_get_block_data() { $block_data = array(); $registry = WP_Block_Type_Registry::get_instance(); - $blocks = array_merge( + $blocks = array_merge( $registry->get_all_registered(), array( 'global' => new WP_Block_Type( @@ -307,14 +307,14 @@ function gutenberg_experimental_global_styles_get_block_data() { 'supports' => array( '__experimentalSelector' => ':root', '__experimentalFontSize' => true, - '__experimentalColor' => array( + '__experimentalColor' => array( 'linkColor' => true, 'gradients' => true, - ) - ) - ) - ) - ) + ), + ), + ), + ), + ), ); foreach ( $blocks as $block_name => $block_type ) { if ( empty( $block_type->supports ) || ! is_array( $block_type->supports ) ) { From 5fc664c9ede574c92a1d15f8cd824f838ec9cd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 4 Aug 2020 16:54:12 +0200 Subject: [PATCH 5/5] Make linter happy --- lib/global-styles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 5423f251ff0c4..24512c01ccc5b 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -312,9 +312,9 @@ function gutenberg_experimental_global_styles_get_block_data() { 'gradients' => true, ), ), - ), + ) ), - ), + ) ); foreach ( $blocks as $block_name => $block_type ) { if ( empty( $block_type->supports ) || ! is_array( $block_type->supports ) ) {