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

In this article

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

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

User Contributed Notes

You must log in before being able to contribute a note or feedback.