WordPress.org

Make WordPress Core

Changeset 5936


Ignore:
Timestamp:
08/24/2007 02:18:08 PM (13 years ago)
Author:
ryan
Message:

Fix how wp_filter array is keyed. Props santosj/darkdragon. fixes #3875 for 2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r5924 r5936  
    2020
    2121    // 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);
    2325    unset( $merged_filters[ $tag ] );
    2426    return true;
     
    98100 */
    99101function 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);
    101103
    102104    $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
     
    282284}
    283285
     286function _wp_filter_build_unique_id($tag, $function, $priority = 10)
     287{
     288    global $wp_filter;
     289   
     290    // If function then just skip all of the tests and not overwrite the following.
     291    // Static Calling
     292    if( is_string($function) )
     293        return $function;
     294    // Object Class Calling
     295    else if(is_object($function[0]) )
     296    {
     297        $obj_idx = get_class($function[0]).$function[1];
     298        if( is_null($function[0]->wp_filter_id) ) {
     299            $count = count((array)$wp_filter[$tag][$priority]);
     300            $function[0]->wp_filter_id = $count;
     301            $obj_idx .= $count;
     302            unset($count);
     303        } else
     304            $obj_idx .= $function[0]->wp_filter_id;
     305        return $obj_idx;
     306    }
     307    else if( is_string($function[0]) )
     308        return $function[0].$function[1];
     309}
     310
    284311?>
Note: See TracChangeset for help on using the changeset viewer.