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

  1. if ( !function_exists( 'doing_filter' ) ) { 
  2. require_once ABSPATH . WPINC . '/plugin.php'; 
  3.  
  4. // Optional. Filter to check. Defaults to null, which 
  5. // checks if any filter is currently being run. 
  6. $filter = null; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = doing_filter($filter); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/plugin.php  
  1. function doing_filter( $filter = null ) { 
  2. global $wp_current_filter; 
  3.  
  4. if ( null === $filter ) { 
  5. return ! empty( $wp_current_filter ); 
  6.  
  7. return in_array( $filter, $wp_current_filter );