doing_filter()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
doing_filter( string|null $hook_name = null ): bool
Описание
Функция current_filter() возвращает только последний выполняемый фильтр.
did_filter() возвращает, сколько раз фильтр был применён в течение текущего запроса.
Эта функция позволяет определить любой фильтр, выполняемый в данный момент (независимо от того, является ли он последним сработавшим, в случае хуков, вызываемых из функций обратного вызова хуков).
См. alsocurrent_filter()
did_filter()
Оригинал (английский)
The function current_filter() only returns the most recent filter being executed.
did_filter() returns the number of times a filter has been applied during the current request.
This function allows detection for any filter currently being executed (regardless of whether it’s the most recent filter to fire, in the case of hooks called from hook callbacks) to be verified.
Параметры
$hook_name
string|null
необязательный
= null
Возвращаемое значение
bool
Исходный код
wp-includes/plugin.php:396
function doing_filter( $hook_name = null ) {
global $wp_current_filter;
if ( null === $hook_name ) {
return ! empty( $wp_current_filter );
}
return in_array( $hook_name, $wp_current_filter, true );
}
История изменений
| Версия | Описание |
|---|---|
| 3.9.0 | Introduced. |

