interface hook_manager_interface

Contract for the Hook Manager.

Provides a WordPress-style system of "filters" and "actions".

Filters: Modify a value and return it. Actions: Execute side effects, no return value.

Methods

static void
add_filter(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new filter callback.

static mixed
apply_filters(string $tag, mixed $value, mixed ...$args)

Apply all registered filters to a value.

static void
add_action(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new action callback.

static void
do_action(string $tag, mixed ...$args)

Execute all callbacks registered for a given action.

static bool
has_action(string $tag)

Check whether any callback is registered for the given action.

static void
reset()

Clear all registered hooks. Essential for unit testing isolation.

Details

at line 38
static void add_filter(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new filter callback.

Parameters

string $tag

Filter identifier

callable $function

Callback to execute

int $priority

Lower = run earlier

int $args

Number of accepted arguments

Return Value

void

at line 49
static mixed apply_filters(string $tag, mixed $value, mixed ...$args)

Apply all registered filters to a value.

Parameters

string $tag

Filter identifier

mixed $value

Initial value

mixed ...$args

Additional parameters passed to callbacks

Return Value

mixed

Filtered value

at line 59
static void add_action(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new action callback.

Parameters

string $tag

Action identifier

callable $function

Callback to execute

int $priority

Lower = run earlier

int $args

Number of accepted arguments

Return Value

void

at line 67
static void do_action(string $tag, mixed ...$args)

Execute all callbacks registered for a given action.

Parameters

string $tag

Action identifier

mixed ...$args

Parameters passed to callbacks

Return Value

void

at line 76
static bool has_action(string $tag)

Check whether any callback is registered for the given action.

Parameters

string $tag

Return Value

bool

at line 81
static void reset()

Clear all registered hooks. Essential for unit testing isolation.

Return Value

void