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

Removes all of the callback functions from a filter hook.


Parameters Parameters

$hook_name

(string) (Required) The filter to remove callbacks from.

$priority

(int|false) (Optional) The priority number to remove them from.

Default value: false


Top ↑

Return Return

(true) Always returns true.


Top ↑

Source Source

File: wp-includes/plugin.php

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;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by nosilver4u

    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 );
  2. Skip to note 2 content

    Example:

    remove_all_filters('the_content', 'plugin_filters');

    This example will remove all of the plugins hooks from the_content function.

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