Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme Export: Sort theme.json properties #39842

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
}
}

wp_recursive_ksort( $flattened_theme_json );

return $flattened_theme_json;
}

Expand Down
23 changes: 23 additions & 0 deletions lib/compat/wordpress-6.0/utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Generic helper functions
*
* @package WordPress
* @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 wp_recursive_ksort( &$array ) {
foreach ( $array as &$value ) {
if ( is_array( $value ) ) {
wp_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