# _doing_it_wrong()

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

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

## Сигнатура

```php
_doing_it_wrong( string $function_name, string $message, string $version )
```

## Описание

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

## Параметры

- `$function_name` `string` — обязательный. Функция, которая была вызвана.
- `$message` `string` — обязательный. Сообщение, объясняющее, что было сделано некорректно.
- `$version` `string` — обязательный. Версия WordPress, в которой было добавлено сообщение.

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

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

```php
function _doing_it_wrong( $function_name, $message, $version ) {

	/**
	 * Fires when the given function is being used incorrectly.
	 *
	 * @since 3.1.0
	 *
	 * @param string $function_name The function that was called.
	 * @param string $message       A message explaining what has been done incorrectly.
	 * @param string $version       The version of WordPress where the message was added.
	 */
	do_action( 'doing_it_wrong_run', $function_name, $message, $version );

	/**
	 * Filters whether to trigger an error for _doing_it_wrong() calls.
	 *
	 * @since 3.1.0
	 * @since 5.1.0 Added the `$function_name`, `$message`, and `$version` parameters.
	 *
	 * @param bool   $trigger       Whether to trigger the error for _doing_it_wrong() calls. Default true.
	 * @param string $function_name The function that was called.
	 * @param string $message       A message explaining what has been done incorrectly.
	 * @param string $version       The version of WordPress where the message was added.
	 */
	if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true, $function_name, $message, $version ) ) {
		if ( function_exists( '__' ) ) {
			if ( $version ) {
				/* translators: %s: Version number. */
				$version = sprintf( __( '(This message was added in version %s.)' ), $version );
			}

			$message .= ' ' . sprintf(
				/* translators: %s: Documentation URL. */
				__( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
				__( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' )
			);

			$message = sprintf(
				/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: WordPress version number. */
				__( 'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s' ),
				$function_name,
				$message,
				$version
			);
		} else {
			if ( $version ) {
				$version = sprintf( '(This message was added in version %s.)', $version );
			}

			$message .= sprintf(
				' Please see <a href="%s">Debugging in WordPress</a> for more information.',
				'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/'
			);

			$message = sprintf(
				'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s',
				$function_name,
				$message,
				$version
			);
		}

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

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

- 5.4.0 — This function is no longer marked as "private".
- 3.1.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_connectors_is_ai_api_key_valid`](https://chugunov.pro/api-wordpress/functions/_wp_connectors_is_ai_api_key_valid/), [`_wp_connectors_resolve_ai_provider_logo_url`](https://chugunov.pro/api-wordpress/functions/_wp_connectors_resolve_ai_provider_logo_url/), `WP_Icons_Registry::register`, `WP_Icons_Registry::__construct`, `WP_Connector_Registry::unregister`, `WP_Connector_Registry::register`, `WP_Connector_Registry::get_registered`, `WP_Connector_Registry::set_instance`, `WP_AI_Client_Prompt_Builder::__construct`, `WP_AI_Client_Prompt_Builder::using_abilities`, `WP_Interactivity_API::_process_directives`, `WP_Interactivity_API::get_context`, `WP_Interactivity_API::get_element`, `WP_Script_Modules::sort_item_dependencies`, `WP_Script_Modules::set_fetchpriority`, [`wp_register_ability_category`](https://chugunov.pro/api-wordpress/functions/wp_register_ability_category/), [`wp_register_ability`](https://chugunov.pro/api-wordpress/functions/wp_register_ability/), `WP_HTML_Processor::create_full_parser`, `WP_HTML_Processor::create_fragment_at_current_node`, `WP_Abilities_Registry::register`, `WP_Abilities_Registry::unregister`, `WP_Abilities_Registry::get_registered`, `WP_Abilities_Registry::get_instance`, `WP_Ability_Categories_Registry::get_instance`, `WP_Ability_Categories_Registry::register`, `WP_Ability_Categories_Registry::unregister`, `WP_Ability_Categories_Registry::get_registered`, `WP_Ability::execute`, `WP_Ability_Category::__construct`, `WP_Ability::__construct`, `WP_Speculation_Rules::add_rule`, `WP_Block_Metadata_Registry::get_collection_block_metadata_files`, [`wp_unique_id_from_values`](https://chugunov.pro/api-wordpress/functions/wp_unique_id_from_values/), `WP_URL_Pattern_Prefixer::prefix_path_pattern`, `WP_Block_Metadata_Registry::register_collection`, `WP_Block_Templates_Registry::unregister`, `WP_Block_Templates_Registry::register`, `WP_Token_Map::from_precomputed_table`, `WP_Token_Map::from_array`, `WP_Block_Bindings_Registry::unregister`.

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