has_filter

Check if any filter has been registered for a hook.

Description

(int|boolean) has_filter( (string) $tag, (constant) $function_to_check = false ); 

Returns (int|boolean)

Optionally returns the priority on that hook for the specified function.

Parameters (2)

0. $tag (string)
The name of the filter hook.
1. $function_to_check — Optional. (constant) => false
If specified, return the priority of that function on this hook or false if not attached.

Usage

  1. if ( !function_exists( 'has_filter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.plugin-api.php'; 
  3.  
  4. // The name of the filter hook. 
  5. $tag = ''; 
  6.  
  7. // optional. If specified, return the priority of that function on this hook or false if not attached. 
  8. $function_to_check = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = has_filter($tag, $function_to_check); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/backpress/functions.plugin-api.php  
  1. function has_filter($tag, $function_to_check = false) { 
  2. global $wp_filter; 
  3.  
  4. $has = !empty($wp_filter[$tag]); 
  5. if ( false === $function_to_check || false == $has ) 
  6. return $has; 
  7.  
  8. if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) ) 
  9. return false; 
  10.  
  11. foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) { 
  12. if ( isset($wp_filter[$tag][$priority][$idx]) ) 
  13. return $priority; 
  14.  
  15. return false;