Skip to content

Commit

Permalink
Theme Export: Sort theme.json properties
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Mar 30, 2022
1 parent bd6853d commit 9048ee5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/compat/wordpress-6.0/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function get_data() {
}
}

gutenberg_recursive_ksort( $flattened_theme_json );

return $flattened_theme_json;
}

Expand Down
22 changes: 22 additions & 0 deletions lib/compat/wordpress-6.0/utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Generic helper functions
*
* @since 6.0
*/

/**
* Sorts the keys of an array alphabetically.
* The array is passed by reference so it doesn't get returned
* which mimiks the behaviour of ksort.
*
* @param array $array The array to sort, passed by reference.
*/
function gutenberg_recursive_ksort( &$array ) {
foreach ( $array as &$value ) {
if ( is_array( $value ) ) {
gutenberg_recursive_ksort( $value );
}
}
ksort( $array );
}
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php';
require __DIR__ . '/compat/wordpress-6.0/utils.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-theme-json-gutenberg.php';
require __DIR__ . '/compat/wordpress-6.0/rest-api.php';
require __DIR__ . '/compat/wordpress-6.0/block-patterns.php';
Expand Down

0 comments on commit 9048ee5

Please sign in to comment.