Ticket #3875: wp2_2.plugins.php.diff

File wp2_2.plugins.php.diff, 1.9 kB (added by santosj, 1 year ago)

Working patch for WordPress 2.2.x branch. Code is similar.

  • plugin.php

    old new  
    1919        global $wp_filter, $merged_filters; 
    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; 
    2525} 
     
    9898 */ 
    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 
    105105        return true; 
     
    279279        add_action('deactivate_' . $file, $function); 
    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?>