@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | array $args = array() |
64 | 64 | ) { |
65 | 65 | |
66 | - $classes = $this->get_deep( $this->classes, $parent_slugs ); |
|
66 | + $classes = $this->get_deep($this->classes, $parent_slugs); |
|
67 | 67 | |
68 | - if ( ! $classes || ! isset( $classes['_classes'] ) ) { |
|
68 | + if ( ! $classes || ! isset($classes['_classes'])) { |
|
69 | 69 | return array(); |
70 | 70 | } |
71 | 71 | |
72 | - if ( $this->settings['pass_slugs'] ) { |
|
73 | - array_unshift( $args, $parent_slugs ); |
|
72 | + if ($this->settings['pass_slugs']) { |
|
73 | + array_unshift($args, $parent_slugs); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return WordPoints_Class_Registry::construct_with_args( |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @since 2.2.0 |
85 | 85 | */ |
86 | - public function get_children_slugs( array $parent_slugs = array() ) { |
|
86 | + public function get_children_slugs(array $parent_slugs = array()) { |
|
87 | 87 | |
88 | 88 | $slugs = array(); |
89 | 89 | |
90 | - $classes = $this->get_deep( $this->classes, $parent_slugs ); |
|
90 | + $classes = $this->get_deep($this->classes, $parent_slugs); |
|
91 | 91 | |
92 | - if ( $classes && isset( $classes['_classes'] ) ) { |
|
93 | - $slugs = array_keys( $classes['_classes'] ); |
|
92 | + if ($classes && isset($classes['_classes'])) { |
|
93 | + $slugs = array_keys($classes['_classes']); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return $slugs; |
@@ -110,29 +110,29 @@ discard block |
||
110 | 110 | array $args = array() |
111 | 111 | ) { |
112 | 112 | |
113 | - $classes = $this->get_deep( $this->classes, $parent_slugs ); |
|
113 | + $classes = $this->get_deep($this->classes, $parent_slugs); |
|
114 | 114 | |
115 | - if ( ! $classes || ! isset( $classes['_classes'][ $slug ] ) ) { |
|
115 | + if ( ! $classes || ! isset($classes['_classes'][$slug])) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - $class = $classes['_classes'][ $slug ]; |
|
119 | + $class = $classes['_classes'][$slug]; |
|
120 | 120 | |
121 | - if ( empty( $args ) ) { |
|
121 | + if (empty($args)) { |
|
122 | 122 | |
123 | - if ( $this->settings['pass_slugs'] ) { |
|
124 | - return new $class( $slug, $parent_slugs ); |
|
123 | + if ($this->settings['pass_slugs']) { |
|
124 | + return new $class($slug, $parent_slugs); |
|
125 | 125 | } else { |
126 | 126 | return new $class(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | } else { |
130 | 130 | |
131 | - if ( $this->settings['pass_slugs'] ) { |
|
132 | - array_unshift( $args, $slug, $parent_slugs ); |
|
131 | + if ($this->settings['pass_slugs']) { |
|
132 | + array_unshift($args, $slug, $parent_slugs); |
|
133 | 133 | } |
134 | 134 | |
135 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
135 | + return wordpoints_construct_class_with_args($class, $args); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | |
149 | 149 | $classes = &$this->classes; |
150 | 150 | |
151 | - foreach ( $parent_slugs as $parent_slug ) { |
|
151 | + foreach ($parent_slugs as $parent_slug) { |
|
152 | 152 | |
153 | - if ( ! isset( $classes[ $parent_slug ] ) ) { |
|
154 | - $classes[ $parent_slug ] = array(); |
|
153 | + if ( ! isset($classes[$parent_slug])) { |
|
154 | + $classes[$parent_slug] = array(); |
|
155 | 155 | } |
156 | 156 | |
157 | - $classes =& $classes[ $parent_slug ]; |
|
157 | + $classes = & $classes[$parent_slug]; |
|
158 | 158 | } |
159 | 159 | |
160 | - $classes['_classes'][ $slug ] = $class; |
|
160 | + $classes['_classes'][$slug] = $class; |
|
161 | 161 | |
162 | 162 | return true; |
163 | 163 | } |
@@ -165,43 +165,43 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * @since 2.2.0 |
167 | 167 | */ |
168 | - public function deregister( $slug, array $parent_slugs = array() ) { |
|
168 | + public function deregister($slug, array $parent_slugs = array()) { |
|
169 | 169 | |
170 | - $classes = &$this->get_deep( $this->classes, $parent_slugs ); |
|
170 | + $classes = &$this->get_deep($this->classes, $parent_slugs); |
|
171 | 171 | |
172 | - if ( ! $classes ) { |
|
172 | + if ( ! $classes) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | - unset( $classes['_classes'][ $slug ] ); |
|
176 | + unset($classes['_classes'][$slug]); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @since 2.2.0 |
181 | 181 | */ |
182 | - public function deregister_children( array $parent_slugs = array() ) { |
|
182 | + public function deregister_children(array $parent_slugs = array()) { |
|
183 | 183 | |
184 | - $classes = &$this->get_deep( $this->classes, $parent_slugs ); |
|
184 | + $classes = &$this->get_deep($this->classes, $parent_slugs); |
|
185 | 185 | |
186 | - if ( ! $classes ) { |
|
186 | + if ( ! $classes) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | - unset( $classes['_classes'] ); |
|
190 | + unset($classes['_classes']); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @since 2.2.0 |
195 | 195 | */ |
196 | - public function is_registered( $slug, array $parent_slugs = array() ) { |
|
196 | + public function is_registered($slug, array $parent_slugs = array()) { |
|
197 | 197 | |
198 | 198 | $parent_slugs[] = '_classes'; |
199 | 199 | |
200 | - if ( null !== $slug ) { |
|
200 | + if (null !== $slug) { |
|
201 | 201 | $parent_slugs[] = $slug; |
202 | 202 | } |
203 | 203 | |
204 | - return (bool) $this->get_deep( $this->classes, $parent_slugs ); |
|
204 | + return (bool) $this->get_deep($this->classes, $parent_slugs); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,19 +214,19 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return mixed|false A reference to the value, or false if not found. |
216 | 216 | */ |
217 | - protected function &get_deep( array &$array, array $indexes ) { |
|
217 | + protected function &get_deep(array &$array, array $indexes) { |
|
218 | 218 | |
219 | 219 | // Only variable references can be returned by reference. |
220 | 220 | $false = false; |
221 | 221 | $false_reference = &$false; |
222 | 222 | |
223 | - foreach ( $indexes as $index ) { |
|
223 | + foreach ($indexes as $index) { |
|
224 | 224 | |
225 | - if ( ! isset( $array[ $index ] ) ) { |
|
225 | + if ( ! isset($array[$index])) { |
|
226 | 226 | return $false_reference; |
227 | 227 | } |
228 | 228 | |
229 | - $array = &$array[ $index ]; |
|
229 | + $array = &$array[$index]; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $array; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return object|false The object or false if it is not registered. |
52 | 52 | */ |
53 | - public function get( $slug ); |
|
53 | + public function get($slug); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Register a type of object. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return bool Whether the class was registered successfully. |
65 | 65 | */ |
66 | - public function register( $slug, $class, array $args = array() ); |
|
66 | + public function register($slug, $class, array $args = array()); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Deregister a type of object |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param string $slug The slug of the class to deregister. |
74 | 74 | */ |
75 | - public function deregister( $slug ); |
|
75 | + public function deregister($slug); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Check if a type of object is registered by its slug. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool Whether the class is registered. |
85 | 85 | */ |
86 | - public function is_registered( $slug ); |
|
86 | + public function is_registered($slug); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // EOF |
@@ -71,6 +71,7 @@ |
||
71 | 71 | * @since 2.1.0 |
72 | 72 | * |
73 | 73 | * @param string $slug The slug of the class to deregister. |
74 | + * @return void |
|
74 | 75 | */ |
75 | 76 | public function deregister( $slug ); |
76 | 77 |
@@ -30,46 +30,46 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @since 2.1.0 |
32 | 32 | */ |
33 | - public function get_all( array $args = array() ) { |
|
34 | - return self::construct_with_args( $this->classes, $args ); |
|
33 | + public function get_all(array $args = array()) { |
|
34 | + return self::construct_with_args($this->classes, $args); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | 40 | public function get_all_slugs() { |
41 | - return array_keys( $this->classes ); |
|
41 | + return array_keys($this->classes); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @since 2.1.0 |
46 | 46 | */ |
47 | - public function get( $slug, array $args = array() ) { |
|
47 | + public function get($slug, array $args = array()) { |
|
48 | 48 | |
49 | - if ( ! isset( $this->classes[ $slug ] ) ) { |
|
49 | + if ( ! isset($this->classes[$slug])) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - if ( ! empty( $args ) ) { |
|
53 | + if ( ! empty($args)) { |
|
54 | 54 | |
55 | - array_unshift( $args, $slug ); |
|
55 | + array_unshift($args, $slug); |
|
56 | 56 | |
57 | 57 | return wordpoints_construct_class_with_args( |
58 | - $this->classes[ $slug ] |
|
58 | + $this->classes[$slug] |
|
59 | 59 | , $args |
60 | 60 | ); |
61 | 61 | |
62 | 62 | } else { |
63 | - return new $this->classes[ $slug ]( $slug ); |
|
63 | + return new $this->classes[$slug]($slug); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @since 2.1.0 |
69 | 69 | */ |
70 | - public function register( $slug, $class, array $args = array() ) { |
|
70 | + public function register($slug, $class, array $args = array()) { |
|
71 | 71 | |
72 | - $this->classes[ $slug ] = $class; |
|
72 | + $this->classes[$slug] = $class; |
|
73 | 73 | |
74 | 74 | return true; |
75 | 75 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @since 2.1.0 |
79 | 79 | */ |
80 | - public function deregister( $slug ) { |
|
80 | + public function deregister($slug) { |
|
81 | 81 | |
82 | - unset( $this->classes[ $slug ] ); |
|
82 | + unset($this->classes[$slug]); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @since 2.1.0 |
87 | 87 | */ |
88 | - public function is_registered( $slug ) { |
|
88 | + public function is_registered($slug) { |
|
89 | 89 | |
90 | - return isset( $this->classes[ $slug ] ); |
|
90 | + return isset($this->classes[$slug]); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -114,39 +114,39 @@ discard block |
||
114 | 114 | array $args = array() |
115 | 115 | ) { |
116 | 116 | |
117 | - $pass_slugs = ( ! isset( $args['pass_slugs'] ) || $args['pass_slugs'] ); |
|
117 | + $pass_slugs = ( ! isset($args['pass_slugs']) || $args['pass_slugs']); |
|
118 | 118 | |
119 | 119 | $objects = array(); |
120 | 120 | |
121 | - if ( empty( $construct_with_args ) ) { |
|
121 | + if (empty($construct_with_args)) { |
|
122 | 122 | |
123 | - if ( $pass_slugs ) { |
|
124 | - foreach ( $classes as $slug => $class ) { |
|
125 | - $objects[ $slug ] = new $class( $slug ); |
|
123 | + if ($pass_slugs) { |
|
124 | + foreach ($classes as $slug => $class) { |
|
125 | + $objects[$slug] = new $class($slug); |
|
126 | 126 | } |
127 | 127 | } else { |
128 | - foreach ( $classes as $slug => $class ) { |
|
129 | - $objects[ $slug ] = new $class(); |
|
128 | + foreach ($classes as $slug => $class) { |
|
129 | + $objects[$slug] = new $class(); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | } else { |
134 | 134 | |
135 | - if ( $pass_slugs ) { |
|
135 | + if ($pass_slugs) { |
|
136 | 136 | |
137 | - array_unshift( $construct_with_args, null ); |
|
137 | + array_unshift($construct_with_args, null); |
|
138 | 138 | |
139 | - foreach ( $classes as $slug => $class ) { |
|
140 | - $objects[ $slug ] = wordpoints_construct_class_with_args( |
|
139 | + foreach ($classes as $slug => $class) { |
|
140 | + $objects[$slug] = wordpoints_construct_class_with_args( |
|
141 | 141 | $class |
142 | - , array( $slug ) + $construct_with_args |
|
142 | + , array($slug) + $construct_with_args |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | 146 | } else { |
147 | 147 | |
148 | - foreach ( $classes as $slug => $class ) { |
|
149 | - $objects[ $slug ] = wordpoints_construct_class_with_args( |
|
148 | + foreach ($classes as $slug => $class) { |
|
149 | + $objects[$slug] = wordpoints_construct_class_with_args( |
|
150 | 150 | $class |
151 | 151 | , $construct_with_args |
152 | 152 | ); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * |
43 | 43 | * @return mixed|WP_Error The validated value or a WP_Error on failure. |
44 | 44 | */ |
45 | - public function validate_value( $value ); |
|
45 | + public function validate_value($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // EOF |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @param string $slug The slug of this data type. |
30 | 30 | */ |
31 | - public function __construct( $slug ) { |
|
31 | + public function __construct($slug) { |
|
32 | 32 | $this->slug = $slug; |
33 | 33 | } |
34 | 34 |
@@ -76,7 +76,7 @@ |
||
76 | 76 | * |
77 | 77 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
78 | 78 | */ |
79 | - public function hit( WordPoints_Hook_Fire $fire ); |
|
79 | + public function hit(WordPoints_Hook_Fire $fire); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // EOF |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @since 2.1.0 |
91 | 91 | */ |
92 | - public function __call( $name, $args ) { |
|
92 | + public function __call($name, $args) { |
|
93 | 93 | |
94 | - $this->route_action( $name, $args ); |
|
94 | + $this->route_action($name, $args); |
|
95 | 95 | |
96 | 96 | // Return the first value, in case it is hooked to a filter. |
97 | 97 | $return = null; |
98 | - if ( isset( $args[0] ) ) { |
|
98 | + if (isset($args[0])) { |
|
99 | 99 | $return = $args[0]; |
100 | 100 | } |
101 | 101 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * action name and the priority. |
113 | 113 | * @param array $args The args the action was fired with. |
114 | 114 | */ |
115 | - protected function route_action( $name, $args ) { |
|
115 | + protected function route_action($name, $args) { |
|
116 | 116 | |
117 | - if ( ! isset( $this->action_index[ $name ] ) ) { |
|
117 | + if ( ! isset($this->action_index[$name])) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
@@ -122,48 +122,48 @@ discard block |
||
122 | 122 | // registry attempts to access the router in its own constructor. The result |
123 | 123 | // of attempting to do this before the router itself has been fully |
124 | 124 | // constructed is that the events registry gets null instead of the router. |
125 | - if ( ! isset( $this->hooks ) ) { |
|
125 | + if ( ! isset($this->hooks)) { |
|
126 | 126 | |
127 | 127 | $hooks = wordpoints_hooks(); |
128 | 128 | |
129 | 129 | $this->hooks = $hooks; |
130 | - $this->events = $hooks->get_sub_app( 'events' ); |
|
131 | - $this->actions = $hooks->get_sub_app( 'actions' ); |
|
132 | - $this->event_args = $this->events->get_sub_app( 'args' ); |
|
130 | + $this->events = $hooks->get_sub_app('events'); |
|
131 | + $this->actions = $hooks->get_sub_app('actions'); |
|
132 | + $this->event_args = $this->events->get_sub_app('args'); |
|
133 | 133 | } |
134 | 134 | |
135 | - foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) { |
|
135 | + foreach ($this->action_index[$name]['actions'] as $slug => $data) { |
|
136 | 136 | |
137 | - if ( ! isset( $this->event_index[ $slug ] ) ) { |
|
137 | + if ( ! isset($this->event_index[$slug])) { |
|
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | |
141 | - $action_object = $this->actions->get( $slug, $args, $data ); |
|
141 | + $action_object = $this->actions->get($slug, $args, $data); |
|
142 | 142 | |
143 | - if ( ! ( $action_object instanceof WordPoints_Hook_ActionI ) ) { |
|
143 | + if ( ! ($action_object instanceof WordPoints_Hook_ActionI)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | - if ( ! $action_object->should_fire() ) { |
|
147 | + if ( ! $action_object->should_fire()) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | |
151 | - foreach ( $this->event_index[ $slug ] as $type => $events ) { |
|
152 | - foreach ( $events as $event_slug => $unused ) { |
|
151 | + foreach ($this->event_index[$slug] as $type => $events) { |
|
152 | + foreach ($events as $event_slug => $unused) { |
|
153 | 153 | |
154 | - if ( ! $this->events->is_registered( $event_slug ) ) { |
|
154 | + if ( ! $this->events->is_registered($event_slug)) { |
|
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | - $event_args = $this->event_args->get_children( $event_slug, array( $action_object ) ); |
|
158 | + $event_args = $this->event_args->get_children($event_slug, array($action_object)); |
|
159 | 159 | |
160 | - if ( empty( $event_args ) ) { |
|
160 | + if (empty($event_args)) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
164 | - $event_args = new WordPoints_Hook_Event_Args( $event_args ); |
|
164 | + $event_args = new WordPoints_Hook_Event_Args($event_args); |
|
165 | 165 | |
166 | - $this->hooks->fire( $event_slug, $event_args, $type ); |
|
166 | + $this->hooks->fire($event_slug, $event_args, $type); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -192,56 +192,56 @@ discard block |
||
192 | 192 | * } |
193 | 193 | * } |
194 | 194 | */ |
195 | - public function add_action( $slug, array $args ) { |
|
195 | + public function add_action($slug, array $args) { |
|
196 | 196 | |
197 | 197 | $priority = 10; |
198 | - if ( isset( $args['priority'] ) ) { |
|
198 | + if (isset($args['priority'])) { |
|
199 | 199 | $priority = $args['priority']; |
200 | 200 | } |
201 | 201 | |
202 | - if ( ! isset( $args['action'] ) ) { |
|
202 | + if ( ! isset($args['action'])) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $method = "{$args['action']},{$priority}"; |
207 | 207 | |
208 | - $this->action_index[ $method ]['actions'][ $slug ] = array(); |
|
208 | + $this->action_index[$method]['actions'][$slug] = array(); |
|
209 | 209 | |
210 | 210 | $arg_number = 1; |
211 | 211 | |
212 | - if ( isset( $args['data'] ) ) { |
|
212 | + if (isset($args['data'])) { |
|
213 | 213 | |
214 | - if ( isset( $args['data']['arg_index'] ) ) { |
|
215 | - $arg_number = 1 + max( $args['data']['arg_index'] ); |
|
214 | + if (isset($args['data']['arg_index'])) { |
|
215 | + $arg_number = 1 + max($args['data']['arg_index']); |
|
216 | 216 | } |
217 | 217 | |
218 | - if ( isset( $args['data']['requirements'] ) ) { |
|
219 | - $requirements = 1 + max( array_keys( $args['data']['requirements'] ) ); |
|
218 | + if (isset($args['data']['requirements'])) { |
|
219 | + $requirements = 1 + max(array_keys($args['data']['requirements'])); |
|
220 | 220 | |
221 | - if ( $requirements > $arg_number ) { |
|
221 | + if ($requirements > $arg_number) { |
|
222 | 222 | $arg_number = $requirements; |
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | - $this->action_index[ $method ]['actions'][ $slug ] = $args['data']; |
|
226 | + $this->action_index[$method]['actions'][$slug] = $args['data']; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( isset( $args['arg_number'] ) ) { |
|
229 | + if (isset($args['arg_number'])) { |
|
230 | 230 | $arg_number = $args['arg_number']; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // If this action is already being routed, and will have enough args, we |
234 | 234 | // don't need to hook to it again. |
235 | 235 | if ( |
236 | - isset( $this->action_index[ $method ]['arg_number'] ) |
|
237 | - && $this->action_index[ $method ]['arg_number'] >= $arg_number |
|
236 | + isset($this->action_index[$method]['arg_number']) |
|
237 | + && $this->action_index[$method]['arg_number'] >= $arg_number |
|
238 | 238 | ) { |
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
242 | - $this->action_index[ $method ]['arg_number'] = $arg_number; |
|
242 | + $this->action_index[$method]['arg_number'] = $arg_number; |
|
243 | 243 | |
244 | - add_action( $args['action'], array( $this, $method ), $priority, $arg_number ); |
|
244 | + add_action($args['action'], array($this, $method), $priority, $arg_number); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -251,20 +251,20 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param string $slug The action slug. |
253 | 253 | */ |
254 | - public function remove_action( $slug ) { |
|
254 | + public function remove_action($slug) { |
|
255 | 255 | |
256 | - foreach ( $this->action_index as $method => $data ) { |
|
257 | - if ( isset( $data['actions'][ $slug ] ) ) { |
|
256 | + foreach ($this->action_index as $method => $data) { |
|
257 | + if (isset($data['actions'][$slug])) { |
|
258 | 258 | |
259 | - unset( $this->action_index[ $method ]['actions'][ $slug ] ); |
|
259 | + unset($this->action_index[$method]['actions'][$slug]); |
|
260 | 260 | |
261 | - if ( empty( $this->action_index[ $method ]['actions'] ) ) { |
|
261 | + if (empty($this->action_index[$method]['actions'])) { |
|
262 | 262 | |
263 | - unset( $this->action_index[ $method ] ); |
|
263 | + unset($this->action_index[$method]); |
|
264 | 264 | |
265 | - list( $action, $priority ) = explode( ',', $method ); |
|
265 | + list($action, $priority) = explode(',', $method); |
|
266 | 266 | |
267 | - remove_action( $action, array( $this, $method ), $priority ); |
|
267 | + remove_action($action, array($this, $method), $priority); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | } |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param string $action_slug The slug of the action. |
280 | 280 | * @param string $action_type The type of action. Default is 'fire'. |
281 | 281 | */ |
282 | - public function add_event_to_action( $event_slug, $action_slug, $action_type = 'fire' ) { |
|
283 | - $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] = true; |
|
282 | + public function add_event_to_action($event_slug, $action_slug, $action_type = 'fire') { |
|
283 | + $this->event_index[$action_slug][$action_type][$event_slug] = true; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $action_slug The slug of the action. |
293 | 293 | * @param string $action_type The type of action. Default is 'fire'. |
294 | 294 | */ |
295 | - public function remove_event_from_action( $event_slug, $action_slug, $action_type = 'fire' ) { |
|
296 | - unset( $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] ); |
|
295 | + public function remove_event_from_action($event_slug, $action_slug, $action_type = 'fire') { |
|
296 | + unset($this->event_index[$action_slug][$action_type][$event_slug]); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function get_event_index() { |
307 | 307 | |
308 | - if ( empty( $this->event_index ) ) { |
|
309 | - wordpoints_hooks()->get_sub_app( 'events' ); |
|
308 | + if (empty($this->event_index)) { |
|
309 | + wordpoints_hooks()->get_sub_app('events'); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | return $this->event_index; |
@@ -32,36 +32,36 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @since 2.1.0 |
34 | 34 | */ |
35 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
35 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
36 | 36 | |
37 | - if ( ! $this->get_settings_from_fire( $fire ) ) { |
|
37 | + if ( ! $this->get_settings_from_fire($fire)) { |
|
38 | 38 | return true; |
39 | 39 | } |
40 | 40 | |
41 | - $ids = $this->get_hits_to_be_reversed( $fire ); |
|
41 | + $ids = $this->get_hits_to_be_reversed($fire); |
|
42 | 42 | |
43 | - return count( $ids ) > 0; |
|
43 | + return count($ids) > 0; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @since 2.1.0 |
48 | 48 | */ |
49 | - public function after_hit( WordPoints_Hook_Fire $fire ) { |
|
49 | + public function after_hit(WordPoints_Hook_Fire $fire) { |
|
50 | 50 | |
51 | - if ( ! $this->get_settings_from_fire( $fire ) ) { |
|
51 | + if ( ! $this->get_settings_from_fire($fire)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - foreach ( $this->get_hits_to_be_reversed( $fire ) as $id ) { |
|
56 | - add_metadata( 'wordpoints_hook_hit', $id, 'reverse_fired', true ); |
|
55 | + foreach ($this->get_hits_to_be_reversed($fire) as $id) { |
|
56 | + add_metadata('wordpoints_hook_hit', $id, 'reverse_fired', true); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @since 2.1.0 |
62 | 62 | */ |
63 | - public function after_miss( WordPoints_Hook_Fire $fire ) { |
|
64 | - $this->after_hit( $fire ); |
|
63 | + public function after_miss(WordPoints_Hook_Fire $fire) { |
|
64 | + $this->after_hit($fire); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The IDs the hits to be reversed. |
75 | 75 | */ |
76 | - protected function get_hits_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
|
76 | + protected function get_hits_to_be_reversed(WordPoints_Hook_Fire $fire) { |
|
77 | 77 | |
78 | 78 | // We cache these so that we don't run the query both before and after the |
79 | 79 | // fire. |
80 | - if ( isset( $fire->data[ $this->slug ]['hit_ids'] ) ) { |
|
81 | - return $fire->data[ $this->slug ]['hit_ids']; |
|
80 | + if (isset($fire->data[$this->slug]['hit_ids'])) { |
|
81 | + return $fire->data[$this->slug]['hit_ids']; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $query = $fire->get_matching_hits_query(); |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | $query->set_args( |
87 | 87 | array( |
88 | 88 | 'fields' => 'id', |
89 | - 'action_type' => $this->get_settings_from_fire( $fire ), |
|
89 | + 'action_type' => $this->get_settings_from_fire($fire), |
|
90 | 90 | 'meta_key' => 'reverse_fired', |
91 | 91 | 'meta_compare' => 'NOT EXISTS', |
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | |
95 | - $ids = $query->get( 'col' ); |
|
95 | + $ids = $query->get('col'); |
|
96 | 96 | |
97 | - if ( ! $ids ) { |
|
97 | + if ( ! $ids) { |
|
98 | 98 | $ids = array(); |
99 | 99 | } |
100 | 100 | |
101 | - $fire->data[ $this->slug ]['hit_ids'] = $ids; |
|
101 | + $fire->data[$this->slug]['hit_ids'] = $ids; |
|
102 | 102 | |
103 | 103 | return $ids; |
104 | 104 | } |
@@ -24,15 +24,15 @@ |
||
24 | 24 | /** |
25 | 25 | * @since 2.1.0 |
26 | 26 | */ |
27 | - public function validate_action_type_settings( $settings ) { |
|
27 | + public function validate_action_type_settings($settings) { |
|
28 | 28 | return (bool) $settings; |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @since 2.1.0 |
33 | 33 | */ |
34 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
35 | - return ! $this->get_settings_from_fire( $fire ); |
|
34 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
35 | + return ! $this->get_settings_from_fire($fire); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 |