WP_Theme_JSON_Schema::rename_settings()private staticWP 5.9.0

Processes a settings array, renaming or moving properties.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = WP_Theme_JSON_Schema::rename_settings( $settings, $paths_to_rename );
$settings(массив) (обязательный) (передается по ссылке — &)
Reference to settings either defaults or an individual block's.
$paths_to_rename(массив) (обязательный)
Paths to rename.

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

С версии 5.9.0 Введена.

Код WP_Theme_JSON_Schema::rename_settings() WP 6.5.2

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