ActionHook
in package
ActionHook Module class.
Table of Contents
Properties
- $accepted_args : int
- Number of arguments the callback accepts.
- $callback : callable
- Callback function to be executed when the action hook is run.
- $hook_name : string
- Action hook name.
- $priority : int
- Priority of the action hook.
Methods
- __construct() : mixed
- Constructor.
- __toString() : string
- Custom toString magic method.
- add_action() : void
- Adds the action hook to WordPress.
- initialize() : void
- Initializes the action hook.
Properties
$accepted_args
Number of arguments the callback accepts.
private
int
$accepted_args
Number of arguments the callback accepts.
Tags
$callback
Callback function to be executed when the action hook is run.
private
callable
$callback
Callback function to be executed when the action hook is run.
Tags
$hook_name
Action hook name.
private
string
$hook_name
Action hook name.
Tags
$priority
Priority of the action hook.
private
int
$priority
Priority of the action hook.
Tags
Methods
__construct()
Constructor.
public
__construct(string $hook_name, callable $callback[, int $priority = 10 ][, int $accepted_args = 1 ]) : mixed
Constructs the ActionHook object by setting the hook name, callback, priority, and accepted arguments.
Parameters
- $hook_name : string
-
Action hook name.
- $callback : callable
-
Callback function to be executed when the action hook is run.
- $priority : int = 10
-
Priority of the action hook.
- $accepted_args : int = 1
-
Number of arguments the callback accepts.
Tags
__toString()
Custom toString magic method.
public
__toString() : string
Returns the action hook as a JSON string.
Tags
Return values
string —JSON string.
add_action()
Adds the action hook to WordPress.
public
add_action() : void
Adds the action hook to WordPress using the add_action function.
Tags
initialize()
Initializes the action hook.
private
initialize() : void
Adds the action hook to the registry.