remove_all_filters() WordPress Function

The remove_all_filters() function is a powerful tool for developers who need to remove all filters from a specified hook. This function can be used to remove filters that are added by plugins or themes, or even to remove filters that are added by the WordPress core.

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

Removes all of the callback functions from a filter hook.


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

(true) Always returns true.


Top ↑

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
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.