WP_Theme_JSON_Schema::migrate()public staticWP 5.9.0

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

Метод класса: WP_Theme_JSON_Schema{}

Хуков нет.

Возвращает

Массив. The structure in the last version.

Использование

$result = WP_Theme_JSON_Schema::migrate( $theme_json, $origin );
$theme_json(массив) (обязательный)
The structure to migrate.
$origin(строка)
What source of data this object represents. One of 'blocks', 'default', 'theme', or 'custom'.
По умолчанию: 'theme'

Список изменений

С версии 5.9.0 Введена.
С версии 6.6.0 Migrate up to v3 and add $origin parameter.

Код WP_Theme_JSON_Schema::migrate() WP 6.8.1

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