W3cubDocs

/WordPress

WP_Theme_JSON_Schema::migrate( array $theme_json, string $origin = ‘theme’ ): array

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

Parameters

$theme_jsonarrayrequired
The structure to migrate.
$originstringoptional
What source of data this object represents.
One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.

Default:'theme'

Return

array The structure in the last version.

Source

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;
}

Changelog

Version Description
6.6.0 Migrate up to v3 and add $origin parameter.
5.9.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_schema/migrate