remove_all_filters()
Remove all of the hooks from a filter.
Used By: remove_all_actions()
No Hooks.
Return
true
. Always returns true.
Usage
remove_all_filters( $hook_name, $priority );
- $hook_name(string) (required)
- The filter to remove callbacks from.
- $priority(int|false)
- The priority number to remove them from.
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_filter Stores all of the filters and actions.
Changelog
Since 2.7.0 | Introduced. |
remove_all_filters() remove all filters code WP 6.8
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; }