Add has_action method

This commit is contained in:
Starbeamrainbowlabs 2017-06-18 13:54:15 +01:00
parent 3ec7722453
commit 1d09c22f3a
3 changed files with 23 additions and 0 deletions

View File

@ -14,6 +14,7 @@
- An identicon is rendered if a user hasn't specified an email address or uploaded a gravatar yet either
- Added `avatars_show` and `avatars_size` settings to control the displaying & size of rendered avatars.
- Added the `avatar` action, which 307 redirects to the appropriate avatar image
- Added `has_action` to make detecting enabled features easier (even if they move modules)
### Changed
- Updated MathJax CDN link, as cdn.mathjax.org is being retired ([source](https://www.mathjax.org/cdn-shutting-down/)).

View File

@ -1720,6 +1720,17 @@ function add_action($action_name, $func)
global $actions;
$actions->$action_name = $func;
}
/**
* Figures out whether a given action is currently registered.
* Only guaranteed to be accurate in inside an existing action function
* @param string $action_name The name of the action to search for
* @return boolean Whether an action with the specified name exists.
*/
function has_action($action_name)
{
global $actions;
return !empty($actions->action_name);
}
$parsers = [
"none" => function() {

View File

@ -1371,6 +1371,17 @@ function add_action($action_name, $func)
global $actions;
$actions->$action_name = $func;
}
/**
* Figures out whether a given action is currently registered.
* Only guaranteed to be accurate in inside an existing action function
* @param string $action_name The name of the action to search for
* @return boolean Whether an action with the specified name exists.
*/
function has_action($action_name)
{
global $actions;
return !empty($actions->action_name);
}
$parsers = [
"none" => function() {