Removes all of the callback functions from a filter hook.
Parameters
$hook_name
stringrequired- The filter to remove callbacks from.
$priority
int|falseoptional- The priority number to remove them from.
Default:
false
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
Version | Description |
---|---|
2.7.0 | Introduced. |
Example:
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:
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:
Example:
This example will remove all of the plugins hooks from the_content function.