| 878 | | if (isset($wp_filter[$tag])) { |
|---|
| 879 | | foreach ($wp_filter[$tag] as $priority => $functions) { |
|---|
| 880 | | if (!is_null($functions)) { |
|---|
| 881 | | foreach($functions as $function) { |
|---|
| 882 | | $string = call_user_func_array($function, array($string) + $args); |
|---|
| | 878 | if (!isset($wp_filter[$tag])) { |
|---|
| | 879 | return $string; |
|---|
| | 880 | } |
|---|
| | 881 | foreach ($wp_filter[$tag] as $priority => $functions) { |
|---|
| | 882 | if (!is_null($functions)) { |
|---|
| | 883 | foreach($functions as $function) { |
|---|
| | 884 | |
|---|
| | 885 | $all_args = array_merge(array($string), $args); |
|---|
| | 886 | $function_name = $function['function']; |
|---|
| | 887 | $accepted_args = $function['accepted_args']; |
|---|
| | 888 | |
|---|
| | 889 | if($accepted_args == 1) { |
|---|
| | 890 | $args = array($string); |
|---|
| | 891 | } elseif ($accepted_args > 1) { |
|---|
| | 892 | $args = array_slice($all_args, 0, $accepted_args); |
|---|
| | 893 | } elseif($accepted_args == 0) { |
|---|
| | 894 | $args = NULL; |
|---|
| | 895 | } else { |
|---|
| | 896 | $args = $all_args; |
|---|
| 892 | | // So the format is wp_filter['tag']['array of priorities']['array of functions'] |
|---|
| 893 | | if (!@in_array($function_to_add, $wp_filter[$tag]["$priority"])) { |
|---|
| 894 | | $wp_filter[$tag]["$priority"][] = $function_to_add; |
|---|
| | 908 | |
|---|
| | 909 | // check that we don't already have the same filter at the same priority |
|---|
| | 910 | if (isset($wp_filter[$tag]["$priority"])) { |
|---|
| | 911 | foreach($wp_filter[$tag]["$priority"] as $filter) { |
|---|
| | 912 | // uncomment if we want to match function AND accepted_args |
|---|
| | 913 | //if ($filter == array($function, $accepted_args)) { |
|---|
| | 914 | if ($filter['function'] == $function_to_add) { |
|---|
| | 915 | return true; |
|---|
| | 916 | } |
|---|
| | 917 | } |
|---|
| 901 | | if (@in_array($function_to_remove, $wp_filter[$tag]["$priority"])) { |
|---|
| 902 | | foreach ($wp_filter[$tag]["$priority"] as $function) { |
|---|
| 903 | | if ($function_to_remove != $function) { |
|---|
| 904 | | $new_function_list[] = $function; |
|---|
| | 927 | |
|---|
| | 928 | // rebuild the list of filters |
|---|
| | 929 | if (isset($wp_filter[$tag]["$priority"])) { |
|---|
| | 930 | foreach($wp_filter[$tag]["$priority"] as $filter) { |
|---|
| | 931 | if ($filter['function'] != $function_to_remove) { |
|---|
| | 932 | $new_function_list[] = $filter; |
|---|
| 925 | | if (isset($wp_filter[$tag])) { |
|---|
| 926 | | foreach ($wp_filter[$tag] as $priority => $functions) { |
|---|
| 927 | | if (!is_null($functions)) { |
|---|
| 928 | | foreach($functions as $function) { |
|---|
| 929 | | $string = call_user_func_array($function, $args); |
|---|
| | 952 | if (!isset($wp_filter[$tag])) { |
|---|
| | 953 | return; |
|---|
| | 954 | } |
|---|
| | 955 | foreach ($wp_filter[$tag] as $priority => $functions) { |
|---|
| | 956 | if (!is_null($functions)) { |
|---|
| | 957 | foreach($functions as $function) { |
|---|
| | 958 | |
|---|
| | 959 | $all_args = array_merge(array($string), $args); |
|---|
| | 960 | $function_name = $function['function']; |
|---|
| | 961 | $accepted_args = $function['accepted_args']; |
|---|
| | 962 | |
|---|
| | 963 | if($accepted_args == 1) { |
|---|
| | 964 | $args = array($string); |
|---|
| | 965 | } elseif ($accepted_args > 1) { |
|---|
| | 966 | $args = array_slice($all_args, 0, $accepted_args); |
|---|
| | 967 | } elseif($accepted_args == 0) { |
|---|
| | 968 | $args = NULL; |
|---|
| | 969 | } else { |
|---|
| | 970 | $args = $all_args; |
|---|
| 936 | | function add_action($tag, $function_to_add, $priority = 10) { |
|---|
| 937 | | add_filter($tag, $function_to_add, $priority); |
|---|
| | 979 | function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { |
|---|
| | 980 | add_filter($tag, $function_to_add, $priority, $accepted_args); |
|---|
| 940 | | function remove_action($tag, $function_to_remove, $priority = 10) { |
|---|
| 941 | | remove_filter($tag, $function_to_remove, $priority); |
|---|
| | 983 | function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { |
|---|
| | 984 | remove_filter($tag, $function_to_remove, $priority, $accepted_args); |
|---|