diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 2f7d4004a..0588bc9ac 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -665,13 +665,14 @@ function _wp_call_all_hook($args) { * * @global array $wp_filter Storage for all of the filters and actions * @param string $tag Used in counting how many hooks were applied - * @param string|array $function Used for creating unique id + * @param callback $function Used for creating unique id * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. * @param string $type filter or action - * @return string Unique ID for usage as array key + * @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a uniqe id. */ function _wp_filter_build_unique_id($tag, $function, $priority) { global $wp_filter; + static $filter_id_count = 0; // If function then just skip all of the tests and not overwrite the following. if ( is_string($function) ) @@ -682,10 +683,8 @@ function _wp_filter_build_unique_id($tag, $function, $priority) { if ( !isset($function[0]->wp_filter_id) ) { if ( false === $priority ) return false; - $count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0; - $function[0]->wp_filter_id = $count; - $obj_idx .= $count; - unset($count); + $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0; + $function[0]->wp_filter_id = $filter_id_count++; } else $obj_idx .= $function[0]->wp_filter_id; return $obj_idx;