do_action_ref_array

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

Description

(null) do_action_ref_array( (string) $tag, (array) $args ); 

Returns (null)

Will return null if $tag does not exist in $wp_filter array

Parameters (2)

0. $tag (string)
The name of the action to be executed.
1. $args (array)
The arguments supplied to the functions hooked to $tag

Usage

  1. if ( !function_exists( 'do_action_ref_array' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.plugin-api.php'; 
  3.  
  4. // The name of the action to be executed. 
  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 = do_action_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 do_action_ref_array($tag, $args) { 
  2. global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 
  3.  
  4. if ( ! isset($wp_actions) ) 
  5. $wp_actions = array(); 
  6.  
  7. if ( ! isset($wp_actions[$tag]) ) 
  8. $wp_actions[$tag] = 1; 
  9. else 
  10. ++$wp_actions[$tag]; 
  11.  
  12. $wp_current_filter[] = $tag; 
  13.  
  14. // Do 'all' actions first 
  15. if ( isset($wp_filter['all']) ) { 
  16. $all_args = func_get_args(); 
  17. _wp_call_all_hook($all_args); 
  18.  
  19. if ( !isset($wp_filter[$tag]) ) { 
  20. array_pop($wp_current_filter); 
  21. return; 
  22.  
  23. // Sort 
  24. if ( !isset( $merged_filters[ $tag ] ) ) { 
  25. ksort($wp_filter[$tag]); 
  26. $merged_filters[ $tag ] = true; 
  27.  
  28. reset( $wp_filter[ $tag ] ); 
  29.  
  30. do { 
  31. foreach( (array) current($wp_filter[$tag]) as $the_ ) 
  32. if ( !is_null($the_['function']) ) 
  33. call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 
  34.  
  35. } while ( next($wp_filter[$tag]) !== false ); 
  36.  
  37. array_pop($wp_current_filter);