Title: WP_Theme_JSON_Schema::migrate
Published: February 3, 2022
Last modified: May 20, 2026

---

# WP_Theme_JSON_Schema::migrate( array $theme_json, string $origin = 'theme' ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#wp--skip-link--target)

Function that migrates a given theme.json structure to the last version.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#parameters)󠁿

 `$theme_json`arrayrequired

The structure to migrate.

`$origin`stringoptional

What source of data this object represents.
 One of `'blocks'`, `'default'`, `'theme'`,
or `'custom'`. Default `'theme'`.

Default:`'theme'`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#return)󠁿

 array The structure in the last version.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#source)󠁿

    ```php
    public static function migrate( $theme_json, $origin = 'theme' ) {
    	if ( ! isset( $theme_json['version'] ) ) {
    		$theme_json = array(
    			'version' => WP_Theme_JSON::LATEST_SCHEMA,
    		);
    	}

    	// Migrate each version in order starting with the current version.
    	switch ( $theme_json['version'] ) {
    		case 1:
    			$theme_json = self::migrate_v1_to_v2( $theme_json );
    			// Deliberate fall through. Once migrated to v2, also migrate to v3.
    		case 2:
    			$theme_json = self::migrate_v2_to_v3( $theme_json, $origin );
    	}

    	return $theme_json;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme-json-schema.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-theme-json-schema.php#L45)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-theme-json-schema.php#L45-L62)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Theme_JSON_Schema::migrate_v2_to_v3()](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate_v2_to_v3/)`wp-includes/class-wp-theme-json-schema.php` |

Migrates from v2 to v3.

  | 
| [WP_Theme_JSON_Schema::migrate_v1_to_v2()](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate_v1_to_v2/)`wp-includes/class-wp-theme-json-schema.php` |

Removes the custom prefixes for a few properties that were part of v1:

  |

| Used by | Description | 
| [WP_Theme_JSON::remove_insecure_properties()](https://developer.wordpress.org/reference/classes/wp_theme_json/remove_insecure_properties/)`wp-includes/class-wp-theme-json.php` |

Removes insecure data from theme.json.

  | 
| [WP_Theme_JSON::__construct()](https://developer.wordpress.org/reference/classes/wp_theme_json/__construct/)`wp-includes/class-wp-theme-json.php` |

Constructor.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Migrate up to v3 and add $origin parameter. | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme_json_schema%2Fmigrate%2F)
before being able to contribute a note or feedback.