# _deprecated_hook()

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

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

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

## Сигнатура

```php
_deprecated_hook( string $hook, string $version, string $replacement = '', string $message = '' )
```

## Описание

Используйте действие 'deprecated_hook_run', чтобы получить трассировку вызовов с указанием места, где был вызван устаревший хук.
По умолчанию генерируется пользовательская ошибка, если WP_DEBUG равно true.
Эта функция вызывается функциями do_action_deprecated() и apply_filters_deprecated() , поэтому обычно её не нужно вызывать напрямую.

## Параметры

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

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

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

```php
function _deprecated_hook( $hook, $version, $replacement = '', $message = '' ) {
	/**
	 * Fires when a deprecated hook is called.
	 *
	 * @since 4.6.0
	 *
	 * @param string $hook        The hook that was called.
	 * @param string $replacement The hook that should be used as a replacement.
	 * @param string $version     The version of WordPress that deprecated the argument used.
	 * @param string $message     A message regarding the change.
	 */
	do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );

	/**
	 * Filters whether to trigger deprecated hook errors.
	 *
	 * @since 4.6.0
	 *
	 * @param bool $trigger Whether to trigger deprecated hook errors. Requires
	 *                      `WP_DEBUG` to be defined true.
	 */
	if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
		$message = empty( $message ) ? '' : ' ' . $message;

		if ( $replacement ) {
			$message = sprintf(
				/* translators: 1: WordPress hook name, 2: Version number, 3: Alternative hook name. */
				__( 'Hook %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
				$hook,
				$version,
				$replacement
			) . $message;
		} else {
			$message = sprintf(
				/* translators: 1: WordPress hook name, 2: Version number. */
				__( 'Hook %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ),
				$hook,
				$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).
- 4.6.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/).
Используется в: [`apply_filters_deprecated`](https://chugunov.pro/api-wordpress/functions/apply_filters_deprecated/), [`do_action_deprecated`](https://chugunov.pro/api-wordpress/functions/do_action_deprecated/).

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