Description
Adds hooks before loading WP.
Usage
$true = tests_add_filter( $tag, $function_to_add, $priority, $accepted_args );
Parameters
- $tag
- ( string ) required – The name of the filter to hook the $function_to_add callback to.
- $function_to_add
- ( callable ) required – The callback to be run when the filter is applied.
- $priority
- ( int ) optional default: 10 – Optional. Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. Default 10.
- $accepted_args
- ( int ) optional default: 1 – Optional. The number of arguments the function accepts. Default 1.
Returns
true
Source
File name: wordpress-develop-tests/phpunit/includes/functions.php
Lines:
1 to 16 of 16
function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { global $wp_filter; if ( function_exists( 'add_filter' ) ) { add_filter( $tag, $function_to_add, $priority, $accepted_args ); } else { $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority ); $wp_filter[ $tag ][ $priority ][ $idx ] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args, ); } return true; }