Ticket #3875: wp-includes.plugin.php.2.diff
File wp-includes.plugin.php.2.diff, 2.4 KB (added by , 16 years ago) |
---|
-
plugin.php
19 19 global $wp_filter, $merged_filters; 20 20 21 21 // So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] 22 $wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 22 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); 23 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 24 //$wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 23 25 unset( $merged_filters[ $tag ] ); 24 26 return true; 25 27 } … … 97 99 * @return boolean Whether the function is removed. 98 100 */ 99 101 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { 100 $function_to_remove = serialize($function_to_remove);102 $function_to_remove = _wp_filter_build_unique_id($tag, &$function_to_remove, $priority); 101 103 102 104 $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); 103 105 … … 280 282 add_action('deactivate_' . $file, $function); 281 283 } 282 284 285 function _wp_filter_build_unique_id($tag, $function, $priority = 10) 286 { 287 global $wp_filter; 288 289 // If function then just skip all of the tests and not overwrite the following. 290 if(is_string($function)) 291 return $function; 292 293 $fn_idx = ''; 294 295 // Only test if using an array to call a class and method. 296 // Else bypass all of the following checks. 297 if(is_array($function)) 298 { 299 // Expect most use cases for $obj to be objects and not strings 300 if(is_object($function[0])) 301 { 302 // We are going to use $classname more than once, store it 303 $classname = get_class($function[0]); 304 $fn_idx = $classname.$function[1]; 305 306 if(true === array_key_exists('wp_filter_id', get_object_vars($function[0]))) 307 { 308 $fn_idx .= $function[0]->wp_filter_id; 309 } 310 else 311 { 312 if(isset($wp_filter[$tag])) 313 $i = count($wp_filter[$tag][$priority]); 314 else 315 $i = 0; 316 $function[0]->wp_filter_id = $i; 317 $fn_idx .= $function[0]->wp_filter_id; 318 } 319 } 320 // Must mean that it is using static calling. 321 else 322 $fn_idx = $function[0].$function[1]; 323 } 324 return $fn_idx; 325 } 326 283 327 ?>