Ticket #3116: 3116c.diff
| File 3116c.diff, 2.2 kB (added by mdawaffe, 2 years ago) |
|---|
-
wp-includes/plugin.php
old new 26 26 function apply_filters($tag, $string) { 27 27 global $wp_filter; 28 28 29 $args = array_slice(func_get_args(), 2); 29 $args = array($string); 30 for ( $a = 2; $a < func_num_args(); $a++ ) 31 $args[] = func_get_arg($a); 30 32 31 33 merge_filters($tag); 32 34 … … 37 39 if ( !is_null($functions) ) { 38 40 foreach($functions as $function) { 39 41 40 $all_args = array_merge(array($string), $args);41 42 $function_name = $function['function']; 42 43 $accepted_args = $function['accepted_args']; 43 44 44 if ( $accepted_args == 1 ) 45 $the_args = array($string); 46 elseif ( $accepted_args > 1 ) 47 $the_args = array_slice($all_args, 0, $accepted_args); 45 if ( $accepted_args > 0 ) 46 $the_args = array_slice($args, 0, $accepted_args); 48 47 elseif ( $accepted_args == 0 ) 49 48 $the_args = NULL; 50 49 else 51 $the_args = $a ll_args;50 $the_args = $args; 52 51 53 52 $string = call_user_func_array($function_name, $the_args); 54 53 } … … 102 101 103 102 function do_action($tag, $arg = '') { 104 103 global $wp_filter; 105 $ extra_args = array_slice(func_get_args(), 2);106 if ( is_array($arg))107 $args = array_merge($arg, $extra_args);104 $args = array(); 105 if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this) 106 $args[] =& $arg[0]; 108 107 else 109 $args = array_merge(array($arg), $extra_args); 108 $args[] = $arg; 109 for ( $a = 2; $a < func_num_args(); $a++ ) 110 $args[] = func_get_arg($a); 110 111 111 112 merge_filters($tag); 112 113 … … 120 121 $function_name = $function['function']; 121 122 $accepted_args = $function['accepted_args']; 122 123 123 if ( $accepted_args == 1 ) { 124 if ( is_array($arg) ) 125 $the_args = $arg; 126 else 127 $the_args = array($arg); 128 } elseif ( $accepted_args > 1 ) { 124 if ( $accepted_args > 0 ) 129 125 $the_args = array_slice($args, 0, $accepted_args); 130 } elseif ( $accepted_args == 0 ) {126 elseif ( $accepted_args == 0 ) 131 127 $the_args = NULL; 132 } else {128 else 133 129 $the_args = $args; 134 }135 130 136 131 $string = call_user_func_array($function_name, $the_args); 137 132 }
