From 481e505d490671a81987ac94a197f08929e928a5 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 7 May 2007 23:22:50 +0000 Subject: [PATCH] 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 --- wp-includes/plugin.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 76ea10a4e..c2bc9123a 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -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 $tag + * @return int The number of times action hook $tag is fired */ function did_action($tag) { global $wp_actions;