Ticket #58291: 58291.2.patch
File 58291.2.patch, 6.2 KB (added by , 21 months ago) |
---|
-
src/wp-includes/class-wp-hook.php
72 72 * @param int $accepted_args The number of arguments the function accepts. 73 73 */ 74 74 public function add_filter( $hook_name, $callback, $priority, $accepted_args ) { 75 $idx = _wp_filter_build_unique_id( $hook_name, $callback, $priority);75 $idx = self::build_unique_id( $callback ); 76 76 77 if ( ! $idx ) { 78 return false; 79 } 80 77 81 $priority_existed = isset( $this->callbacks[ $priority ] ); 78 82 79 83 $this->callbacks[ $priority ][ $idx ] = array( … … 177 181 * @return bool Whether the callback existed before it was removed. 178 182 */ 179 183 public function remove_filter( $hook_name, $callback, $priority ) { 180 $function_key = _wp_filter_build_unique_id( $hook_name, $callback, $priority);184 $function_key = self::build_unique_id( $callback ); 181 185 182 186 $exists = isset( $this->callbacks[ $priority ][ $function_key ] ); 183 187 … … 217 221 return $this->has_filters(); 218 222 } 219 223 220 $function_key = _wp_filter_build_unique_id( $hook_name, $callback, false);224 $function_key = self::build_unique_id( $callback ); 221 225 222 226 if ( ! $function_key ) { 223 227 return false; … … 433 437 } 434 438 435 439 /** 440 * Builds a unique string ID for a hook callback function. 441 * 442 * Functions and static method callbacks are just returned as strings and 443 * shouldn't have any speed penalty. 444 * 445 * @since 6.3.0 446 * 447 * @param string $hook_name Unused. The name of the filter to build ID for. 448 * @param callable|string|array $callback The callback to generate ID for. The callback may 449 * or may not exist. 450 * @param int $priority Unused. The order in which the functions 451 * associated with a particular action are executed. 452 * @return string Unique function ID for usage as array key. 453 */ 454 private static function build_unique_id( $callback ) { 455 if ( is_string( $callback ) ) { 456 return $callback; 457 } 458 459 if ( is_object( $callback ) ) { 460 return spl_object_id( $callback ); 461 } 462 463 $callback = (array) $callback; 464 465 if ( is_object( $callback[0] ) ) { 466 // Object class calling. 467 return spl_object_id( $callback[0] ) . $callback[1]; 468 } elseif ( is_string( $callback[0] ) ) { 469 // Static calling. 470 return $callback[0] . $callback[1]; 471 } 472 } 473 474 /** 436 475 * Determines whether an offset value exists. 437 476 * 438 477 * @since 4.7.0 -
src/wp-includes/deprecated.php
4639 4639 function wlwmanifest_link() { 4640 4640 _deprecated_function( __FUNCTION__, '6.3.0' ); 4641 4641 } 4642 4643 /** 4644 * Builds a unique string ID for a hook callback function. 4645 * 4646 * Functions and static method callbacks are just returned as strings and 4647 * shouldn't have any speed penalty. 4648 * 4649 * @link https://core.trac.wordpress.org/ticket/3875 4650 * 4651 * @since 2.2.3 4652 * @since 5.3.0 Removed workarounds for spl_object_hash(). 4653 * `$hook_name` and `$priority` are no longer used, 4654 * and the function always returns a string. 4655 * @deprecated 6.3.0 4656 * 4657 * @access private 4658 * 4659 * @param string $hook_name Unused. The name of the filter to build ID for. 4660 * @param callable|string|array $callback The callback to generate ID for. The callback may 4661 * or may not exist. 4662 * @param int $priority Unused. The order in which the functions 4663 * associated with a particular action are executed. 4664 * @return string Unique function ID for usage as array key. 4665 */ 4666 function _wp_filter_build_unique_id( $hook_name, $callback, $priority ) { 4667 _deprecated_function( __FUNCTION__, '6.3.0' ); 4668 4669 if ( is_string( $callback ) ) { 4670 return $callback; 4671 } 4672 4673 if ( is_object( $callback ) ) { 4674 // Closures are currently implemented as objects. 4675 $callback = array( $callback, '' ); 4676 } else { 4677 $callback = (array) $callback; 4678 } 4679 4680 if ( is_object( $callback[0] ) ) { 4681 // Object class calling. 4682 return spl_object_hash( $callback[0] ) . $callback[1]; 4683 } elseif ( is_string( $callback[0] ) ) { 4684 // Static calling. 4685 return $callback[0] . '::' . $callback[1]; 4686 } 4687 } -
src/wp-includes/plugin.php
962 962 963 963 $wp_filter['all']->do_all_hook( $args ); 964 964 } 965 966 /**967 * Builds a unique string ID for a hook callback function.968 *969 * Functions and static method callbacks are just returned as strings and970 * shouldn't have any speed penalty.971 *972 * @link https://core.trac.wordpress.org/ticket/3875973 *974 * @since 2.2.3975 * @since 5.3.0 Removed workarounds for spl_object_hash().976 * `$hook_name` and `$priority` are no longer used,977 * and the function always returns a string.978 *979 * @access private980 *981 * @param string $hook_name Unused. The name of the filter to build ID for.982 * @param callable|string|array $callback The callback to generate ID for. The callback may983 * or may not exist.984 * @param int $priority Unused. The order in which the functions985 * associated with a particular action are executed.986 * @return string Unique function ID for usage as array key.987 */988 function _wp_filter_build_unique_id( $hook_name, $callback, $priority ) {989 if ( is_string( $callback ) ) {990 return $callback;991 }992 993 if ( is_object( $callback ) ) {994 // Closures are currently implemented as objects.995 $callback = array( $callback, '' );996 } else {997 $callback = (array) $callback;998 }999 1000 if ( is_object( $callback[0] ) ) {1001 // Object class calling.1002 return spl_object_hash( $callback[0] ) . $callback[1];1003 } elseif ( is_string( $callback[0] ) ) {1004 // Static calling.1005 return $callback[0] . '::' . $callback[1];1006 }1007 }