do_action_ref_array

Definition:
function do_action_ref_array($tag, $args) {}

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

Parameters

  • string $tag: The name of the action to be executed.
  • array $args: The arguments supplied to the functions hooked to <tt>$tag</tt>

Return values

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

Source code

function do_action_ref_array($tag, $args) {

	global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;



	if ( ! isset($wp_actions) )

		$wp_actions = array();



	if ( ! isset($wp_actions[$tag]) )

		$wp_actions[$tag] = 1;

	else

		++$wp_actions[$tag];



	// Do 'all' actions first

	if ( isset($wp_filter['all']) ) {

		$wp_current_filter[] = $tag;

		$all_args = func_get_args();

		_wp_call_all_hook($all_args);

	}



	if ( !isset($wp_filter[$tag]) ) {

		if ( isset($wp_filter['all']) )

			array_pop($wp_current_filter);

		return;

	}



	if ( !isset($wp_filter['all']) )

		$wp_current_filter[] = $tag;



	// Sort

	if ( !isset( $merged_filters[ $tag ] ) ) {

		ksort($wp_filter[$tag]);

		$merged_filters[ $tag ] = true;

	}



	reset( $wp_filter[ $tag ] );



	do {

		foreach( (array) current($wp_filter[$tag]) as $the_ )

			if ( !is_null($the_['function']) )

				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));



	} while ( next($wp_filter[$tag]) !== false );



	array_pop($wp_current_filter);

}

944

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: