Skip to content

Commit

Permalink
Change theme.json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Apr 13, 2021
1 parent 3e8ac5a commit 98c37c5
Show file tree
Hide file tree
Showing 11 changed files with 1,654 additions and 1,059 deletions.
6 changes: 3 additions & 3 deletions lib/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ private static function translate( $theme_json, $domain = 'default' ) {
/*
* We need to process the paths that include '*' separately.
* One example of such a path would be:
* [ 'settings', '*', 'color', 'palette' ]
* [ 'settings', 'blocks', '*', 'color', 'palette' ]
*/
$nodes_to_iterate = array_keys( $path, '*', true );
if ( ! empty( $nodes_to_iterate ) ) {
/*
* At the moment, we only need to support one '*' in the path, so take it directly.
* - base will be [ 'settings' ]
* - base will be [ 'settings', 'blocks' ]
* - data will be [ 'color', 'palette' ]
*/
$base_path = array_slice( $path, 0, $nodes_to_iterate[0] );
Expand All @@ -213,7 +213,7 @@ private static function translate( $theme_json, $domain = 'default' ) {
continue;
}

// Whole path will be [ 'settings', 'core/paragraph', 'color', 'palette' ].
// Whole path will be [ 'settings', 'blocks', 'core/paragraph', 'color', 'palette' ].
$whole_path = array_merge( $base_path, array( $node_name ), $data_path );
$translated_array = self::translate_theme_json_chunk( $array_to_translate, $key, $context, $domain );
gutenberg_experimental_set( $theme_json, $whole_path, $translated_array );
Expand Down
2 changes: 1 addition & 1 deletion lib/class-wp-theme-json-schema-v0.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static function parse( $old ) {
$new['styles'] = self::process_styles( $old['styles'], $blocks_to_consolidate );
}

$new['version'] = 1;
$new['version'] = WP_Theme_JSON::LATEST_SCHEMA;

return $new;
}
Expand Down
Loading

0 comments on commit 98c37c5

Please sign in to comment.