Hook_Registry
Hook Registry class for managing WordPress actions and filters.
Namespace: WebberZone\Better_Search\Util
Since: 4.2.0
Source: includes/util/class-hook-registry.php line 19
Methods
register() static
Register a hook (action or filter).
Line: 39
static public function register( string $hook_type, string $hook_name, callable $callback, int $priority = ..., int $args = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_type | Either ‘action’ or ‘filter’. |
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
int | $args | Number of arguments. |
Returns: bool — True if registered, false if duplicate or invalid hook.
add_action() static
Register an action.
Line: 94
static public function add_action( $hook_name, $callback, $priority = ..., $args = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
int | $args | Number of arguments. |
Returns: bool — True if registered, false if duplicate or invalid hook.
add_filter() static
Register a filter.
Line: 108
static public function add_filter( $hook_name, $callback, $priority = ..., $args = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
int | $args | Number of arguments. |
Returns: bool — True if registered, false if duplicate or invalid hook.
remove() static
Remove a hook (action or filter).
Note: Closures are removable only if registered via this class.
Line: 124
static public function remove( $hook_type, $hook_name, $callback, $priority = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_type | Either ‘action’ or ‘filter’. |
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
Returns: bool — True if removed, false if not found or removal failed.
remove_action() static
Remove an action.
Line: 168
static public function remove_action( $hook_name, $callback, $priority = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
Returns: bool — True if removed, false if not found or removal failed.
remove_filter() static
Remove a filter.
Line: 181
static public function remove_filter( $hook_name, $callback, $priority = ... ): bool;
| Type | Name | Description |
|---|---|---|
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
Returns: bool — True if removed, false if not found or removal failed.
get_hooks() static
Get all registered hooks.
Line: 190
static public function get_hooks( ): array;
Returns: array — Array of registered hooks.
remove_all_hooks() static
Remove all registered hooks.
Line: 199
static public function remove_all_hooks( ): void;
Returns: void
create_hook_key() static
Create a unique key for a hook registration.
Line: 220
static public function create_hook_key( $hook_name, $callback, $priority, $closure_id = ... ): string;
| Type | Name | Description |
|---|---|---|
string | $hook_name | The hook name. |
callable | $callback | The callback function. |
int | $priority | Priority of the hook. |
string | $closure_id | Unique ID for closures. |
Returns: string — Unique key.
callback_to_string() static
Convert a callback to a string representation.
Line: 231
static public function callback_to_string( $callback ): string;
| Type | Name | Description |
|---|---|---|
callable | $callback | The callback to convert. |
Returns: string — String representation of the callback.