PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.6.20
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.6.20
2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / includes / class-metasync-loader.php

class-metasync-loader.php in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.6.20, at includes/class-metasync-loader.php

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