WP_Theme_JSON_Schema::rename_settings()private staticWP 5.9.0

Processes a settings array, renaming or moving properties.

Method of the class: WP_Theme_JSON_Schema{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WP_Theme_JSON_Schema::rename_settings( $settings, $paths_to_rename );
$settings(array) (required) (passed by reference — &)
Reference to settings either defaults or an individual block's.
$paths_to_rename(array) (required)
Paths to rename.

Changelog

Since 5.9.0 Introduced.

WP_Theme_JSON_Schema::rename_settings() code WP 6.7.1

private static function rename_settings( &$settings, $paths_to_rename ) {
	foreach ( $paths_to_rename as $original => $renamed ) {
		$original_path = explode( '.', $original );
		$renamed_path  = explode( '.', $renamed );
		$current_value = _wp_array_get( $settings, $original_path, null );

		if ( null !== $current_value ) {
			_wp_array_set( $settings, $renamed_path, $current_value );
			self::unset_setting_by_path( $settings, $original_path );
		}
	}
}