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
This commit is contained in:
parent
d8cb7841fb
commit
96c87298e8
|
@ -897,16 +897,16 @@ function apply_filters($tag, $string) {
|
||||||
$accepted_args = $function['accepted_args'];
|
$accepted_args = $function['accepted_args'];
|
||||||
|
|
||||||
if($accepted_args == 1) {
|
if($accepted_args == 1) {
|
||||||
$args = array($string);
|
$the_args = array($string);
|
||||||
} elseif ($accepted_args > 1) {
|
} 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) {
|
} elseif($accepted_args == 0) {
|
||||||
$args = NULL;
|
$the_args = NULL;
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -966,21 +966,23 @@ function do_action($tag, $arg = '') {
|
||||||
if (!is_null($functions)) {
|
if (!is_null($functions)) {
|
||||||
foreach($functions as $function) {
|
foreach($functions as $function) {
|
||||||
|
|
||||||
$all_args = array_merge(array($string), $args);
|
|
||||||
$function_name = $function['function'];
|
$function_name = $function['function'];
|
||||||
$accepted_args = $function['accepted_args'];
|
$accepted_args = $function['accepted_args'];
|
||||||
|
|
||||||
if($accepted_args == 1) {
|
if($accepted_args == 1) {
|
||||||
$args = array($string);
|
if ( is_array($arg) )
|
||||||
|
$the_args = $arg;
|
||||||
|
else
|
||||||
|
$the_args = array($arg);
|
||||||
} elseif ($accepted_args > 1) {
|
} elseif ($accepted_args > 1) {
|
||||||
$args = array_slice($all_args, 0, $accepted_args);
|
$the_args = array_slice($args, 0, $accepted_args);
|
||||||
} elseif($accepted_args == 0) {
|
} elseif($accepted_args == 0) {
|
||||||
$args = NULL;
|
$the_args = NULL;
|
||||||
} else {
|
} else {
|
||||||
$args = $all_args;
|
$the_args = $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
$string = call_user_func_array($function_name, $args);
|
$string = call_user_func_array($function_name, $the_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue