Skip to content

Commit

Permalink
Refactor fix for changing styles on the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Oct 4, 2022
1 parent 123d05b commit 00b8099
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WP_Theme_JSON {
* @since 5.8.0
* @var array
*/
protected static $blocks_metadata = null;
protected static $blocks_metadata = array();

/**
* The CSS selector for the top-level styles.
Expand Down Expand Up @@ -721,11 +721,12 @@ protected static function append_to_selector( $selector, $to_append, $position =
* @return array Block metadata.
*/
protected static function get_blocks_metadata() {
$registry = WP_Block_Type_Registry::get_instance();
$blocks = $registry->get_all_registered();
static::$blocks_metadata = array();
$blocks = array_diff_key( $blocks, static::$blocks_metadata );
if ( count( $blocks ) === 0 ) {
$registry = WP_Block_Type_Registry::get_instance();
$blocks = $registry->get_all_registered();

// Is there metadata for all currently registered blocks?
$blocks = array_diff_key( $blocks, static::$blocks_metadata );
if ( empty( $blocks ) ) {
return static::$blocks_metadata;
}
foreach ( $blocks as $block_name => $block_type ) {
Expand Down

0 comments on commit 00b8099

Please sign in to comment.