apply_filters_ref_array

Execute functions hooked on a specific filter hook, specifying arguments in an array.

Description

apply_filters_ref_array( (string) $tag, (array) $args ); 

Parameters (2)

0. $tag (string)
The name of the filter hook.
1. $args (array)
The arguments supplied to the functions hooked to $tag.

Usage

  1. if ( !function_exists( 'apply_filters_ref_array' ) ) { 
  2. require_once ABSPATH . WPINC . '/plugin.php'; 
  3.  
  4. // The name of the filter hook. 
  5. $tag = ''; 
  6.  
  7. // The arguments supplied to the functions hooked to $tag. 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = apply_filters_ref_array($tag, $args); 
  12.  

Defined (1)

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

/wp-includes/plugin.php  
  1. function apply_filters_ref_array($tag, $args) { 
  2. global $wp_filter, $wp_current_filter; 
  3.  
  4. // Do 'all' actions first 
  5. if ( isset($wp_filter['all']) ) { 
  6. $wp_current_filter[] = $tag; 
  7. $all_args = func_get_args(); 
  8. _wp_call_all_hook($all_args); 
  9.  
  10. if ( !isset($wp_filter[$tag]) ) { 
  11. if ( isset($wp_filter['all']) ) 
  12. array_pop($wp_current_filter); 
  13. return $args[0]; 
  14.  
  15. if ( !isset($wp_filter['all']) ) 
  16. $wp_current_filter[] = $tag; 
  17.  
  18. $filtered = $wp_filter[ $tag ]->apply_filters( $args[0], $args ); 
  19.  
  20. array_pop( $wp_current_filter ); 
  21.  
  22. return $filtered;