PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.15
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.15
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-loader.php

class-loader.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.15, at includes/class-loader.php

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