Skip to content

Commit 00b8099

Browse files
committed
Refactor fix for changing styles on the editor
1 parent 123d05b commit 00b8099

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/wp-includes/class-wp-theme-json.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class WP_Theme_JSON {
3535
* @since 5.8.0
3636
* @var array
3737
*/
38-
protected static $blocks_metadata = null;
38+
protected static $blocks_metadata = array();
3939

4040
/**
4141
* The CSS selector for the top-level styles.
@@ -721,11 +721,12 @@ protected static function append_to_selector( $selector, $to_append, $position =
721721
* @return array Block metadata.
722722
*/
723723
protected static function get_blocks_metadata() {
724-
$registry = WP_Block_Type_Registry::get_instance();
725-
$blocks = $registry->get_all_registered();
726-
static::$blocks_metadata = array();
727-
$blocks = array_diff_key( $blocks, static::$blocks_metadata );
728-
if ( count( $blocks ) === 0 ) {
724+
$registry = WP_Block_Type_Registry::get_instance();
725+
$blocks = $registry->get_all_registered();
726+
727+
// Is there metadata for all currently registered blocks?
728+
$blocks = array_diff_key( $blocks, static::$blocks_metadata );
729+
if ( empty( $blocks ) ) {
729730
return static::$blocks_metadata;
730731
}
731732
foreach ( $blocks as $block_name => $block_type ) {

0 commit comments

Comments
 (0)