Skip to content

Commit

Permalink
Use a block type to represent the global context
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Aug 2, 2020
1 parent 508fe0d commit 89e4a68
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 89e4a68

Please sign in to comment.