PluginProbe ʕ •ᴥ•ʔ
Catch Scroll Progress Bar / 2.1
Catch Scroll Progress Bar v2.1
trunk 1.0.0 1.1 1.2 1.3 1.4 1.5 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 2.0 2.1 2.2
catch-scroll-progress-bar / includes / class-catch-scroll-progress-bar-loader.php
catch-scroll-progress-bar / includes Last commit date
CatchThemesThemePlugin.php 4 months ago class-catch-scroll-progress-bar-activator.php 4 months ago class-catch-scroll-progress-bar-deactivator.php 4 months ago class-catch-scroll-progress-bar-i18n.php 4 months ago class-catch-scroll-progress-bar-loader.php 4 months ago class-catch-scroll-progress-bar.php 4 months ago ctp-tabs-removal.php 4 months ago index.php 4 months ago
class-catch-scroll-progress-bar-loader.php
126 lines
1 <?php
2
3 // Exit if accessed directly
4 if (! defined('ABSPATH')) exit;
5
6 /**
7 * Register all actions and filters for the plugin
8 *
9 * @link www.catchplugins.com
10 * @since 1.0.0
11 *
12 * @package Catch_Progress_Bar
13 * @subpackage Catch_Progress_Bar/includes
14 * @author Catch Plugins <www.catchplugins.com>
15 */
16
17
18 class Catch_Scroll_Progress_Bar_Loader
19 {
20
21 /**
22 * The array of actions registered with WordPress.
23 *
24 * @since 1.0.0
25 * @access protected
26 * @var array $actions The actions registered with WordPress to fire when the plugin loads.
27 */
28 protected $actions;
29
30 /**
31 * The array of filters registered with WordPress.
32 *
33 * @since 1.0.0
34 * @access protected
35 * @var array $filters The filters registered with WordPress to fire when the plugin loads.
36 */
37 protected $filters;
38
39 /**
40 * Initialize the collections used to maintain the actions and filters.
41 *
42 * @since 1.0.0
43 */
44 public function __construct()
45 {
46
47 $this->actions = array();
48 $this->filters = array();
49 }
50
51 /**
52 * Add a new action to the collection to be registered with WordPress.
53 *
54 * @since 1.0.0
55 * @param string $hook The name of the WordPress action that is being registered.
56 * @param object $component A reference to the instance of the object on which the action is defined.
57 * @param string $callback The name of the function definition on the $component.
58 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
59 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
60 */
61 public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
62 {
63 $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
64 }
65
66 /**
67 * Add a new filter to the collection to be registered with WordPress.
68 *
69 * @since 1.0.0
70 * @param string $hook The name of the WordPress filter that is being registered.
71 * @param object $component A reference to the instance of the object on which the filter is defined.
72 * @param string $callback The name of the function definition on the $component.
73 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
74 * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
75 */
76 public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
77 {
78 $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
79 }
80
81 /**
82 * A utility function that is used to register the actions and hooks into a single
83 * collection.
84 *
85 * @since 1.0.0
86 * @access private
87 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
88 * @param string $hook The name of the WordPress filter that is being registered.
89 * @param object $component A reference to the instance of the object on which the filter is defined.
90 * @param string $callback The name of the function definition on the $component.
91 * @param int $priority The priority at which the function should be fired.
92 * @param int $accepted_args The number of arguments that should be passed to the $callback.
93 * @return array The collection of actions and filters registered with WordPress.
94 */
95 private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
96 {
97
98 $hooks[] = array(
99 'hook' => $hook,
100 'component' => $component,
101 'callback' => $callback,
102 'priority' => $priority,
103 'accepted_args' => $accepted_args
104 );
105
106 return $hooks;
107 }
108
109 /**
110 * Register the filters and actions with WordPress.
111 *
112 * @since 1.0.0
113 */
114 public function run()
115 {
116
117 foreach ($this->filters as $hook) {
118 add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
119 }
120
121 foreach ($this->actions as $hook) {
122 add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
123 }
124 }
125 }
126