On this page
remove_filter( string $hook_name, callable|string|array $callback, int $priority = 10 ): bool
Removes a callback function from a filter hook.
Description
This can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.
To remove a hook, the $callback and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.
Parameters
$hook_namestring Required-
The filter hook to which the function to be removed is hooked.
$callbackcallable|string|array Required-
The callback to be removed from running when the filter is applied.
This function can be called unconditionally to speculatively remove a callback that may or may not exist. $priorityint Optional-
The exact priority used when adding the original filter callback.
Default:
10
Return
bool Whether the function existed before it was removed.
Source
File: wp-includes/plugin.php. View all references
function remove_filter( $hook_name, $callback, $priority = 10 ) {
global $wp_filter;
$r = false;
if ( isset( $wp_filter[ $hook_name ] ) ) {
$r = $wp_filter[ $hook_name ]->remove_filter( $hook_name, $callback, $priority );
if ( ! $wp_filter[ $hook_name ]->callbacks ) {
unset( $wp_filter[ $hook_name ] );
}
}
return $r;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_REST_Menu_Items_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Prepares a single post output for response. |
| WP_REST_Global_Styles_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php | Prepare a global styles config output for response. |
| _resolve_template_for_new_post() wp-includes/block-template.php | Sets the current WP_Query to return auto-draft posts. |
| wp_pre_kses_block_attributes() wp-includes/formatting.php | Removes non-allowable HTML from parsed block attribute values when filtering in the post context. |
| wp_remove_targeted_link_rel_filters() wp-includes/formatting.php | Removes all filters modifying the rel attribute of targeted links. |
| WP_REST_Post_Search_Handler::prepare_item() wp-includes/rest-api/search/class-wp-rest-post-search-handler.php | Prepares the search result for a given ID. |
| do_blocks() wp-includes/blocks.php | Parses dynamic blocks out of |
| _restore_wpautop_hook() wp-includes/blocks.php | If do_blocks() needs to remove wpautop() from the |
| WP_Widget_Custom_HTML::widget() wp-includes/widgets/class-wp-widget-custom-html.php | Outputs the content for the current Custom HTML widget instance. |
| WP_Widget_Media_Video::render_media() wp-includes/widgets/class-wp-widget-media-video.php | Render the media on the frontend. |
| WP_Customize_Manager::save_changeset_post() wp-includes/class-wp-customize-manager.php | Saves the post for the loaded changeset. |
| WP_REST_Posts_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Prepares a single post output for response. |
| WP_REST_Posts_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts. |
| WP_REST_Comments_Controller::check_read_post_permission() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Checks if the post can be read. |
| WP_Taxonomy::remove_hooks() wp-includes/class-wp-taxonomy.php | Removes the ajax callback for the meta box. |
| WP_Customize_Nav_Menus::insert_auto_draft_post() wp-includes/class-wp-customize-nav-menus.php | Adds a new |
| _filter_query_attachment_filenames() wp-includes/deprecated.php | Filter the SQL clauses of an attachment query to include filenames. |
| unregister_meta_key() wp-includes/meta.php | Unregisters a meta key from the list of registered keys. |
| WP_Metadata_Lazyloader::reset_queue() wp-includes/class-wp-metadata-lazyloader.php | Resets lazy-load queue for a given object type. |
| WP_Customize_Widgets::render_widget_partial() wp-includes/class-wp-customize-widgets.php | Renders a specific widget using the supplied sidebar arguments. |
| wp_handle_comment_submission() wp-includes/comment.php | Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. |
| WP_Customize_Nav_Menus::customize_register() wp-includes/class-wp-customize-nav-menus.php | Adds the customizer settings and controls. |
| wp_ajax_crop_image() wp-admin/includes/ajax-actions.php | Ajax handler for cropping an image. |
| Language_Pack_Upgrader::bulk_upgrade() wp-admin/includes/class-language-pack-upgrader.php | Bulk upgrade language packs. |
| Plugin_Upgrader::bulk_upgrade() wp-admin/includes/class-plugin-upgrader.php | Bulk upgrade several plugins at once. |
| Theme_Upgrader::check_parent_theme_filter() wp-admin/includes/class-theme-upgrader.php | Check if a child theme is being installed and we need to install its parent. |
| Theme_Upgrader::install() wp-admin/includes/class-theme-upgrader.php | Install a theme package. |
| Theme_Upgrader::upgrade() wp-admin/includes/class-theme-upgrader.php | Upgrade a theme. |
| Theme_Upgrader::bulk_upgrade() wp-admin/includes/class-theme-upgrader.php | Upgrade several themes at once. |
| Plugin_Upgrader::install() wp-admin/includes/class-plugin-upgrader.php | Install a plugin package. |
| Plugin_Upgrader::upgrade() wp-admin/includes/class-plugin-upgrader.php | Upgrade a plugin. |
| unregister_setting() wp-includes/option.php | Unregisters a setting. |
| wp_ajax_send_attachment_to_editor() wp-admin/includes/ajax-actions.php | Ajax handler for sending an attachment to the editor. |
| wp_ajax_replyto_comment() wp-admin/includes/ajax-actions.php | Ajax handler for replying to a comment. |
| wp_link_manager_disabled_message() wp-admin/includes/bookmark.php | Outputs the ‘disabled’ message for the WordPress Link Manager. |
| WP_Customize_Manager::stop_previewing_theme() wp-includes/class-wp-customize-manager.php | Stops previewing the selected theme. |
| kses_remove_filters() wp-includes/kses.php | Removes all KSES input form content filters. |
| WP_Widget_Text::widget() wp-includes/widgets/class-wp-widget-text.php | Outputs the content for the current Text widget instance. |
| WP_Widget_Text::form() wp-includes/widgets/class-wp-widget-text.php | Outputs the Text widget settings form. |
| remove_action() wp-includes/plugin.php | Removes a callback function from an action hook. |
| welcome_user_msg_filter() wp-includes/ms-functions.php | Ensures that the welcome message is not empty. Currently unused. |
| Walker_Comment::start_el() wp-includes/class-walker-comment.php | Starts the element output. |
| WP_Customize_Widgets::stop_capturing_option_updates() wp-includes/class-wp-customize-widgets.php | Undoes any changes to the options since options capture began. |
| wp_update_comment() wp-includes/comment.php | Updates an existing comment in the database. |
| _WP_Editors::editor() wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor. |
Changelog
| Version | Description |
|---|---|
| 1.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/remove_filter