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.

The function will infer the priority of the filter, required for its correct detachment and re-attachment, on its own.

Parameters #


(string) (Required) The filter tag to suspend.


(callable) (Required) The filter_callback currently attached to the filter.


(callable) (Required) The filter_callback that will be run detaching the $filter_callback.


(int) (Optional) The number of arguments that should be used to re-attach the filtering callback to the filter.

Default value: 1

Top ↑

Return #

(mixed) The return value of the $do callback.

Top ↑

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;

Top ↑

Changelog #

Version Description
4.12.12 Introduced.