@@ -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 '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
// no break
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
// no break
62
64
}
63
65
@@ -102,10 +104,12 @@ private static function migrate_v1_to_v2( $old ) {
102
104
* @since 6.6.0
103
105
*
104
106
* @param array $old Data to migrate.
107
+ * @param string $origin What source of data this object represents.
108
+ * One of 'default', 'theme', or 'custom'.
105
109
*
106
110
* @return array Data with defaultFontSizes set to false.
107
111
*/
108
- private static function migrate_v2_to_v3 ( $ old ) {
112
+ private static function migrate_v2_to_v3 ( $ old, $ origin ) {
109
113
// Copy everything.
110
114
$ new = $ old ;
111
115
@@ -116,10 +120,7 @@ private static function migrate_v2_to_v3( $old ) {
116
120
* Remaining changes do not need to be applied to the custom origin,
117
121
* as they should take on the value of the theme origin.
118
122
*/
119
- if (
120
- isset ( $ new ['isGlobalStylesUserThemeJSON ' ] ) &&
121
- true === $ new ['isGlobalStylesUserThemeJSON ' ]
122
- ) {
123
+ if ( 'custom ' === $ origin ) {
123
124
return $ new ;
124
125
}
125
126
0 commit comments