| 10 | | // check that we don't already have the same filter at the same priority |
|---|
| 11 | | if ( isset($wp_filter[$tag]["$priority"]) ) { |
|---|
| 12 | | foreach ( $wp_filter[$tag]["$priority"] as $filter ) { |
|---|
| 13 | | // uncomment if we want to match function AND accepted_args |
|---|
| 14 | | // if ( $filter == array($function, $accepted_args) ) { |
|---|
| 15 | | if ( $filter['function'] == $function_to_add ) |
|---|
| 16 | | return true; |
|---|
| 17 | | } |
|---|
| 18 | | } |
|---|
| 19 | | |
|---|
| 20 | | // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]'] |
|---|
| 21 | | $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args); |
|---|
| | 10 | // So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] |
|---|
| | 11 | $wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
|---|
| 37 | | foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { |
|---|
| 38 | | if ( !is_null($functions) ) { |
|---|
| 39 | | foreach ( (array) $functions as $function ) { |
|---|
| 40 | | $function_name = $function['function']; |
|---|
| 41 | | $accepted_args = $function['accepted_args']; |
|---|
| 42 | | $the_args = $args; |
|---|
| 43 | | array_unshift($the_args, $string); |
|---|
| 44 | | if ( $accepted_args > 0 ) |
|---|
| 45 | | $the_args = array_slice($the_args, 0, $accepted_args); |
|---|
| 46 | | elseif ( 0 == $accepted_args ) |
|---|
| 47 | | $the_args = NULL; |
|---|
| 48 | | $string = call_user_func_array($function_name, $the_args); |
|---|
| | 23 | $args = func_get_args(); |
|---|
| | 24 | |
|---|
| | 25 | do{ |
|---|
| | 26 | foreach( (array) current($wp_filter[$tag]) as $the_ ) |
|---|
| | 27 | if ( !is_null($the_['function']) ){ |
|---|
| | 28 | $args[1] = $string; |
|---|
| | 29 | $string = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); |
|---|
| 57 | | if ( isset($wp_filter['all']) ) { |
|---|
| 58 | | foreach ( (array) $wp_filter['all'] as $priority => $functions ) { |
|---|
| 59 | | if ( isset($wp_filter[$tag][$priority]) ) |
|---|
| 60 | | $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); |
|---|
| 61 | | else |
|---|
| 62 | | $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array()); |
|---|
| 63 | | $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]); |
|---|
| 64 | | } |
|---|
| | 39 | |
|---|
| | 40 | if ( isset($wp_filter['all']) ) |
|---|
| | 41 | $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); |
|---|
| | 42 | |
|---|
| | 43 | if ( isset($wp_filter[$tag]) ){ |
|---|
| | 44 | reset($wp_filter[$tag]); |
|---|
| | 45 | uksort($wp_filter[$tag], "strnatcasecmp"); |
|---|
| 110 | | foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { |
|---|
| 111 | | if ( !is_null($functions) ) { |
|---|
| 112 | | foreach ( (array) $functions as $function ) { |
|---|
| 113 | | $function_name = $function['function']; |
|---|
| 114 | | $accepted_args = $function['accepted_args']; |
|---|
| | 81 | do{ |
|---|
| | 82 | foreach( (array) current($wp_filter[$tag]) as $the_ ) |
|---|
| | 83 | if ( !is_null($the_['function']) ) |
|---|
| | 84 | call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); |
|---|
| 154 | | foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { |
|---|
| 155 | | if ( !is_null($functions) ) { |
|---|
| 156 | | foreach ( (array) $functions as $function ) { |
|---|
| 157 | | $function_name = $function['function']; |
|---|
| 158 | | $accepted_args = $function['accepted_args']; |
|---|
| 159 | | if ( $accepted_args > 0 ) |
|---|
| 160 | | $the_args = array_slice($args, 0, $accepted_args); |
|---|
| 161 | | elseif ( 0 == $accepted_args ) |
|---|
| 162 | | $the_args = NULL; |
|---|
| 163 | | else |
|---|
| 164 | | $the_args = $args; |
|---|
| | 114 | do{ |
|---|
| | 115 | foreach( (array) current($wp_filter[$tag]) as $the_ ) |
|---|
| | 116 | if ( !is_null($the_['function']) ) |
|---|
| | 117 | call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); |
|---|