doing_action( string|null $hook_name = null ): bool
- Since
- 3.9.0
- Source
wp-includes/plugin.php:671
Description
The function current_action() only returns the most recent action being executed.
did_action() returns the number of times an action has been fired during the current request.
This function allows detection for any action currently being executed (regardless of whether it's the most recent action to fire, in the case of hooks called from hook callbacks) to be verified.
Compatibility
- WordPress
- since 3.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$hook_namestring|nulloptional- Action hook to check. Defaults to null, which checks if any action is currently being run.Default:
null
Return value
bool- Whether the action is currently in the stack.
Performance profile
How much work a call to doing_action() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 5
- Plugin surface
- None
- Called by
- 12
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 5.
Nothing here hands control to plugin code.
12 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost doing_action() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 5 | doing_filter() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 5 instructions, 5 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- doing_filter()Returns whether or not a filter hook is currently being processed.
Used by · 12
- WP_Connector_Registry::set_instance()Sets the main instance of the registry class.
- _load_textdomain_just_in_time()Loads plugin and theme text domains just-in-time.
- load_default_textdomain()Loads default translated strings based on locale.
- wp_add_privacy_policy_content()Declares a helper function for adding content to the Privacy Policy Guide.
- wp_cron()Registers _wp_cron() to run on the {@see 'shutdown'} action.
- wp_enqueue_global_styles()Enqueues the global styles defined via theme.json.
- wp_enqueue_stored_styles()Fetches, processes and compiles stored core styles, then combines and renders them to the page.
- wp_oembed_add_discovery_links()Adds oEmbed discovery links in the head element of the website.
- wp_register_ability()Registers a new ability using the Abilities API. It requires three steps:
- wp_register_ability_category()Registers a new ability category.
- wp_save_post_revision()Creates a revision for the current version of a post.
- wp_version_check()Checks WordPress version against the newest version.
Source code
function doing_action( $hook_name = null ) { return doing_filter( $hook_name );}Changelog
Introduced in 3.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 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.