PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.0.1
WpStream – Live Streaming, Video on Demand, Pay Per View v4.0.1
4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 4.5.12 All 180 releases
wpstream / includes / class-wpstream-loader.php

class-wpstream-loader.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.0.1, at includes/class-wpstream-loader.php

130 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 /**
4 * Register all actions and filters for the plugin
5 *
6 * @link http://wpstream.net
7 * @since 3.0.1
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/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 Wpstream
21 * @subpackage Wpstream/includes
22 * @author wpstream <office@wpstream.net>
23 */
24 class Wpstream_Loader {
25
26 /**
27 * The array of actions registered with WordPress.
28 *
29 * @since 3.0.1
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 3.0.1
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 3.0.1
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 3.0.1
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 3.0.1
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 3.0.1
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 3.0.1
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