Fix did_action to properly account for actions that have no callbacks attached.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-05-07 23:22:50 +00:00
parent ef4ad331e1
commit 481e505d49
1 changed files with 7 additions and 6 deletions

View File

@ -138,6 +138,11 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions;
if ( is_array($wp_actions) )
$wp_actions[] = $tag;
else
$wp_actions = array($tag);
$args = array();
if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
$args[] =& $arg[0];
@ -158,16 +163,12 @@ function do_action($tag, $arg = '') {
} while ( next($wp_filter[$tag]) );
if ( is_array($wp_actions) )
$wp_actions[] = $tag;
else
$wp_actions = array($tag);
}
/**
* Return the number of functions hooked to a specific action hook.
* Return the number times an action is fired.
* @param string $tag The name of the action hook.
* @return int The number of functions hooked to action hook <tt>$tag</tt>
* @return int The number of times action hook <tt>$tag</tt> is fired
*/
function did_action($tag) {
global $wp_actions;