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 . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.plugin-api.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).

/bp-forums/bbpress/bb-includes/backpress/functions.plugin-api.php  
  1. function apply_filters_ref_array($tag, $args) { 
  2. global $wp_filter, $merged_filters, $wp_current_filter; 
  3.  
  4. $wp_current_filter[] = $tag; 
  5.  
  6. // Do 'all' actions first 
  7. if ( isset($wp_filter['all']) ) { 
  8. $all_args = func_get_args(); 
  9. _wp_call_all_hook($all_args); 
  10.  
  11. if ( !isset($wp_filter[$tag]) ) { 
  12. array_pop($wp_current_filter); 
  13. return $args[0]; 
  14.  
  15. // Sort 
  16. if ( !isset( $merged_filters[ $tag ] ) ) { 
  17. ksort($wp_filter[$tag]); 
  18. $merged_filters[ $tag ] = true; 
  19.  
  20. reset( $wp_filter[ $tag ] ); 
  21.  
  22. do { 
  23. foreach( (array) current($wp_filter[$tag]) as $the_ ) 
  24. if ( !is_null($the_['function']) ) 
  25. $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 
  26.  
  27. } while ( next($wp_filter[$tag]) !== false ); 
  28.  
  29. array_pop( $wp_current_filter ); 
  30.  
  31. return $args[0];