Skip to content

Commit

Permalink
Refill variations cache if blocks changed
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jun 19, 2024
1 parent cdd91c9 commit 04948a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,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();

Check warning on line 788 in lib/class-wp-theme-json-resolver-gutenberg.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Unused variable $blocks.
$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 ];
}

Expand Down

0 comments on commit 04948a0

Please sign in to comment.