Changeset 46801
- Timestamp:
- 11/29/2019 09:40:58 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-hook.php
r46586 r46801 65 65 * @param string $tag The name of the filter to hook the $function_to_add callback to. 66 66 * @param callable $function_to_add The callback to be run when the filter is applied. 67 * @param int $priority The order in which the functions associated with a 68 * particular action are executed. Lower numbers correspond with69 * earlier execution, and functions with the same priority are executed70 * in the order inwhich they were added to the action.67 * @param int $priority The order in which the functions associated with a particular action 68 * are executed. Lower numbers correspond with earlier execution, 69 * and functions with the same priority are executed in the order 70 * in which they were added to the action. 71 71 * @param int $accepted_args The number of arguments the function accepts. 72 72 */ 73 73 public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) { 74 $idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority ); 74 $idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority ); 75 75 76 $priority_existed = isset( $this->callbacks[ $priority ] ); 76 77 … … 163 164 * @since 4.7.0 164 165 * 165 * @param string $tag The filter hook to which the function to be removed is hooked. Used 166 * for building the callback ID when SPL is not available. 166 * @param string $tag The filter hook to which the function to be removed is hooked. 167 167 * @param callable $function_to_remove The callback to be removed from running when the filter is applied. 168 168 * @param int $priority The exact priority used when adding the original filter callback. … … 190 190 * @since 4.7.0 191 191 * 192 * @param string $tag Optional. The name of the filter hook. Used for building 193 * the callback ID when SPL is not available. Default empty. 192 * @param string $tag Optional. The name of the filter hook. Default empty. 194 193 * @param callable|bool $function_to_check Optional. The callback to check for. Default false. 195 194 * @return bool|int The priority of that hook is returned, or false if the function is not attached. -
trunk/src/wp-includes/plugin.php
r46792 r46801 94 94 * @since 0.71 95 95 * 96 * @global array $wp_filter 96 * @global array $wp_filter A multidimensional array of all hooks and the callbacks hooked to them. 97 97 * 98 98 * @param string $tag The name of the filter to hook the $function_to_add callback to. 99 99 * @param callable $function_to_add The callback to be run when the filter is applied. 100 100 * @param int $priority Optional. Used to specify the order in which the functions 101 * associated with a particular action are executed. Default 10.101 * associated with a particular action are executed. 102 102 * Lower numbers correspond with earlier execution, 103 103 * and functions with the same priority are executed 104 * in the order in which they were added to the action. 104 * in the order in which they were added to the action. Default 10. 105 105 * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. 106 106 * @return true … … 120 120 * @since 2.5.0 121 121 * 122 * @global array $wp_filter Stores all of the filters .122 * @global array $wp_filter Stores all of the filters and actions. 123 123 * 124 124 * @param string $tag The name of the filter hook. … … 171 171 * @since 0.71 172 172 * 173 * @global array $wp_filter Stores all of the filters .173 * @global array $wp_filter Stores all of the filters and actions. 174 174 * @global array $wp_current_filter Stores the list of current filters with the current one last. 175 175 * … … 219 219 * functions hooked to `$tag` are supplied using an array. 220 220 * 221 * @global array $wp_filter Stores all of the filters 222 * @global array $wp_current_filter Stores the list of current filters with the current one last 221 * @global array $wp_filter Stores all of the filters and actions. 222 * @global array $wp_current_filter Stores the list of current filters with the current one last. 223 223 * 224 224 * @param string $tag The name of the filter hook. … … 267 267 * @since 1.2.0 268 268 * 269 * @global array $wp_filter Stores all of the filters269 * @global array $wp_filter Stores all of the filters and actions. 270 270 * 271 271 * @param string $tag The filter hook to which the function to be removed is hooked. … … 293 293 * @since 2.7.0 294 294 * 295 * @global array $wp_filter Stores all of the filters295 * @global array $wp_filter Stores all of the filters and actions. 296 296 * 297 297 * @param string $tag The filter to remove hooks from. … … 434 434 * by adding it to the function signature. 435 435 * 436 * @global array $wp_filter Stores all of the filters 436 * @global array $wp_filter Stores all of the filters and actions. 437 437 * @global array $wp_actions Increments the amount of times action was triggered. 438 * @global array $wp_current_filter Stores the list of current filters with the current one last 438 * @global array $wp_current_filter Stores the list of current filters with the current one last. 439 439 * 440 440 * @param string $tag The name of the action to be executed. … … 508 508 * @see do_action() This function is identical, but the arguments passed to the 509 509 * functions hooked to `$tag` are supplied using an array. 510 * @global array $wp_filter Stores all of the filters 510 * @global array $wp_filter Stores all of the filters and actions. 511 511 * @global array $wp_actions Increments the amount of times action was triggered. 512 * @global array $wp_current_filter Stores the list of current filters with the current one last 512 * @global array $wp_current_filter Stores the list of current filters with the current one last. 513 513 * 514 514 * @param string $tag The name of the action to be executed. … … 868 868 * @access private 869 869 * 870 * @global array $wp_filter Stores all of the filters870 * @global array $wp_filter Stores all of the filters and actions. 871 871 * 872 872 * @param array $args The collected parameters from the hook that was called. … … 898 898 * 899 899 * @since 2.2.3 900 * @since 5.3.0 Removed workarounds for spl_object_hash(). 901 * `$tag` and `$priority` are no longer used, 902 * and the function always returns a string. 900 903 * @access private 901 904 * 902 * @global array $wp_filter Stor age forall of the filters and actions.905 * @global array $wp_filter Stores all of the filters and actions. 903 906 * @staticvar int $filter_id_count 904 907 * 905 * @param string $tag Used in counting how many hooks were applied 906 * @param callable $function Used for creating unique id 907 * @param int|bool $priority Used in counting how many hooks were applied. If === false 908 * and $function is an object reference, we return the unique 909 * id only if it already has one, false otherwise. 910 * @return string|false Unique ID for usage as array key or false if $priority === false 911 * and $function is an object reference, and it does not already have 912 * a unique id. 908 * @param string $tag Unused. The name of the filter to build ID for. 909 * @param callable $function The function to generate ID for. 910 * @param int $priority Unused. The order in which the functions associated 911 * with a particular action are executed. 912 * @return string Unique ID for usage as array key. 913 913 */ 914 914 function _wp_filter_build_unique_id( $tag, $function, $priority ) { … … 921 921 922 922 if ( is_object( $function ) ) { 923 // Closures are currently implemented as objects 923 // Closures are currently implemented as objects. 924 924 $function = array( $function, '' ); 925 925 } else { … … 928 928 929 929 if ( is_object( $function[0] ) ) { 930 // Object Class Calling930 // Object class calling. 931 931 return spl_object_hash( $function[0] ) . $function[1]; 932 932 } elseif ( is_string( $function[0] ) ) { 933 // Static Calling933 // Static calling. 934 934 return $function[0] . '::' . $function[1]; 935 935 } -
trunk/tests/phpunit/includes/functions.php
r46586 r46801 39 39 * Adds hooks before loading WP. 40 40 * 41 * @param string $tag The name for the filter to add. 42 * @param object|array $function_to_add The function/callback to execute on call. 43 * @param int $priority The priority. 44 * @param int $accepted_args The amount of accepted arguments. 45 * @return bool Always true. 41 * @see add_filter() 42 * 43 * @param string $tag The name of the filter to hook the $function_to_add callback to. 44 * @param callable $function_to_add The callback to be run when the filter is applied. 45 * @param int $priority Optional. Used to specify the order in which the functions 46 * associated with a particular action are executed. 47 * Lower numbers correspond with earlier execution, 48 * and functions with the same priority are executed 49 * in the order in which they were added to the action. Default 10. 50 * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. 51 * @return true 46 52 */ 47 53 function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { … … 51 57 add_filter( $tag, $function_to_add, $priority, $accepted_args ); 52 58 } else { 53 $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority ); 59 $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority ); 60 54 61 $wp_filter[ $tag ][ $priority ][ $idx ] = array( 55 62 'function' => $function_to_add, … … 63 70 * Generates a unique function ID based on the given arguments. 64 71 * 65 * @param string $tag Unused. The name of the filter to build ID for. 66 * @param object|array $function The function to generate ID for. 67 * @param int $priority Unused. The priority. 68 * @return string Unique function ID. 72 * @see _wp_filter_build_unique_id() 73 * 74 * @param string $tag Unused. The name of the filter to build ID for. 75 * @param callable $function The function to generate ID for. 76 * @param int $priority Unused. The order in which the functions 77 * associated with a particular action are executed. 78 * @return string Unique function ID for usage as array key. 69 79 */ 70 80 function _test_filter_build_unique_id( $tag, $function, $priority ) { … … 81 91 82 92 if ( is_object( $function[0] ) ) { 93 // Object class calling. 83 94 return spl_object_hash( $function[0] ) . $function[1]; 84 95 } elseif ( is_string( $function[0] ) ) { 85 // Static Calling.96 // Static calling. 86 97 return $function[0] . $function[1]; 87 98 }
Note: See TracChangeset
for help on using the changeset viewer.