did_filter()WP 6.1.0

Retrieves the number of times a filter has been applied during the current request.

No Hooks.

Return

Int. The number of times the filter hook has been applied.

Usage

did_filter( $hook_name );
$hook_name(string) (required)
The name of the filter hook.

Notes

  • Global. Int[]. $wp_filters Stores the number of times each filter was triggered.

Changelog

Since 6.1.0 Introduced.

did_filter() code WP 6.5.2

function did_filter( $hook_name ) {
	global $wp_filters;

	if ( ! isset( $wp_filters[ $hook_name ] ) ) {
		return 0;
	}

	return $wp_filters[ $hook_name ];
}