PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / class-loader.php

class-loader.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/class-loader.php

127 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace OPTN\Includes;
4
5 /**
6 * Register all actions and filters for the plugin
7 *
8 * @link https://wpxpo.com
9 * @since 1.0.0
10 *
11 * @package optin
12 * @subpackage optin/includes
13 */
14
15 /**
16 * Register all actions and filters for the plugin.
17 *
18 * Maintain a list of all hooks that are registered throughout
19 * the plugin, and register them with the WordPress API. Call the
20 * run function to execute the list of actions and filters.
21 *
22 * @package optin
23 * @subpackage optin/includes
24 */
25 class Loader {
26
27 /**
28 * The array of actions registered with WordPress.
29 *
30 * @since 1.0.0
31 * @access protected
32 * @var array $actions The actions registered with WordPress to fire when the plugin loads.
33 */
34 protected $actions;
35
36 /**
37 * The array of filters registered with WordPress.
38 *
39 * @since 1.0.0
40 * @access protected
41 * @var array $filters The filters registered with WordPress to fire when the plugin loads.
42 */
43 protected $filters;
44
45 /**
46 * Initialize the collections used to maintain the actions and filters.
47 *
48 * @since 1.0.0
49 */
50 public function __construct() {
51
52 $this->actions = array();
53 $this->filters = array();
54 }
55
56 /**
57 * Add a new action to the collection to be registered with WordPress.
58 *
59 * @since 1.0.0
60 * @param string $hook The name of the WordPress action that is being registered.
61 * @param object $component A reference to the instance of the object on which the action is defined.
62 * @param string $callback The name of the function definition on the $component.
63 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
64 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
65 */
66 public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
67 $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
68 }
69
70 /**
71 * Add a new filter to the collection to be registered with WordPress.
72 *
73 * @since 1.0.0
74 * @param string $hook The name of the WordPress filter that is being registered.
75 * @param object $component A reference to the instance of the object on which the filter is defined.
76 * @param string $callback The name of the function definition on the $component.
77 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
78 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
79 */
80 public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
81 $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
82 }
83
84 /**
85 * A utility function that is used to register the actions and hooks into a single
86 * collection.
87 *
88 * @since 1.0.0
89 * @access private
90 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
91 * @param string $hook The name of the WordPress filter that is being registered.
92 * @param object $component A reference to the instance of the object on which the filter is defined.
93 * @param string $callback The name of the function definition on the $component.
94 * @param int $priority The priority at which the function should be fired.
95 * @param int $accepted_args The number of arguments that should be passed to the $callback.
96 * @return array The collection of actions and filters registered with WordPress.
97 */
98 private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
99
100 $hooks[] = array(
101 'hook' => $hook,
102 'component' => $component,
103 'callback' => $callback,
104 'priority' => $priority,
105 'accepted_args' => $accepted_args,
106 );
107
108 return $hooks;
109 }
110
111 /**
112 * Register the filters and actions with WordPress.
113 *
114 * @since 1.0.0
115 */
116 public function run() {
117
118 foreach ( $this->filters as $hook ) {
119 add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
120 }
121
122 foreach ( $this->actions as $hook ) {
123 add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
124 }
125 }
126 }
127