$valid_variations = array
();
foreach ( self::
get_blocks_metadata() as $block_name =>
$block_meta ) { if ( !
isset( $block_meta['styleVariations'
] ) ) { continue;
} $valid_variations[ $block_name ] =
array_keys( $block_meta['styleVariations'
] );
} $theme_json =
static::
sanitize( $this->theme_json,
$valid_block_names,
$valid_element_names,
$valid_variations );
$this->theme_json =
static::
maybe_opt_in_into_settings( $theme_json );
// Internally, presets are keyed by origin.
$nodes =
static::
get_setting_nodes( $this->theme_json
);
foreach ( $nodes as $node ) { foreach ( static::PRESETS_METADATA
as $preset_metadata ) { $path =
$node['path'
];
foreach ( $preset_metadata['path'
] as $subpath ) { $path[] =
$subpath;
} $preset =
_wp_array_get( $this->theme_json,
$path, null
);
if ( null !==
$preset ) { // If the preset is not already keyed by origin.
if ( isset( $preset[0
] ) ||
empty( $preset ) ) { _wp_array_set( $this->theme_json,
$path, array
( $origin =>
$preset ) );
}