Cp_Plgn_Drctry_Loader

Register all actions and filters for the plugin.

Description

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
author

Beda Schmid beda@tukutoi.com

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.
$shortcodes  : array<string|int, mixed>
The array of shortcode registered with WordPress.
__construct()  : mixed
Initialize the collections used to maintain the actions and filters.
add_action()  : mixed
Add a new action to the collection to be registered with WordPress.
add_filter()  : mixed
Add a new filter to the collection to be registered with WordPress.
add_shortcode()  : mixed
Add a new shortcode to the collection to be registered with WordPress
autoloader()  : mixed
Simple Autoloader.
remove_action()  : bool
Remove an action from the collection registered with WordPress.
remove_filter()  : bool
Remove a filter from the collection registered with WordPress.
run()  : mixed
Register the filters and actions with WordPress.
add()  : array<string|int, mixed>
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
Description

The actions registered with WordPress to fire when the plugin loads.

Tags
since
1.0.0
access

protected

$filters

The array of filters registered with WordPress.

protected array<string|int, mixed> $filters
Description

The filters registered with WordPress to fire when the plugin loads.

Tags
since
1.0.0
access

protected

$shortcodes

The array of shortcode registered with WordPress.

protected array<string|int, mixed> $shortcodes
Description

The shortcode registered with WordPress to fire when the plugin loads.

Tags
since
1.0.0
access

protected

Methods

__construct()

Initialize the collections used to maintain the actions and filters.

public __construct() : mixed
Tags
since
1.0.0
Return
(mixed)

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 ]) : mixed
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) Optional. The priority at which the function should be fired. Default is 10. Defaults to: 10
$accepted_args
(int) Optional. The number of arguments that should be passed to the $callback. Default is 1. Defaults to: 1
Tags
since
1.0.0
Return
(mixed)

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 ]) : mixed
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) Optional. The priority at which the function should be fired. Default is 10. Defaults to: 10
$accepted_args
(int) Optional. The number of arguments that should be passed to the $callback. Default is 1. Defaults to: 1
Tags
since
1.0.0
Return
(mixed)

add_shortcode()

Add a new shortcode to the collection to be registered with WordPress

public add_shortcode(string $tag, object $component, string $callback[, int $priority = 10 ][, int $accepted_args = 1 ]) : mixed
Parameters
$tag
(string) The name of the new shortcode.
$component
(object) A reference to the instance of the object on which the shortcode is defined.
$callback
(string) The name of the function that defines the shortcode.
$priority
(int) Optional. The priority at which the function should be fired. Default is 10. Defaults to: 10
$accepted_args
(int) Optional. The number of arguments that should be passed to the $callback. Default is 1. Defaults to: 1
Tags
since
1.0.0
Return
(mixed)

autoloader()

Simple Autoloader.

public autoloader(string $class) : mixed
Description

Provides an autoloader for this plugin. To hve the autoloader functioning:

  • the class must be in a file staring with class- and ending with .php
  • the class filename between class- and .php must match the classname (lowercase, - not _ separated)
  • the class file must be in either the admin, includes or public folder
Parameters
$class
(string) The Class to autoload.
Tags
since
1.4.0
Return
(mixed)

remove_action()

Remove an action from the collection registered with WordPress.

public remove_action(string $tag[, string $class_name = '' ][, string $method_to_remove = '' ][, int $priority = 10 ]) : bool
Parameters
$tag
(string) The filter hook to which the function to be removed is hooked.
$class_name
(string) Class name registering the filter callback. Defaults to: ''
$method_to_remove
(string) Method name for the filter's callback. Defaults to: ''
$priority
(int) The priority of the method (default 10). Defaults to: 10
Tags
since
1.0.0
Return
(bool) $removed Whether the function is removed.

remove_filter()

Remove a filter from the collection registered with WordPress.

public remove_filter(string $tag[, string $class_name = '' ][, string $method_to_remove = '' ][, int $priority = 10 ]) : bool
Parameters
$tag
(string) The filter hook to which the function to be removed is hooked.
$class_name
(string) Class name registering the filter callback. Defaults to: ''
$method_to_remove
(string) Method name for the filter's callback. Defaults to: ''
$priority
(int) The priority of the method (default 10). Defaults to: 10
Tags
since
1.0.0
Return
(bool) $removed Whether the function is removed.

add()

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

private add(array<string|int, mixed> $hooks, string $hook, object $component, string $callback, int $priority, int $accepted_args) : array<string|int, mixed>
Parameters
$hooks
(array<string|int, mixed>) 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
1.0.0
access

private

Return
(array<string|int, mixed>) The collection of actions and filters registered with WordPress.

Search results