@@ -35,13 +35,14 @@ class WP_Theme_JSON_Schema {
35
35
* Function that migrates a given theme.json structure to the last version.
36
36
*
37
37
* @since 5.9.0
38
- * @since 6.6.0 Migrate up to v3.
38
+ * @since 6.6.0 Migrate up to v3 and add $origin parameter .
39
39
*
40
40
* @param array $theme_json The structure to migrate.
41
- *
41
+ * @param string $origin Optional. What source of data this object represents.
42
+ * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
42
43
* @return array The structure in the last version.
43
44
*/
44
- public static function migrate ( $ theme_json ) {
45
+ public static function migrate ( $ theme_json, $ origin = ' theme ' ) {
45
46
if ( ! isset ( $ theme_json ['version ' ] ) ) {
46
47
$ theme_json = array (
47
48
'version ' => WP_Theme_JSON::LATEST_SCHEMA ,
@@ -54,7 +55,7 @@ public static function migrate( $theme_json ) {
54
55
$ theme_json = self ::migrate_v1_to_v2 ( $ theme_json );
55
56
// Deliberate fall through. Once migrated to v2, also migrate to v3.
56
57
case 2 :
57
- $ theme_json = self ::migrate_v2_to_v3 ( $ theme_json );
58
+ $ theme_json = self ::migrate_v2_to_v3 ( $ theme_json, $ origin );
58
59
}
59
60
60
61
return $ theme_json ;
@@ -100,11 +101,12 @@ private static function migrate_v1_to_v2( $old ) {
100
101
*
101
102
* @since 6.6.0
102
103
*
103
- * @param array $old Data to migrate.
104
- *
104
+ * @param array $old Data to migrate.
105
+ * @param string $origin What source of data this object represents.
106
+ * One of 'blocks', 'default', 'theme', or 'custom'.
105
107
* @return array Data with defaultFontSizes set to false.
106
108
*/
107
- private static function migrate_v2_to_v3 ( $ old ) {
109
+ private static function migrate_v2_to_v3 ( $ old, $ origin ) {
108
110
// Copy everything.
109
111
$ new = $ old ;
110
112
@@ -115,10 +117,7 @@ private static function migrate_v2_to_v3( $old ) {
115
117
* Remaining changes do not need to be applied to the custom origin,
116
118
* as they should take on the value of the theme origin.
117
119
*/
118
- if (
119
- isset ( $ new ['isGlobalStylesUserThemeJSON ' ] ) &&
120
- true === $ new ['isGlobalStylesUserThemeJSON ' ]
121
- ) {
120
+ if ( 'custom ' === $ origin ) {
122
121
return $ new ;
123
122
}
124
123
0 commit comments