Tests: Use add_filter()
when it's available.
The `tests_add_filter()` helper function directly manipulates the `$wp_filter` global, instead of using `add_filter()`. We can use `add_filter()` when it's available, and fall back to manipulating `$wp_filter` when it isn't, relying on the `$wp_filter` bootstrap code at the top of `plugin.php` to handle conversion. Props boonebgorges, dd32 and pento: WordPress Thought Leadership Triumvirate. Fixes #17817. git-svn-id: https://develop.svn.wordpress.org/trunk@38582 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bafd8c92f2
commit
40ebbc7713
@ -23,8 +23,12 @@ function tests_reset__SERVER() {
|
||||
function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
|
||||
global $wp_filter;
|
||||
|
||||
$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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user