Changeset 55025
- Timestamp:
- 01/02/2023 12:28:02 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/functions.php
r55023 r55025 38 38 * Adds hooks before loading WP. 39 39 * 40 * @since UT (3.7.0) 41 * 40 42 * @see add_filter() 41 * 42 * @param string $tag The name of the filter to hook the $function_to_add callback to. 43 * @param callable $function_to_add The callback to be run when the filter is applied. 44 * @param int $priority Optional. Used to specify the order in which the functions 45 * associated with a particular action are executed. 46 * Lower numbers correspond with earlier execution, 47 * and functions with the same priority are executed 48 * in the order in which they were added to the action. Default 10. 49 * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. 50 * @return true 51 */ 52 function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { 43 * @global WP_Hook[] $wp_filter A multidimensional array of all hooks and the callbacks hooked to them. 44 * 45 * @param string $hook_name The name of the filter to add the callback to. 46 * @param callable $callback The callback to be run when the filter is applied. 47 * @param int $priority Optional. Used to specify the order in which the functions 48 * associated with a particular action are executed. 49 * Lower numbers correspond with earlier execution, 50 * and functions with the same priority are executed 51 * in the order in which they were added to the action. Default 10. 52 * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. 53 * @return true Always returns true. 54 */ 55 function tests_add_filter( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { 53 56 global $wp_filter; 54 57 55 58 if ( function_exists( 'add_filter' ) ) { 56 add_filter( $ tag, $function_to_add, $priority, $accepted_args );59 add_filter( $hook_name, $callback, $priority, $accepted_args ); 57 60 } else { 58 $idx = _test_filter_build_unique_id( $ tag, $function_to_add, $priority );59 60 $wp_filter[ $ tag][ $priority ][ $idx ] = array(61 'function' => $ function_to_add,61 $idx = _test_filter_build_unique_id( $hook_name, $callback, $priority ); 62 63 $wp_filter[ $hook_name ][ $priority ][ $idx ] = array( 64 'function' => $callback, 62 65 'accepted_args' => $accepted_args, 63 66 ); 64 67 } 68 65 69 return true; 66 70 } … … 69 73 * Generates a unique function ID based on the given arguments. 70 74 * 75 * @since UT (3.7.0) 76 * 71 77 * @see _wp_filter_build_unique_id() 72 78 * 73 * @param string $tag Unused. The name of the filter to build ID for. 74 * @param callable $callback The function to generate ID for. 75 * @param int $priority Unused. The order in which the functions 76 * associated with a particular action are executed. 79 * @param string $hook_name Unused. The name of the filter to build ID for. 80 * @param callable|string|array $callback The callback to generate ID for. The callback may 81 * or may not exist. 82 * @param int $priority Unused. The order in which the functions 83 * associated with a particular action are executed. 77 84 * @return string Unique function ID for usage as array key. 78 85 */ 79 function _test_filter_build_unique_id( $ tag, $callback, $priority ) {86 function _test_filter_build_unique_id( $hook_name, $callback, $priority ) { 80 87 if ( is_string( $callback ) ) { 81 88 return $callback;
Note: See TracChangeset
for help on using the changeset viewer.