did_action( string $hook_name )

Retrieves the number of times an action has been fired during the current request.

Parameters

$hook_name

(string) (Required) The name of the action hook.

Return

(int) The number of times the action hook has been fired.

Source

File: wp-includes/plugin.php

function did_action( $hook_name ) {
	global $wp_actions;

	if ( ! isset( $wp_actions[ $hook_name ] ) ) {
		return 0;
	}

	return $wp_actions[ $hook_name ];
}

Changelog

Version Description
2.1.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/did_action