diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index b2fd4405b8a84e..f6d93583bb875a 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -772,9 +772,17 @@ protected static function get_style_variation_files() { * @return array */ public static function get_style_variations( $scope = 'theme' ) { + $registry = WP_Block_Type_Registry::get_instance(); + $blocks = $registry->get_all_registered(); $theme_dir = get_stylesheet_directory(); $locale = get_locale(); - if ( isset( static::$style_variations_cache[ $theme_dir ][ $locale ][ $scope ] ) ) { + + if ( + isset( static::$style_variations_cache[ $theme_dir ][ $locale ][ $scope ] ) && + // Variations depend on registered blocks. + null !== static::$blocks && + static::has_same_registered_blocks( 'theme' ) + ) { return static::$style_variations_cache[ $theme_dir ][ $locale ][ $scope ]; }