do_action_ref_array

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

Description

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

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 . WPINC . '/plugin.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 (2)

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

/wp-includes/plugin.php  
  1. function do_action_ref_array($tag, $args) { 
  2. global $wp_filter, $wp_actions, $wp_current_filter; 
  3.  
  4. if ( ! isset($wp_actions[$tag]) ) 
  5. $wp_actions[$tag] = 1; 
  6. else 
  7. ++$wp_actions[$tag]; 
  8.  
  9. // Do 'all' actions first 
  10. if ( isset($wp_filter['all']) ) { 
  11. $wp_current_filter[] = $tag; 
  12. $all_args = func_get_args(); 
  13. _wp_call_all_hook($all_args); 
  14.  
  15. if ( !isset($wp_filter[$tag]) ) { 
  16. if ( isset($wp_filter['all']) ) 
  17. array_pop($wp_current_filter); 
  18. return; 
  19.  
  20. if ( !isset($wp_filter['all']) ) 
  21. $wp_current_filter[] = $tag; 
  22.  
  23. $wp_filter[ $tag ]->do_action( $args ); 
  24.  
  25. array_pop($wp_current_filter); 
/wp-admin/includes/noop.php  
  1. function do_action_ref_array() {}