PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 2.0.13
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v2.0.13
5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 5.5.43 All 159 releases
← All changes | includes/class-wp-data-access-loader.php +23 -32 5.5.32.0.13 View file →
@@ -9,8 +9,9 @@
9 9 * Class WP_Data_Access_Loader
10 10 *
11 11 * Adds and activates plugin filters and actions.
12 12 *
13 + * @package plugin\includes
13 14 * @author Peter Schulz
14 15 * @since 1.0.0
15 16 */
16 17 class WP_Data_Access_Loader {
@@ -19,9 +20,9 @@
19 20 * Registered plugin actions
20 21 *
21 22 * @var array
22 23 */
23 - protected $actions = array();
24 + protected $actions = [];
24 25
25 26 /**
26 27 * Registered plugin filters
27 28 *
@@ -26,9 +27,9 @@
26 27 * Registered plugin filters
27 28 *
28 29 * @var array
29 30 */
30 - protected $filters = array();
31 + protected $filters = [];
31 32
32 33 /**
33 34 * Adds an action to the action array
34 35 *
@@ -33,20 +34,22 @@
33 34 * Adds an action to the action array
34 35 *
35 36 * Calls method add the create array element to be added to action array.
36 37 *
38 + * @since 1.0.0
39 + *
40 + * @see WP_Data_Access_Loader::add()
41 + *
37 42 * @param string $hook Action name to be registered.
38 43 * @param object $component Reference to object to which the action will be applied.
39 44 * @param string $callback Callback function: method of $component object.
40 45 * @param int $priority Priority of the action (default = 10).
41 46 * @param int $accepted_args Number of accepted arguments of callback (default = 1).
42 - *
43 - * @see WP_Data_Access_Loader::add()
44 - *
45 - * @since 1.0.0
46 47 */
47 48 public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
49 +
48 50 $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
51 +
49 52 }
50 53
51 54 /**
52 55 * Create action or filter element
@@ -52,8 +55,10 @@
52 55 * Create action or filter element
53 56 *
54 57 * Generic creation of an element that can be added to the action array or filter array.
55 58 *
59 + * @since 1.0.0
60 + *
56 61 * @param array $hooks Action or filter array to which the hook is added.
57 62 * @param string $hook Action or filter name to be registered.
58 63 * @param object $component Reference to object to which the action or filter will be applied.
59 64 * @param string $callback Callback function: method of $component object.
@@ -58,22 +63,22 @@
58 63 * @param object $component Reference to object to which the action or filter will be applied.
59 64 * @param string $callback Callback function: method of $component object.
60 65 * @param int $priority Priority of the action or action.
61 66 * @param int $accepted_args Number of accepted arguments of callback.
62 - *
63 67 * @return array
64 - * @since 1.0.0
65 68 */
66 69 protected function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
67 - $hooks[] = array(
70 +
71 + $hooks[] = [
68 72 'hook' => $hook,
69 73 'component' => $component,
70 74 'callback' => $callback,
71 75 'priority' => $priority,
72 76 'accepted_args' => $accepted_args,
73 - );
77 + ];
74 78
75 79 return $hooks;
80 +
76 81 }
77 82
78 83 /**
79 84 * Adds a filter to the filter array
@@ -79,17 +84,17 @@
79 84 * Adds a filter to the filter array
80 85 *
81 86 * Calls method add the create array element to be added to filter array.
82 87 *
88 + * @since 1.0.0
89 + *
90 + * @see WP_Data_Access_Loader::add()
91 + *
83 92 * @param string $hook Filter name to be registered.
84 93 * @param object $component Reference to object to which the filter will be applied.
85 94 * @param string $callback Callback function: method of $component object.
86 95 * @param int $priority Priority of the filter (default = 10).
87 96 * @param int $accepted_args Number of accepted arguments of callback (default = 1).
88 - *
89 - * @see WP_Data_Access_Loader::add()
90 - *
91 - * @since 1.0.0
92 97 */
93 98 public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
94 99 $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
95 100 }
@@ -99,30 +104,16 @@
99 104 *
100 105 * @since 1.0.0
101 106 */
102 107 public function run() {
108 +
103 109 foreach ( $this->filters as $hook ) {
104 - add_filter(
105 - $hook['hook'],
106 - array(
107 - $hook['component'],
108 - $hook['callback'],
109 - ),
110 - $hook['priority'],
111 - $hook['accepted_args']
112 - );
110 + add_filter( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'], $hook['accepted_args'] );
113 111 }
114 112
115 113 foreach ( $this->actions as $hook ) {
116 - add_action(
117 - $hook['hook'],
118 - array(
119 - $hook['component'],
120 - $hook['callback'],
121 - ),
122 - $hook['priority'],
123 - $hook['accepted_args']
124 - );
114 + add_action( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'], $hook['accepted_args'] );
125 115 }
116 +
126 117 }
127 118
128 119 }