Skip to content

Commit 0d47eed

Browse files
authored
Move and version attributes to the start of the theme.json file as this helps editing in IDEs (#787)
1 parent cc1c335 commit 0d47eed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

includes/create-theme/resolver_additions.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ public static function export_theme_data( $content, $extra_theme_data = null ) {
8888
}
8989
$schema = 'https://schemas.wp.org/' . $theme_json_version . '/theme.json';
9090
}
91-
$data['$schema'] = $schema;
91+
// Ensure $schema is the first property and version is second in the JSON output.
92+
$ordered_data = array( '$schema' => $schema );
93+
94+
// Add version as the second property if it exists.
95+
if ( isset( $data['version'] ) ) {
96+
$ordered_data['version'] = $data['version'];
97+
unset( $data['version'] );
98+
}
99+
100+
// Merge the remaining data.
101+
$data = array_merge( $ordered_data, $data );
92102
return static::stringify( $data );
93103
}
94104

0 commit comments

Comments
 (0)