has_action( string $hook_name, callable|string|array|false $callback = false, int|false $priority = false ): bool|int
- Since
- 2.5.0, 6.9.0
- Source
wp-includes/plugin.php:598
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 $priorityint|falseoptional- The specific priority at which to check for the callback. 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. If$callbackand$priorityare both provided, a boolean is returned for whether the specific function is registered at that priority.
Uses · 1
- has_filter()Checks if any filter has been registered for a hook.
Used by · 25
- 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 25
- 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_enqueue_img_auto_sizes_contain_css_fix()Enqueues a CSS rule to fix potential visual issues with images using `sizes=auto`.
- wp_hoist_late_printed_styles()Adds the hooks needed for CSS output to be delayed until after the content of the page has been established.
- 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_oembed_add_discovery_links()Adds oEmbed discovery links in the head element of the website.
- 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.
- wp_should_output_buffer_template_for_enhancement()Checks whether the template should be output buffered for enhancement.
Source
function has_action( $hook_name, $callback = false, $priority = false ) { return has_filter( $hook_name, $callback, $priority );}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 source6.9.0
Added the
$priority parameter.from the docblock2.5.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.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.