Make WordPress Core

Changeset 12090


Ignore:
Timestamp:
10/22/2009 07:33:11 PM (17 years ago)
Author:
westi
Message:

Improve _wp_filter_build_unique_id to give more consistent behaviour and make filter removal reliable for class based filters. Fixes #10535 props dd32.

File:
1 edited

Legend:

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

    r11617 r12090  
    676676        static $filter_id_count = 0;
    677677
    678         // If function then just skip all of the tests and not overwrite the following.
    679         if ( is_string($function) )
     678        if ( is_string($function) ) {
    680679                return $function;
    681         // Object Class Calling
    682         else if (is_object($function[0]) ) {
    683                 $obj_idx = get_class($function[0]).$function[1];
    684                 if ( !isset($function[0]->wp_filter_id) ) {
    685                         if ( false === $priority )
    686                                 return false;
    687                         $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
    688                         $function[0]->wp_filter_id = $filter_id_count++;
    689                 } else
    690                         $obj_idx .= $function[0]->wp_filter_id;
    691                 return $obj_idx;
    692         }
    693         // Static Calling
    694         else if ( is_string($function[0]) )
     680        } else if (is_object($function[0]) ) {
     681                // Object Class Calling
     682                if ( function_exists('spl_object_hash') ) {
     683                        return spl_object_hash($function[0]) . $function[1];
     684                } else {
     685                        $obj_idx = get_class($function[0]).$function[1];
     686                        if ( !isset($function[0]->wp_filter_id) ) {
     687                                if ( false === $priority )
     688                                        return false;
     689                                $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count;
     690                                $function[0]->wp_filter_id = $filter_id_count;
     691                                ++$filter_id_count;
     692                        } else {
     693                                $obj_idx .= $function[0]->wp_filter_id;
     694                        }
     695       
     696                        return $obj_idx;
     697                }
     698        } else if ( is_string($function[0]) ) {
     699                // Static Calling
    695700                return $function[0].$function[1];
     701        }
    696702}
    697703
Note: See TracChangeset for help on using the changeset viewer.