remove_all_filters()
Removes all hooks from the specified filter.
The function removes all functions attached to the filter. If a priority is specified in the $priority parameter, then only hooks with the specified priority will be removed, not all...
Used By: remove_all_actions()
No Hooks.
Returns
true. Always returns true.
Usage
remove_all_filters( $tag, $priority );
- $tag(string) (required)
- The name of the filter whose hooks should all be removed.
- $priority(int)
The priority of the hooks to remove.
- If specified, only hooks with that priority will be removed.
- If not specified (left false), then absolutely all hooks attached to the filter will be removed.
Default: false
Examples
#1 Remove all the functions (hooks) attached to the filter
remove_all_filters( 'wp_mail_from' );
#2 Remove only the hooks with specified priority
Remove all functions (hooks) which was registered with default priority 10, for the filter the_content:
remove_all_filters( 'the_content', 10 );
This will cause most of the post text filters to be disabled - i.e., all filters with a priority of 10 will be disabled. These are:
// from file: /wp-includes/default-filters.php add_filter( 'the_content', 'wptexturize' ); add_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'shortcode_unautop' ); add_filter( 'the_content', 'prepend_attachment' ); add_filter( 'the_content', 'wp_make_content_images_responsive' );
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 );
Notes
- Global. WP_Hook[].
$wp_filterStores all of the filters and actions.
Changelog
| Since 2.7.0 | Introduced. |
remove_all_filters() remove all filters code WP 7.0
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;
}