Changeset 46801 for trunk/tests/phpunit/includes/functions.php
- Timestamp:
- 11/29/2019 09:40:58 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.