Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_Theme_JSON_Schema::migrate_v1_to_v2() WordPress Method

The WP_Theme_JSON_Schema::migrate_v1_to_v2() method is used to migrate a WordPress theme from JSON Schema version 1 to version 2. This is a breaking change, so it is important to test your theme before upgrading.

WP_Theme_JSON_Schema::migrate_v1_to_v2( array $old ) #

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


Description

‘border.customRadius’ => ‘border.radius’, ‘spacing.customMargin’ => ‘spacing.margin’, ‘spacing.customPadding’ => ‘spacing.padding’, ‘typography.customLineHeight’ => ‘typography.lineHeight’,


Top ↑

Parameters

$old

(array)(Required)Data to migrate.


Top ↑

Return

(array) Data without the custom prefixes.


Top ↑

Source

File: wp-includes/class-wp-theme-json-schema.php

	private static function migrate_v1_to_v2( $old ) {
		// Copy everything.
		$new = $old;

		// Overwrite the things that changed.
		if ( isset( $old['settings'] ) ) {
			$new['settings'] = self::rename_paths( $old['settings'], self::V1_TO_V2_RENAMED_PATHS );
		}

		// Set the new version.
		$new['version'] = 2;

		return $new;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.