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

git-svn-id: http://svn.automattic.com/wordpress/trunk@12090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-10-22 19:33:11 +00:00
parent 2c79c7c71f
commit 42eb1ba7ca
1 changed files with 22 additions and 16 deletions

View File

@ -675,24 +675,30 @@ function _wp_filter_build_unique_id($tag, $function, $priority) {
global $wp_filter; global $wp_filter;
static $filter_id_count = 0; static $filter_id_count = 0;
// If function then just skip all of the tests and not overwrite the following. if ( is_string($function) ) {
if ( is_string($function) )
return $function; return $function;
// Object Class Calling } else if (is_object($function[0]) ) {
else if (is_object($function[0]) ) { // Object Class Calling
$obj_idx = get_class($function[0]).$function[1]; if ( function_exists('spl_object_hash') ) {
if ( !isset($function[0]->wp_filter_id) ) { return spl_object_hash($function[0]) . $function[1];
if ( false === $priority ) } else {
return false; $obj_idx = get_class($function[0]).$function[1];
$obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0; if ( !isset($function[0]->wp_filter_id) ) {
$function[0]->wp_filter_id = $filter_id_count++; if ( false === $priority )
} else return false;
$obj_idx .= $function[0]->wp_filter_id; $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count;
return $obj_idx; $function[0]->wp_filter_id = $filter_id_count;
} ++$filter_id_count;
// Static Calling } else {
else if ( is_string($function[0]) ) $obj_idx .= $function[0]->wp_filter_id;
}
return $obj_idx;
}
} else if ( is_string($function[0]) ) {
// Static Calling
return $function[0].$function[1]; return $function[0].$function[1];
}
} }
?> ?>