On this page
has_filter( string $hook_name, callable|string|array|false $callback = false ): bool|int
Checks if any filter has been registered for a hook.
Description
When using the $callback argument, this function may return a non-boolean value that evaluates to false (e.g. 0), so use the === operator for testing the return value.
Parameters
$hook_namestring Required-
The name of the filter hook.
$callbackcallable|string|array|false Optional-
The callback to check for.
This function can be called unconditionally to speculatively check a callback that may or may not exist.Default:
false
Return
bool|int If $callback is omitted, returns boolean for whether the hook has anything registered. When checking a specific function, the priority of that hook is returned, or false if the function is not attached.
Source
File: wp-includes/plugin.php. View all references
function has_filter( $hook_name, $callback = false ) {
global $wp_filter;
if ( ! isset( $wp_filter[ $hook_name ] ) ) {
return false;
}
return $wp_filter[ $hook_name ]->has_filter( $hook_name, $callback );
}
Related
Used By
| Used By | Description |
|---|---|
| core_auto_updates_settings() wp-admin/update-core.php | Display WordPress auto-updates settings. |
| WP_Site_Health::detect_plugin_theme_auto_update_issues() wp-admin/includes/class-wp-site-health.php | Checks for potential issues with plugin and theme auto-updates. |
| WP_Site_Health::check_wp_version_check_exists() wp-admin/includes/class-wp-site-health.php | Tests whether |
| WP_Site_Health_Auto_Updates::test_wp_version_check_attached() wp-admin/includes/class-wp-site-health-auto-updates.php | Checks if updates are intercepted by a filter. |
| update_sitemeta_cache() wp-includes/ms-site.php | Updates metadata cache for list of site IDs. |
| 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 |
| wpdb::placeholder_escape() wp-includes/class-wpdb.php | Generates and returns a placeholder escape string for use in queries returned by ::prepare(). |
| apply_filters_deprecated() wp-includes/plugin.php | Fires functions attached to a deprecated filter hook. |
| WP_Customize_Nav_Menu_Item_Setting::preview() wp-includes/customize/class-wp-customize-nav-menu-item-setting.php | Handle previewing the setting. |
| WP_MS_Sites_List_Table::column_plugins() wp-admin/includes/class-wp-ms-sites-list-table.php | Handles the plugins column output. |
| Core_Upgrader::upgrade() wp-admin/includes/class-core-upgrader.php | Upgrade WordPress core. |
| WP_MS_Sites_List_Table::get_columns() wp-admin/includes/class-wp-ms-sites-list-table.php | |
| map_meta_cap() wp-includes/capabilities.php | Maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked. |
| WP::build_query_string() wp-includes/class-wp.php | Sets the query string property based off of the query variable property. |
| WP_Widget_Text::widget() wp-includes/widgets/class-wp-widget-text.php | Outputs the content for the current Text widget instance. |
| WP_Embed::shortcode() wp-includes/class-wp-embed.php | The do_shortcode() callback function. |
| has_action() wp-includes/plugin.php | Checks if any action has been registered for a hook. |
| wp_update_comment() wp-includes/comment.php | Updates an existing comment in the database. |
| sanitize_meta() wp-includes/meta.php | Sanitizes meta value. |
| register_meta() wp-includes/meta.php | Registers a meta key. |
| _WP_Editors::editor() wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/has_filter