Make WordPress Core

Changeset 6014


Ignore:
Timestamp:
09/03/2007 02:59:58 PM (19 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-includes/plugin.php

    r5928 r6014  
    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        $wp_filter[$tag][$priority][_wp_filter_build_unique_id($tag, $function_to_add, $priority)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
    2323        unset( $merged_filters[ $tag ] );
    2424        return true;
    … …  
    9999function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
    100100        global $wp_filter, $merged_filters;
    101 
    102         unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]);
     101       
     102        unset($GLOBALS['wp_filter'][$tag][$priority][_wp_filter_build_unique_id($tag, $function_to_remove, $priority)]);
    103103        unset( $merged_filters[ $tag ] );
    104104
    … …  
    280280}
    281281
     282function _wp_filter_build_unique_id($tag, $function, $priority = 10)
     283{
     284        global $wp_filter;
     285       
     286        // If function then just skip all of the tests and not overwrite the following.
     287        if( is_string($function) )
     288                return $function;
     289        // Object Class Calling
     290        else if(is_object($function[0]) )
     291        {
     292                $obj_idx = get_class($function[0]).$function[1];
     293                if( is_null($function[0]->wp_filter_id) ) {
     294                        $count = count((array)$wp_filter[$tag][$priority]);
     295                        $function[0]->wp_filter_id = $count;
     296                        $obj_idx .= $count;
     297                        unset($count);
     298                } else
     299                        $obj_idx .= $function[0]->wp_filter_id;
     300                return $obj_idx;
     301        }
     302        // Static Calling
     303        else if( is_string($function[0]) )
     304                return $function[0].$function[1];
     305}
     306
    282307?>
Note: See TracChangeset for help on using the changeset viewer.