From 96c87298e8b1efa8d501e43d552b153263fac298 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 11 Mar 2005 00:57:34 +0000 Subject: [PATCH] Fix do_action arg handling. http://mosquito.wordpress.org/view.php?id=901 git-svn-id: https://develop.svn.wordpress.org/trunk@2430 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 38344d1c42..2e76f50bdc 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -897,16 +897,16 @@ function apply_filters($tag, $string) { $accepted_args = $function['accepted_args']; if($accepted_args == 1) { - $args = array($string); + $the_args = array($string); } elseif ($accepted_args > 1) { - $args = array_slice($all_args, 0, $accepted_args); + $the_args = array_slice($all_args, 0, $accepted_args); } elseif($accepted_args == 0) { - $args = NULL; + $the_args = NULL; } else { - $args = $all_args; + $the_args = $all_args; } - $string = call_user_func_array($function_name, $args); + $string = call_user_func_array($function_name, $the_args); } } } @@ -952,8 +952,8 @@ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args function do_action($tag, $arg = '') { global $wp_filter; $extra_args = array_slice(func_get_args(), 2); - if ( is_array($arg) ) - $args = array_merge($arg, $extra_args); + if ( is_array($arg) ) + $args = array_merge($arg, $extra_args); else $args = array_merge(array($arg), $extra_args); @@ -966,21 +966,23 @@ function do_action($tag, $arg = '') { if (!is_null($functions)) { foreach($functions as $function) { - $all_args = array_merge(array($string), $args); $function_name = $function['function']; $accepted_args = $function['accepted_args']; if($accepted_args == 1) { - $args = array($string); + if ( is_array($arg) ) + $the_args = $arg; + else + $the_args = array($arg); } elseif ($accepted_args > 1) { - $args = array_slice($all_args, 0, $accepted_args); + $the_args = array_slice($args, 0, $accepted_args); } elseif($accepted_args == 0) { - $args = NULL; + $the_args = NULL; } else { - $args = $all_args; + $the_args = $args; } - $string = call_user_func_array($function_name, $args); + $string = call_user_func_array($function_name, $the_args); } } }