tribe_suspending_filter( string $filter_tag, callable $filter_callback, callable $do, int $args = 1 )
Runs a callbacks while suspending, removing and re-adding, a filter or action.
Contents
The function will infer the priority of the filter, required for its correct detachment and re-attachment, on its own.
Parameters
- $filter_tag
-
(string) (Required) The filter tag to suspend.
- $filter_callback
-
(callable) (Required) The filter_callback currently attached to the filter.
- $do
-
(callable) (Required) The filter_callback that will be run detaching the
$filter_callback. - $args
-
(int) (Optional) The number of arguments that should be used to re-attach the filtering callback to the filter.
Default value: 1
Return
(mixed) The return value of the $do callback.
Source
File: src/functions/utils.php
function tribe_suspending_filter( $filter_tag, callable $filter_callback, callable $do, $args = 1 ) {
$priority = has_filter( $filter_tag, $filter_callback );
if ( false !== $priority ) {
remove_filter( $filter_tag, $filter_callback, $priority );
}
$result = $do();
if ( false !== $priority ) {
add_filter( $filter_tag, $filter_callback, $priority, $args );
}
return $result;
}
Changelog
| Version | Description |
|---|---|
| 4.12.12 | Introduced. |