# _deprecated_file()

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

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

> Устаревший элемент. Помечен устаревшим с версии 5.4.0.

## Сигнатура

```php
_deprecated_file( string $file, string $version, string $replacement = '', string $message = '' )
```

## Описание

Существует хук 'deprecated_file_included', который будет вызван и с помощью которого можно получить трассировку вплоть до того, какой файл и функция подключили устаревший файл.
Текущее поведение — сгенерировать пользовательскую ошибку, если WP_DEBUG равно true.
Эту функцию следует использовать в каждом устаревшем файле.

## Параметры

- `$file` `string` — обязательный. Файл, который был подключён.
- `$version` `string` — обязательный. Версия WordPress, в которой файл стал устаревшим.
- `$replacement` `string` — необязательный, по умолчанию `''`. Файл, который следовало подключить, относительно ABSPATH.
- `$message` `string` — необязательный, по умолчанию `''`. Сообщение об изменении.

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

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

```php
function _deprecated_file( $file, $version, $replacement = '', $message = '' ) {

	/**
	 * Fires when a deprecated file is called.
	 *
	 * @since 2.5.0
	 *
	 * @param string $file        The file that was called.
	 * @param string $replacement The file that should have been included based on ABSPATH.
	 * @param string $version     The version of WordPress that deprecated the file.
	 * @param string $message     A message regarding the change.
	 */
	do_action( 'deprecated_file_included', $file, $replacement, $version, $message );

	/**
	 * Filters whether to trigger an error for deprecated files.
	 *
	 * @since 2.5.0
	 *
	 * @param bool $trigger Whether to trigger the error for deprecated files. Default true.
	 */
	if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
		$message = empty( $message ) ? '' : ' ' . $message;

		if ( function_exists( '__' ) ) {
			if ( $replacement ) {
				$message = sprintf(
					/* translators: 1: PHP file name, 2: Version number, 3: Alternative file name. */
					__( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
					$file,
					$version,
					$replacement
				) . $message;
			} else {
				$message = sprintf(
					/* translators: 1: PHP file name, 2: Version number. */
					__( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ),
					$file,
					$version
				) . $message;
			}
		} else {
			if ( $replacement ) {
				$message = sprintf(
					'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
					$file,
					$version,
					$replacement
				);
			} else {
				$message = sprintf(
					'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
					$file,
					$version
				) . $message;
			}
		}

		wp_trigger_error( '', $message, E_USER_DEPRECATED );
	}
}
```

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

- 5.4.0 — The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE).
- 2.5.0 — Introduced.

## Связанные

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

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