Documentation

Loader
in package

Class defining action/filter registration for the plugin.

Maintain a list of all hooks that are registered throughout the plugin, and register them with the WordPress API. Call the run function to execute the list of actions and filters.

Tags
since
2.8.0

Table of Contents

$actions  : array<string|int, mixed>
The array of actions registered with WordPress.
$filters  : array<string|int, mixed>
The array of filters registered with WordPress.
__construct()  : void
Initialize the collections used to maintain the actions and filters.
add_action()  : void
Add a new action to the collection to be registered with WordPress.
add_filter()  : void
Add a new filter to the collection to be registered with WordPress.
run()  : void
Registers the filters and actions with WordPress.
add()  : array<string|int, array<string|int, string|int|object>>
A utility function that is used to register the actions and hooks into a single collection.

Properties

$actions

The array of actions registered with WordPress.

protected array<string|int, mixed> $actions
Tags
since
2.8.0
see
Loader::add()

For more information on the hook array format.

$filters

The array of filters registered with WordPress.

protected array<string|int, mixed> $filters
Tags
since
2.8.0
see
Loader::add()

For more information on the hook array format.

Methods

__construct()

Initialize the collections used to maintain the actions and filters.

public __construct() : void
Tags
since
2.8.0
Return values
void

add_action()

Add a new action to the collection to be registered with WordPress.

public add_action(string $hook, object $component, string $callback[, int $priority = 10 ][, int $accepted_args = 1 ]) : void
Parameters
$hook : string

The name of the WordPress action that is being registered.

$component : object

A reference to the instance of the object on which the action is defined.

$callback : string

The name of the function definition on the $component.

$priority : int = 10

Optional. The priority at which the function should be fired. Default is 10.

$accepted_args : int = 1

Optional. The number of arguments that should be passed to the $callback. Default is 1.

Tags
since
2.8.0
see
Loader::add()

For more information on the hook array format.

Return values
void

add_filter()

Add a new filter to the collection to be registered with WordPress.

public add_filter(string $hook, object $component, string $callback[, int $priority = 10 ][, int $accepted_args = 1 ]) : void
Parameters
$hook : string

The name of the WordPress filter that is being registered.

$component : object

A reference to the instance of the object on which the filter is defined.

$callback : string

The name of the function definition on the $component.

$priority : int = 10

Optional. The priority at which the function should be fired. Default is 10.

$accepted_args : int = 1

Optional. The number of arguments that should be passed to the $callback. Default is 1.

Tags
since
2.8.0
see
Loader::add()

For more information on the hook array format.

Return values
void

run()

Registers the filters and actions with WordPress.

public run() : void
Tags
since
2.8.0
see
Loader::add()

For more information on the hook array format.

Return values
void

add()

A utility function that is used to register the actions and hooks into a single collection.

private add(array<string|int, array<string|int, string|int|object>> $hooks, string $hook, object $component, string $callback, int $priority, int $accepted_args) : array<string|int, array<string|int, string|int|object>>
Parameters
$hooks : array<string|int, array<string|int, string|int|object>>

The collection of hooks that is being registered (that is, actions or filters).

$hook : string

The name of the WordPress filter that is being registered.

$component : object

A reference to the instance of the object on which the filter is defined.

$callback : string

The name of the function definition on the $component.

$priority : int

The priority at which the function should be fired.

$accepted_args : int

The number of arguments that should be passed to the $callback.

Tags
since
2.8.0
Return values
array<string|int, array<string|int, string|int|object>>

{ The registered hook(s).

@type string $hook The name of the registered WordPress hook.
@type object $component A reference to the instance of the object on which the hook is defined.
@type string $callback The name of the function definition on the `$component`.
@type int $priority The priority at which the function should be fired.
@type int $accepted_args The number of arguments that should be passed to the `$callback`.

}

Search results