doing_filter
Retrieve the name of a filter currently being processed.
Description
doing_filter( (null) $filter = null );
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 (despite not being the most recent filter to fire, in the case of hooks called from hook callbacks) to be verified.
Parameters (1)
- 0. $filter — Optional. (null) =>
null
- Filter to check. Defaults to null, which checks if any filter is currently being run.
Usage
if ( !function_exists( 'doing_filter' ) ) { require_once ABSPATH . WPINC . '/plugin.php'; } // Optional. Filter to check. Defaults to null, which // checks if any filter is currently being run. $filter = null; // NOTICE! Understand what this does before running. $result = doing_filter($filter);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/plugin.php
- function doing_filter( $filter = null ) {
- global $wp_current_filter;
- if ( null === $filter ) {
- return ! empty( $wp_current_filter );
- }
- return in_array( $filter, $wp_current_filter );
- }