remove_all_filters( string $hook_name, int|false $priority = false ): true

Removes all of the callback functions from a filter hook.

Parameters

$hook_namestringrequired
The filter to remove callbacks from.
$priorityint|falseoptional
The priority number to remove them from.

Default:false

Return

true Always returns true.

Source

function remove_all_filters( $hook_name, $priority = false ) {
	global $wp_filter;

	if ( isset( $wp_filter[ $hook_name ] ) ) {
		$wp_filter[ $hook_name ]->remove_all_filters( $priority );

		if ( ! $wp_filter[ $hook_name ]->has_filters() ) {
			unset( $wp_filter[ $hook_name ] );
		}
	}

	return true;
}

Changelog

VersionDescription
2.7.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    Example:

    remove_all_filters( 'the_content' );

    This example will remove all hooks from the_content function, for any plugin or theme.
    But if you only want to remove a particular set of hooks at a particular priority, you can use a priority, 10 being the default used for most filters:

    remove_all_filters( 'wp_delete_file', 10 );

    Since class-derived filters can be tricky to remove, if they use a non-default priority (take 15 for example), you could do this instead:

    remove_all_filters( 'wp_delete_file', 15 );

You must log in before being able to contribute a note or feedback.