# get_file_description()

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

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

## Сигнатура

```php
get_file_description( string $file ): string
```

## Описание

Получает описание стандартных файлов темы WordPress.

## Параметры

- `$file` `string` — обязательный. Путь в файловой системе или имя файла.

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

`string`

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

Файл: `wp-admin/includes/file.php:80`

```php
function get_file_description( $file ) {
	global $wp_file_descriptions, $allowed_files;

	$dirname   = pathinfo( $file, PATHINFO_DIRNAME );
	$file_path = $allowed_files[ $file ];

	if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $dirname ) {
		return $wp_file_descriptions[ basename( $file ) ];
	} elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
		$template_data = implode( '', file( $file_path ) );

		if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
			/* translators: %s: Template name. */
			return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
		}
	}

	return trim( basename( $file ) );
}
```

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

- 1.5.0 — Introduced.

## Связанные

Используется в: [`_cleanup_header_comment`](https://chugunov.pro/api-wordpress/functions/_cleanup_header_comment/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`wp_print_theme_file_tree`](https://chugunov.pro/api-wordpress/functions/wp_print_theme_file_tree/).

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