WordPress at Your Fingertips

doing_filter() WP 1.0

Retrieve the name of a filter currently being processed.

The function current_filter() only returns the most recent filter or action being executed. did_action() returns true once the action is initially processed.

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.

Used By: doing_action()
1 time — 0.000012 sec (very fast) | 50000 times — 0.01 sec (speed of light) | PHP 7.0.8, WP 4.5.3

No Hooks.

Return

true|false. Whether the filter is currently in the stack.

Usage

doing_filter( $hook_name );
$hook_name(null|string)
Filter hook to check.
Default: null, which checks if any filter is currently being run

Notes

Changelog

Since 3.9.0 Introduced.

Code of doing_filter() WP 5.8.1

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 );
}

Filters (hooks)

Hooks (actions, filters)

No comments
    Log In