has_action( string $hook_name, callable|string|array|false $callback = false ): bool|int
- Since
- 2.5.0
- Source
wp-includes/plugin.php:588
Checks if any action 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- The name of the action hook.
$callbackcallable|string|array|falseoptional- The callback to check for. This function can be called unconditionally to speculatively check a callback that may or may not exist. Default false.Default:
false
Return
bool|int- If
$callbackis 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.
Uses · 1
- has_filter()Checks if any filter has been registered for a hook.
Used by · 21
- WP_Customize_Manager::save_changeset_post()Saves the post for the loaded changeset.
- WP_Customize_Setting::preview()Add filters to supply the setting's value when accessed.
- WP_Customize_Setting::update()Save the value of the setting, using the related API.
- WP_Screen::render_meta_boxes_preferences()Renders the meta boxes preferences.
- _wp_get_iframed_editor_assets()Collect the block editor assets that need to be loaded into the editor's iframe.
- comment_form()Outputs a complete commenting form for use within a template.
- display_setup_form()Displays installer setup form.
- do_action_deprecated()Fires functions attached to a deprecated action hook.
- do_feed()Loads the feed template from the use of an action hook.
- get_plugin_page_hook()Gets the hook attached to the administrative page of a plugin.
- wp_admin_bar_customize_menu()Adds the "Customize" link to the Toolbar.
- wp_enqueue_admin_bar_bump_styles()Enqueues inline bump styles to make room for the admin bar.
Show all 21
- wp_enqueue_admin_bar_header_styles()Enqueues inline style to hide the admin bar when printing.
- wp_enqueue_block_template_skip_link()Enqueues the skip-link script & styles.
- wp_enqueue_embed_styles()Enqueues the CSS in the embed iframe header.
- wp_enqueue_emoji_styles()Enqueues the important emoji-related styles.
- wp_insert_site()Inserts a new site into the database.
- wp_is_local_html_output()Checks whether a given HTML string is likely an output from this WordPress site.
- wp_maybe_enqueue_oembed_host_js()Enqueue the wp-embed script if the provided oEmbed HTML contains a post embed.
- wp_save_post_revision()Creates a revision for the current version of a post.
- wp_save_post_revision_on_insert()Saves revisions for a post after all changes have been made.
Source
function has_action( $hook_name, $callback = false ) { return has_filter( $hook_name, $callback );}History
Introduced in 2.5.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.9.7
Parameter
$priority added.verified against source2.5.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/plugin.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.