@@ -40,11 +40,13 @@ class WP_Theme_JSON_Schema_Gutenberg {
40
40
* @since 5.9.0
41
41
* @since 6.6.0 Migrate up to v3.
42
42
*
43
- * @param array $theme_json The structure to migrate.
43
+ * @param array $theme_json The structure to migrate.
44
+ * @param string $origin Optional. What source of data this object represents.
45
+ * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
44
46
*
45
47
* @return array The structure in the last version.
46
48
*/
47
- public static function migrate ( $ theme_json ) {
49
+ public static function migrate ( $ theme_json, $ origin = ' theme ' ) {
48
50
if ( ! isset ( $ theme_json ['version ' ] ) ) {
49
51
$ theme_json = array (
50
52
'version ' => WP_Theme_JSON::LATEST_SCHEMA ,
@@ -57,7 +59,7 @@ public static function migrate( $theme_json ) {
57
59
$ theme_json = self ::migrate_v1_to_v2 ( $ theme_json );
58
60
// Deliberate fall through. Once migrated to v2, also migrate to v3.
59
61
case 2 :
60
- $ theme_json = self ::migrate_v2_to_v3 ( $ theme_json );
62
+ $ theme_json = self ::migrate_v2_to_v3 ( $ theme_json, $ origin );
61
63
}
62
64
63
65
return $ theme_json ;
@@ -103,11 +105,12 @@ private static function migrate_v1_to_v2( $old ) {
103
105
*
104
106
* @since 6.6.0
105
107
*
106
- * @param array $old Data to migrate.
107
- *
108
+ * @param array $old Data to migrate.
109
+ * @param string $origin What source of data this object represents.
110
+ * One of 'blocks', 'default', 'theme', or 'custom'.
108
111
* @return array Data with defaultFontSizes set to false.
109
112
*/
110
- private static function migrate_v2_to_v3 ( $ old ) {
113
+ private static function migrate_v2_to_v3 ( $ old, $ origin ) {
111
114
// Copy everything.
112
115
$ new = $ old ;
113
116
@@ -118,10 +121,7 @@ private static function migrate_v2_to_v3( $old ) {
118
121
* Remaining changes do not need to be applied to the custom origin,
119
122
* as they should take on the value of the theme origin.
120
123
*/
121
- if (
122
- isset ( $ new ['isGlobalStylesUserThemeJSON ' ] ) &&
123
- true === $ new ['isGlobalStylesUserThemeJSON ' ]
124
- ) {
124
+ if ( 'custom ' === $ origin ) {
125
125
return $ new ;
126
126
}
127
127
0 commit comments