# wp_normalize_path()

URL: https://chugunov.pro/api-wordpress/functions/wp_normalize_path/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.9.0.

## Сигнатура

```php
wp_normalize_path( string $path ): string
```

## Описание

В системах Windows заменяет обратные слэши прямыми и приводит буквы дисков к верхнему регистру.
Допускает два ведущих слэша для сетевых ресурсов Windows, но гарантирует, что все остальные дублирующиеся слэши сокращаются до одного.

## Параметры

- `$path` `string` — обязательный. Путь для нормализации.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/functions.php:2187`

```php
function wp_normalize_path( $path ): string {
	$path = (string) $path;

	static $cache = array();
	if ( isset( $cache[ $path ] ) ) {
		return $cache[ $path ];
	}

	$original_path = $path;
	$wrapper       = '';

	if ( wp_is_stream( $path ) ) {
		list( $wrapper, $path ) = explode( '://', $path, 2 );

		$wrapper .= '://';
	}

	// Standardize all paths to use '/'.
	$path = str_replace( '\\', '/', $path );

	// Replace multiple slashes down to a singular, allowing for network shares having two slashes.
	$path = (string) preg_replace( '|(?<=.)/+|', '/', $path );

	// Windows paths should uppercase the drive letter.
	if ( ':' === substr( $path, 1, 1 ) ) {
		$path = ucfirst( $path );
	}

	$cache[ $original_path ] = $wrapper . $path;
	return $cache[ $original_path ];
}
```

## История изменений

- 7.0.0 — Uses a static cache to store normalized paths.
- 4.9.7 — Allows for PHP file wrappers.
- 4.5.0 — Allows for Windows network shares.
- 4.4.0 — Ensures upper-case drive letters on Windows systems.
- 3.9.0 — Introduced.

## Связанные

Использует: [`wp_is_stream`](https://chugunov.pro/api-wordpress/functions/wp_is_stream/).
Используется в: [`_wp_connectors_resolve_ai_provider_logo_url`](https://chugunov.pro/api-wordpress/functions/_wp_connectors_resolve_ai_provider_logo_url/), `WP_Block_Metadata_Registry::get_collection_block_metadata_files`, `WP_Block_Metadata_Registry::get_default_collection_roots`, `WP_Block_Metadata_Registry::get_metadata`, `WP_Block_Metadata_Registry::register_collection`, `WP_Font_Collection::load_from_json`, [`register_block_script_module_id`](https://chugunov.pro/api-wordpress/functions/register_block_script_module_id/), [`get_block_asset_url`](https://chugunov.pro/api-wordpress/functions/get_block_asset_url/), [`wp_json_file_decode`](https://chugunov.pro/api-wordpress/functions/wp_json_file_decode/), [`wp_generate_block_templates_export_file`](https://chugunov.pro/api-wordpress/functions/wp_generate_block_templates_export_file/), [`register_block_script_handle`](https://chugunov.pro/api-wordpress/functions/register_block_script_handle/), [`register_block_style_handle`](https://chugunov.pro/api-wordpress/functions/register_block_style_handle/), [`register_block_type_from_metadata`](https://chugunov.pro/api-wordpress/functions/register_block_type_from_metadata/), `Theme_Installer_Skin::do_overwrite`, `WP_Recovery_Mode::get_extension_for_error`, [`_get_plugin_from_callback`](https://chugunov.pro/api-wordpress/functions/_get_plugin_from_callback/), [`wp_delete_file_from_directory`](https://chugunov.pro/api-wordpress/functions/wp_delete_file_from_directory/), [`wp_privacy_generate_personal_data_export_file`](https://chugunov.pro/api-wordpress/functions/wp_privacy_generate_personal_data_export_file/), [`wp_validate_redirect`](https://chugunov.pro/api-wordpress/functions/wp_validate_redirect/), [`wp_debug_backtrace_summary`](https://chugunov.pro/api-wordpress/functions/wp_debug_backtrace_summary/), [`validate_file`](https://chugunov.pro/api-wordpress/functions/validate_file/), [`plugins_url`](https://chugunov.pro/api-wordpress/functions/plugins_url/), [`plugin_basename`](https://chugunov.pro/api-wordpress/functions/plugin_basename/), [`wp_register_plugin_realpath`](https://chugunov.pro/api-wordpress/functions/wp_register_plugin_realpath/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_normalize_path/
