PluginProbe ʕ •ᴥ•ʔ
Firebase Authentication / 1.1.2
Firebase Authentication v1.1.2
1.7.0 trunk 1.0.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.8 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9
firebase-authentication / includes / class-firebase-authentication-loader.php
firebase-authentication / includes Last commit date
images 6 years ago class-firebase-authentication-activator.php 6 years ago class-firebase-authentication-deactivator.php 6 years ago class-firebase-authentication-i18n.php 6 years ago class-firebase-authentication-loader.php 6 years ago class-firebase-authentication.php 6 years ago index.php 6 years ago
class-firebase-authentication-loader.php
130 lines
1 <?php
2
3 /**
4 * Register all actions and filters for the plugin
5 *
6 * @link https://miniorange.com
7 * @since 1.0.0
8 *
9 * @package Firebase_Authentication
10 * @subpackage Firebase_Authentication/includes
11 */
12
13 /**
14 * Register all actions and filters for the plugin.
15 *
16 * Maintain a list of all hooks that are registered throughout
17 * the plugin, and register them with the WordPress API. Call the
18 * run function to execute the list of actions and filters.
19 *
20 * @package Firebase_Authentication
21 * @subpackage Firebase_Authentication/includes
22 * @author miniOrange <info@miniorange.com>
23 */
24 class MO_Firebase_Authentication_Loader {
25
26 /**
27 * The array of actions registered with WordPress.
28 *
29 * @since 1.0.0
30 * @access protected
31 * @var array $actions The actions registered with WordPress to fire when the plugin loads.
32 */
33 protected $actions;
34
35 /**
36 * The array of filters registered with WordPress.
37 *
38 * @since 1.0.0
39 * @access protected
40 * @var array $filters The filters registered with WordPress to fire when the plugin loads.
41 */
42 protected $filters;
43
44 /**
45 * Initialize the collections used to maintain the actions and filters.
46 *
47 * @since 1.0.0
48 */
49 public function __construct() {
50
51 $this->actions = array();
52 $this->filters = array();
53
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 /**
113 * Register the filters and actions with WordPress.
114 *
115 * @since 1.0.0
116 */
117 public function run() {
118
119 foreach ( $this->filters as $hook ) {
120 add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
121 }
122
123 foreach ( $this->actions as $hook ) {
124 add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
125 }
126
127 }
128
129 }
130