@@ -35,7 +35,7 @@ |
||
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | - return __( 'Site', 'wordpoints' ); |
|
38 | + return __('Site', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -22,29 +22,29 @@ |
||
22 | 22 | /** |
23 | 23 | * @since 1.0.0 |
24 | 24 | */ |
25 | - public function get_option( $name ) { |
|
26 | - return get_site_option( $name ); |
|
25 | + public function get_option($name) { |
|
26 | + return get_site_option($name); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @since 1.0.0 |
31 | 31 | */ |
32 | - protected function add_option( $name, $value ) { |
|
33 | - return add_site_option( $name, $value ); |
|
32 | + protected function add_option($name, $value) { |
|
33 | + return add_site_option($name, $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.0.0 |
38 | 38 | */ |
39 | - public function update_option( $name, $value ) { |
|
40 | - return update_site_option( $name, $value ); |
|
39 | + public function update_option($name, $value) { |
|
40 | + return update_site_option($name, $value); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @since 1.0.0 |
45 | 45 | */ |
46 | - protected function delete_option( $name ) { |
|
47 | - return delete_site_option( $name ); |
|
46 | + protected function delete_option($name) { |
|
47 | + return delete_site_option($name); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @since 1.0.0 |
62 | 62 | */ |
63 | - public function __construct( $slug, WordPoints_Hook_Reactor $reactor ) { |
|
63 | + public function __construct($slug, WordPoints_Hook_Reactor $reactor) { |
|
64 | 64 | |
65 | 65 | $this->slug = $slug; |
66 | 66 | $this->reactor = $reactor; |
@@ -84,33 +84,33 @@ discard block |
||
84 | 84 | * @since 1.0.0 |
85 | 85 | */ |
86 | 86 | public function get_context_id() { |
87 | - return wordpoints_entities_get_current_context_id( $this->context ); |
|
87 | + return wordpoints_entities_get_current_context_id($this->context); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @since 1.0.0 |
92 | 92 | */ |
93 | - public function get_reaction( $id ) { |
|
93 | + public function get_reaction($id) { |
|
94 | 94 | |
95 | - if ( ! $this->reaction_exists( $id ) ) { |
|
95 | + if ( ! $this->reaction_exists($id)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - return new $this->reaction_class( $id, $this ); |
|
99 | + return new $this->reaction_class($id, $this); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @since 1.0.0 |
104 | 104 | */ |
105 | - public function create_reaction( array $settings ) { |
|
106 | - return $this->create_or_update_reaction( $settings ); |
|
105 | + public function create_reaction(array $settings) { |
|
106 | + return $this->create_or_update_reaction($settings); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @since 1.0.0 |
111 | 111 | */ |
112 | - public function update_reaction( $id, array $settings ) { |
|
113 | - return $this->create_or_update_reaction( $settings, $id ); |
|
112 | + public function update_reaction($id, array $settings) { |
|
113 | + return $this->create_or_update_reaction($settings, $id); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -125,41 +125,41 @@ discard block |
||
125 | 125 | * The reaction object if created/updated successfully. False or a |
126 | 126 | * validator instance if not. |
127 | 127 | */ |
128 | - protected function create_or_update_reaction( array $settings, $id = null ) { |
|
128 | + protected function create_or_update_reaction(array $settings, $id = null) { |
|
129 | 129 | |
130 | - $is_new = ! isset( $id ); |
|
130 | + $is_new = ! isset($id); |
|
131 | 131 | |
132 | - if ( ! $is_new && ! $this->reaction_exists( $id ) ) { |
|
132 | + if ( ! $is_new && ! $this->reaction_exists($id)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | - $validator = new WordPoints_Hook_Reaction_Validator( $settings, $this->reactor ); |
|
136 | + $validator = new WordPoints_Hook_Reaction_Validator($settings, $this->reactor); |
|
137 | 137 | $settings = $validator->validate(); |
138 | 138 | |
139 | - if ( $validator->had_errors() ) { |
|
139 | + if ($validator->had_errors()) { |
|
140 | 140 | return $validator; |
141 | 141 | } |
142 | 142 | |
143 | - if ( $is_new ) { |
|
143 | + if ($is_new) { |
|
144 | 144 | |
145 | - $id = $this->_create_reaction( $settings['event'] ); |
|
145 | + $id = $this->_create_reaction($settings['event']); |
|
146 | 146 | |
147 | - if ( ! $id ) { |
|
147 | + if ( ! $id) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - $reaction = $this->get_reaction( $id ); |
|
152 | + $reaction = $this->get_reaction($id); |
|
153 | 153 | |
154 | - $reaction->update_event_slug( $settings['event'] ); |
|
154 | + $reaction->update_event_slug($settings['event']); |
|
155 | 155 | |
156 | - unset( $settings['event'] ); |
|
156 | + unset($settings['event']); |
|
157 | 157 | |
158 | - $this->reactor->update_settings( $reaction, $settings ); |
|
158 | + $this->reactor->update_settings($reaction, $settings); |
|
159 | 159 | |
160 | 160 | /** @var WordPoints_Hook_Extension $extension */ |
161 | - foreach ( wordpoints_hooks()->extensions->get_all() as $extension ) { |
|
162 | - $extension->update_settings( $reaction, $settings ); |
|
161 | + foreach (wordpoints_hooks()->extensions->get_all() as $extension) { |
|
162 | + $extension->update_settings($reaction, $settings); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $settings The new settings for the reaction. |
170 | 170 | * @param bool $is_new Whether the reaction was just now created. |
171 | 171 | */ |
172 | - do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new ); |
|
172 | + do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new); |
|
173 | 173 | |
174 | 174 | return $reaction; |
175 | 175 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return int|false The reaction ID, or false if not created. |
188 | 188 | */ |
189 | - abstract protected function _create_reaction( $event_slug ); |
|
189 | + abstract protected function _create_reaction($event_slug); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // EOF |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @since 1.0.0 |
55 | 55 | */ |
56 | - public function __get( $var ) { |
|
56 | + public function __get($var) { |
|
57 | 57 | |
58 | - if ( 'reactions' !== $var ) { |
|
58 | + if ('reactions' !== $var) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | wordpoints_hooks()->get_current_mode() |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! $reaction_group ) { |
|
66 | + if ( ! $reaction_group) { |
|
67 | 67 | return null; |
68 | 68 | } |
69 | 69 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return WordPoints_Hook_Reaction_StorageI|false The reaction storage object. |
81 | 81 | */ |
82 | - public function get_reaction_group( $slug ) { |
|
82 | + public function get_reaction_group($slug) { |
|
83 | 83 | |
84 | 84 | $reaction_group = wordpoints_hooks()->reaction_groups->get( |
85 | 85 | $this->slug |
86 | 86 | , $slug |
87 | - , array( $this ) |
|
87 | + , array($this) |
|
88 | 88 | ); |
89 | 89 | |
90 | - if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI ) { |
|
90 | + if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Allowing access to groups out-of-context would lead to strange behavior. |
95 | - if ( false === $reaction_group->get_context_id() ) { |
|
95 | + if (false === $reaction_group->get_context_id()) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return WordPoints_Hook_ReactionI[] All of the reaction objects. |
168 | 168 | */ |
169 | - public function get_all_reactions_to_event( $event_slug ) { |
|
169 | + public function get_all_reactions_to_event($event_slug) { |
|
170 | 170 | |
171 | 171 | $reactions = array(); |
172 | 172 | |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | $this->slug |
175 | 175 | ); |
176 | 176 | |
177 | - foreach ( $slugs as $slug ) { |
|
177 | + foreach ($slugs as $slug) { |
|
178 | 178 | |
179 | - $storage = $this->get_reaction_group( $slug ); |
|
179 | + $storage = $this->get_reaction_group($slug); |
|
180 | 180 | |
181 | - if ( ! $storage ) { |
|
181 | + if ( ! $storage) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $reactions = array_merge( |
186 | 186 | $reactions |
187 | - , $storage->get_reactions_to_event( $event_slug ) |
|
187 | + , $storage->get_reactions_to_event($event_slug) |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | $this->slug |
214 | 214 | ); |
215 | 215 | |
216 | - foreach ( $slugs as $slug ) { |
|
216 | + foreach ($slugs as $slug) { |
|
217 | 217 | |
218 | - $storage = $this->get_reaction_group( $slug ); |
|
218 | + $storage = $this->get_reaction_group($slug); |
|
219 | 219 | |
220 | - if ( ! $storage ) { |
|
220 | + if ( ! $storage) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
224 | - $reactions = array_merge( $reactions, $storage->get_reactions() ); |
|
224 | + $reactions = array_merge($reactions, $storage->get_reactions()); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $reactions; |
@@ -237,21 +237,21 @@ discard block |
||
237 | 237 | ) { |
238 | 238 | |
239 | 239 | if ( |
240 | - empty( $settings['target'] ) |
|
241 | - || ! is_array( $settings['target'] ) |
|
240 | + empty($settings['target']) |
|
241 | + || ! is_array($settings['target']) |
|
242 | 242 | ) { |
243 | 243 | |
244 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
244 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
245 | 245 | |
246 | 246 | } else { |
247 | 247 | |
248 | - $target = $event_args->get_from_hierarchy( $settings['target'] ); |
|
248 | + $target = $event_args->get_from_hierarchy($settings['target']); |
|
249 | 249 | |
250 | 250 | if ( |
251 | 251 | ! $target instanceof WordPoints_Entity |
252 | - || ! in_array( $target->get_slug(), (array) $this->arg_types ) |
|
252 | + || ! in_array($target->get_slug(), (array) $this->arg_types) |
|
253 | 253 | ) { |
254 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
254 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | /** |
262 | 262 | * @since 1.0.0 |
263 | 263 | */ |
264 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
265 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
264 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
265 | + $reaction->update_meta('target', $settings['target']); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return mixed The entity, or false if not found. |
108 | 108 | */ |
109 | - protected function get_entity( $id ) { |
|
109 | + protected function get_entity($id) { |
|
110 | 110 | |
111 | - $entity = call_user_func( $this->getter, $id ); |
|
111 | + $entity = call_user_func($this->getter, $id); |
|
112 | 112 | |
113 | - if ( ! $this->is_entity( $entity ) ) { |
|
113 | + if ( ! $this->is_entity($entity)) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return bool Whether the passed value is an entity. |
128 | 128 | */ |
129 | - protected function is_entity( $entity ) { |
|
129 | + protected function is_entity($entity) { |
|
130 | 130 | |
131 | - if ( ! is_object( $entity ) && ! is_array( $entity ) ) { |
|
131 | + if ( ! is_object($entity) && ! is_array($entity)) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | - return (bool) $this->get_entity_id( $entity ); |
|
135 | + return (bool) $this->get_entity_id($entity); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return mixed The value of the attribute of the entity. |
147 | 147 | */ |
148 | - protected function get_attr_value( $entity, $attr ) { |
|
148 | + protected function get_attr_value($entity, $attr) { |
|
149 | 149 | |
150 | - if ( is_array( $entity ) ) { |
|
151 | - if ( isset( $entity[ $attr ] ) ) { |
|
152 | - return $entity[ $attr ]; |
|
150 | + if (is_array($entity)) { |
|
151 | + if (isset($entity[$attr])) { |
|
152 | + return $entity[$attr]; |
|
153 | 153 | } |
154 | 154 | } else { |
155 | - if ( isset( $entity->{$attr} ) ) { |
|
155 | + if (isset($entity->{$attr} )) { |
|
156 | 156 | return $entity->{$attr}; |
157 | 157 | } |
158 | 158 | } |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return mixed The ID of the entity. |
171 | 171 | */ |
172 | - protected function get_entity_id( $entity ) { |
|
173 | - return $this->get_attr_value( $entity, $this->get_id_field() ); |
|
172 | + protected function get_entity_id($entity) { |
|
173 | + return $this->get_attr_value($entity, $this->get_id_field()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return mixed The human ID of the entity. |
188 | 188 | */ |
189 | - protected function get_entity_human_id( $entity ) { |
|
190 | - return $this->get_attr_value( $entity, $this->human_id_field ); |
|
189 | + protected function get_entity_human_id($entity) { |
|
190 | + return $this->get_attr_value($entity, $this->human_id_field); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return string|int|float|false The human identifier for the entity, or false. |
233 | 233 | */ |
234 | - public function get_human_id( $id ) { |
|
234 | + public function get_human_id($id) { |
|
235 | 235 | |
236 | - $entity = $this->get_entity( $id ); |
|
236 | + $entity = $this->get_entity($id); |
|
237 | 237 | |
238 | - if ( ! $entity ) { |
|
238 | + if ( ! $entity) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | - return $this->get_entity_human_id( $entity ); |
|
242 | + return $this->get_entity_human_id($entity); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return bool Whether or not an entity with that ID exists. |
253 | 253 | */ |
254 | - public function exists( $id ) { |
|
255 | - return (bool) $this->get_entity( $id ); |
|
254 | + public function exists($id) { |
|
255 | + return (bool) $this->get_entity($id); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return WordPoints_Entityish|false The child's object, or false if not found. |
269 | 269 | */ |
270 | - public function get_child( $child_slug ) { |
|
270 | + public function get_child($child_slug) { |
|
271 | 271 | |
272 | 272 | $children = wordpoints_entities()->children; |
273 | 273 | |
274 | - $child = $children->get( $this->slug, $child_slug ); |
|
274 | + $child = $children->get($this->slug, $child_slug); |
|
275 | 275 | |
276 | 276 | if ( |
277 | - isset( $this->the_value ) |
|
277 | + isset($this->the_value) |
|
278 | 278 | && $child instanceof WordPoints_Entity_ChildI |
279 | 279 | ) { |
280 | - $child->set_the_value_from_entity( $this ); |
|
280 | + $child->set_the_value_from_entity($this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $child; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return bool Whether the value was set. |
301 | 301 | */ |
302 | - public function set_the_value( $value ) { |
|
302 | + public function set_the_value($value) { |
|
303 | 303 | |
304 | 304 | $this->the_value = $this->the_entity = $this->the_context = null; |
305 | 305 | |
306 | - if ( $this->is_entity( $value ) ) { |
|
306 | + if ($this->is_entity($value)) { |
|
307 | 307 | |
308 | 308 | $entity = $value; |
309 | - $value = $this->get_entity_id( $value ); |
|
309 | + $value = $this->get_entity_id($value); |
|
310 | 310 | |
311 | 311 | } else { |
312 | 312 | |
313 | - $entity = $this->get_entity( $value ); |
|
313 | + $entity = $this->get_entity($value); |
|
314 | 314 | |
315 | - if ( ! $entity ) { |
|
315 | + if ( ! $entity) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | } |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return mixed The value of the attribute. |
337 | 337 | */ |
338 | - public function get_the_attr_value( $attr ) { |
|
339 | - return $this->get_attr_value( $this->the_entity, $attr ); |
|
338 | + public function get_the_attr_value($attr) { |
|
339 | + return $this->get_attr_value($this->the_entity, $attr); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return string|int|float|null The human identifier for the entity, or null. |
361 | 361 | */ |
362 | 362 | public function get_the_human_id() { |
363 | - return $this->get_entity_human_id( $this->the_entity ); |
|
363 | + return $this->get_entity_human_id($this->the_entity); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | |
392 | 392 | $guid = $this->get_the_context(); |
393 | 393 | |
394 | - if ( ! is_array( $guid ) ) { |
|
394 | + if ( ! is_array($guid)) { |
|
395 | 395 | return $guid; |
396 | 396 | } |
397 | 397 | |
398 | - $guid[ $this->slug ] = $this->get_the_id(); |
|
398 | + $guid[$this->slug] = $this->get_the_id(); |
|
399 | 399 | |
400 | 400 | return $guid; |
401 | 401 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
35 | 35 | */ |
36 | -function wordpoints_hook_reactors_init( $reactors ) { |
|
36 | +function wordpoints_hook_reactors_init($reactors) { |
|
37 | 37 | |
38 | - $reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param WordPoints_Class_Registry_Children $reaction_groups The group registry. |
49 | 49 | */ |
50 | -function wordpoints_hook_reaction_groups_init( $reaction_groups ) { |
|
50 | +function wordpoints_hook_reaction_groups_init($reaction_groups) { |
|
51 | 51 | |
52 | 52 | $reaction_groups->register( |
53 | 53 | 'points' |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | , 'WordPoints_Hook_Reaction_Storage_Options' |
56 | 56 | ); |
57 | 57 | |
58 | - if ( is_wordpoints_network_active() ) { |
|
58 | + if (is_wordpoints_network_active()) { |
|
59 | 59 | $reaction_groups->register( |
60 | 60 | 'points' |
61 | 61 | , 'network' |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
75 | 75 | */ |
76 | -function wordpoints_hook_extension_init( $extensions ) { |
|
76 | +function wordpoints_hook_extension_init($extensions) { |
|
77 | 77 | |
78 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
79 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
78 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
79 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
90 | 90 | */ |
91 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
91 | +function wordpoints_hook_conditions_init($conditions) { |
|
92 | 92 | |
93 | 93 | $conditions->register( |
94 | 94 | 'text' |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param WordPoints_Hook_Actions $actions The action registry. |
126 | 126 | */ |
127 | -function wordpoints_hook_actions_init( $actions ) { |
|
127 | +function wordpoints_hook_actions_init($actions) { |
|
128 | 128 | |
129 | 129 | $actions->register( |
130 | 130 | 'comment_approve' |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | , array( |
133 | 133 | 'action' => 'transition_comment_status', |
134 | 134 | 'data' => array( |
135 | - 'arg_index' => array( 'comment' => 2 ), |
|
136 | - 'requirements' => array( 0 => 'approved' ), |
|
135 | + 'arg_index' => array('comment' => 2), |
|
136 | + 'requirements' => array(0 => 'approved'), |
|
137 | 137 | ), |
138 | 138 | ) |
139 | 139 | ); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | , array( |
145 | 145 | 'action' => 'wp_insert_comment', |
146 | 146 | 'data' => array( |
147 | - 'arg_index' => array( 'comment' => 1 ), |
|
147 | + 'arg_index' => array('comment' => 1), |
|
148 | 148 | ), |
149 | 149 | ) |
150 | 150 | ); |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | , array( |
156 | 156 | 'action' => 'transition_comment_status', |
157 | 157 | 'data' => array( |
158 | - 'arg_index' => array( 'comment' => 2 ), |
|
159 | - 'requirements' => array( 1 => 'approved' ), |
|
158 | + 'arg_index' => array('comment' => 2), |
|
159 | + 'requirements' => array(1 => 'approved'), |
|
160 | 160 | ), |
161 | 161 | ) |
162 | 162 | ); |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | , array( |
169 | 169 | 'action' => 'transition_post_status', |
170 | 170 | 'data' => array( |
171 | - 'arg_index' => array( 'post' => 2 ), |
|
172 | - 'requirements' => array( 0 => 'publish' ), |
|
171 | + 'arg_index' => array('post' => 2), |
|
172 | + 'requirements' => array(0 => 'publish'), |
|
173 | 173 | ), |
174 | 174 | ) |
175 | 175 | ); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | , array( |
181 | 181 | 'action' => 'add_attachment', |
182 | 182 | 'data' => array( |
183 | - 'arg_index' => array( 'post\attachment' => 0 ), |
|
183 | + 'arg_index' => array('post\attachment' => 0), |
|
184 | 184 | ), |
185 | 185 | ) |
186 | 186 | ); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | , array( |
192 | 192 | 'action' => 'post_delete', |
193 | 193 | 'data' => array( |
194 | - 'arg_index' => array( 'post' => 0 ), |
|
194 | + 'arg_index' => array('post' => 0), |
|
195 | 195 | ), |
196 | 196 | ) |
197 | 197 | ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | , array( |
203 | 203 | 'action' => 'user_register', |
204 | 204 | 'data' => array( |
205 | - 'arg_index' => array( 'user' => 0 ), |
|
205 | + 'arg_index' => array('user' => 0), |
|
206 | 206 | ), |
207 | 207 | ) |
208 | 208 | ); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | , array( |
214 | 214 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
215 | 215 | 'data' => array( |
216 | - 'arg_index' => array( 'user' => 0 ), |
|
216 | + 'arg_index' => array('user' => 0), |
|
217 | 217 | ), |
218 | 218 | ) |
219 | 219 | ); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param WordPoints_Hook_Events $events The event registry. |
238 | 238 | */ |
239 | -function wordpoints_hook_events_init( $events ) { |
|
239 | +function wordpoints_hook_events_init($events) { |
|
240 | 240 | |
241 | 241 | $events->register( |
242 | 242 | 'user_register' |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Register events for all of the public post types. |
269 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
269 | + $post_types = get_post_types(array('public' => true)); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Filter which post types to register hook events for. |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param string[] The post type slugs ("names"). |
277 | 277 | */ |
278 | - $post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types ); |
|
278 | + $post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types); |
|
279 | 279 | |
280 | - foreach ( $post_types as $slug ) { |
|
281 | - wordpoints_register_post_type_hook_events( $slug ); |
|
280 | + foreach ($post_types as $slug) { |
|
281 | + wordpoints_register_post_type_hook_events($slug); |
|
282 | 282 | } |
283 | 283 | |
284 | - if ( is_multisite() ) { |
|
284 | + if (is_multisite()) { |
|
285 | 285 | |
286 | 286 | $event_slugs = array( |
287 | 287 | 'user_visit', |
288 | 288 | 'user_register', |
289 | 289 | ); |
290 | 290 | |
291 | - foreach ( $event_slugs as $event_slug ) { |
|
291 | + foreach ($event_slugs as $event_slug) { |
|
292 | 292 | // TODO network hooks |
293 | 293 | $events->args->register( |
294 | 294 | $event_slug |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param WordPoints_Class_Registry_Persistent $firers The firer registry. |
310 | 310 | */ |
311 | -function wordpoints_hook_firers_init( $firers ) { |
|
311 | +function wordpoints_hook_firers_init($firers) { |
|
312 | 312 | |
313 | - $firers->register( 'fire', 'WordPoints_Hook_Firer' ); |
|
314 | - $firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' ); |
|
315 | - $firers->register( 'spam', 'WordPoints_Hook_Firer_Spam' ); |
|
313 | + $firers->register('fire', 'WordPoints_Hook_Firer'); |
|
314 | + $firers->register('reverse', 'WordPoints_Hook_Firer_Reverse'); |
|
315 | + $firers->register('spam', 'WordPoints_Hook_Firer_Spam'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @param WordPoints_App_Registry $entities The entities app. |
326 | 326 | */ |
327 | -function wordpoints_entities_app_init( $entities ) { |
|
327 | +function wordpoints_entities_app_init($entities) { |
|
328 | 328 | |
329 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
330 | - $entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' ); |
|
329 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
330 | + $entities->sub_apps->register('contexts', 'WordPoints_Class_Registry'); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @param WordPoints_Class_Registry $contexts The entity context registry. |
341 | 341 | */ |
342 | -function wordpoints_entity_contexts_init( $contexts ) { |
|
342 | +function wordpoints_entity_contexts_init($contexts) { |
|
343 | 343 | |
344 | - $contexts->register( 'network', 'WordPoints_Entity_Context_Network' ); |
|
345 | - $contexts->register( 'site', 'WordPoints_Entity_Context_Site' ); |
|
344 | + $contexts->register('network', 'WordPoints_Entity_Context_Network'); |
|
345 | + $contexts->register('site', 'WordPoints_Entity_Context_Site'); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -354,18 +354,18 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @param WordPoints_App_Registry $entities The entities app. |
356 | 356 | */ |
357 | -function wordpoints_entities_init( $entities ) { |
|
357 | +function wordpoints_entities_init($entities) { |
|
358 | 358 | |
359 | 359 | $children = $entities->children; |
360 | 360 | |
361 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
362 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
361 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
362 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
363 | 363 | |
364 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
365 | - $children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
364 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
365 | + $children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
366 | 366 | |
367 | 367 | // Register entities for all of the public post types. |
368 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
368 | + $post_types = get_post_types(array('public' => true)); |
|
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Filter which post types to register entities for. |
@@ -374,14 +374,14 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @param string[] The post type slugs ("names"). |
376 | 376 | */ |
377 | - $post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types ); |
|
377 | + $post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types); |
|
378 | 378 | |
379 | - foreach ( $post_types as $slug ) { |
|
380 | - wordpoints_register_post_type_entities( $slug ); |
|
379 | + foreach ($post_types as $slug) { |
|
380 | + wordpoints_register_post_type_entities($slug); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // Register entities for all of the public taxonomies. |
384 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
384 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Filter which taxonomies to register entities for. |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param string[] The taxonomy slugs. |
392 | 392 | */ |
393 | - $taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies ); |
|
393 | + $taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies); |
|
394 | 394 | |
395 | - foreach ( $taxonomies as $slug ) { |
|
396 | - wordpoints_register_taxonomy_entities( $slug ); |
|
395 | + foreach ($taxonomies as $slug) { |
|
396 | + wordpoints_register_taxonomy_entities($slug); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -404,28 +404,28 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @param string $slug The slug of the post type. |
406 | 406 | */ |
407 | -function wordpoints_register_post_type_entities( $slug ) { |
|
407 | +function wordpoints_register_post_type_entities($slug) { |
|
408 | 408 | |
409 | 409 | $entities = wordpoints_entities(); |
410 | 410 | $children = $entities->children; |
411 | 411 | |
412 | - $entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' ); |
|
413 | - $children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' ); |
|
412 | + $entities->register("post\\{$slug}", 'WordPoints_Entity_Post'); |
|
413 | + $children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author'); |
|
414 | 414 | |
415 | - $supports = get_all_post_type_supports( $slug ); |
|
415 | + $supports = get_all_post_type_supports($slug); |
|
416 | 416 | |
417 | - if ( isset( $supports['editor'] ) ) { |
|
418 | - $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
|
417 | + if (isset($supports['editor'])) { |
|
418 | + $children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content'); |
|
419 | 419 | } |
420 | 420 | |
421 | - if ( isset( $supports['comments'] ) ) { |
|
422 | - $entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' ); |
|
423 | - $children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' ); |
|
424 | - $children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' ); |
|
421 | + if (isset($supports['comments'])) { |
|
422 | + $entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment'); |
|
423 | + $children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post'); |
|
424 | + $children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author'); |
|
425 | 425 | } |
426 | 426 | |
427 | - foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) { |
|
428 | - $children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' ); |
|
427 | + foreach (get_object_taxonomies($slug) as $taxonomy_slug) { |
|
428 | + $children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms'); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @param string $slug The slug ("name") of the post type. |
437 | 437 | */ |
438 | - do_action( 'wordpoints_register_post_type_entities', $slug ); |
|
438 | + do_action('wordpoints_register_post_type_entities', $slug); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $slug The slug of the post type. |
447 | 447 | */ |
448 | -function wordpoints_register_post_type_hook_events( $slug ) { |
|
448 | +function wordpoints_register_post_type_hook_events($slug) { |
|
449 | 449 | |
450 | 450 | $event_slugs = array(); |
451 | 451 | |
452 | 452 | $events = wordpoints_hooks()->events; |
453 | 453 | |
454 | - if ( 'attachment' === $slug ) { |
|
454 | + if ('attachment' === $slug) { |
|
455 | 455 | |
456 | 456 | $event_slugs[] = 'media_upload'; |
457 | 457 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | - if ( post_type_supports( $slug, 'comments' ) ) { |
|
491 | + if (post_type_supports($slug, 'comments')) { |
|
492 | 492 | |
493 | 493 | $event_slugs[] = "comment_leave\\{$slug}"; |
494 | 494 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | , 'WordPoints_Hook_Event_Comment_Leave' |
498 | 498 | , array( |
499 | 499 | 'actions' => array( |
500 | - 'fire' => array( 'comment_approve', 'comment_new' ), |
|
500 | + 'fire' => array('comment_approve', 'comment_new'), |
|
501 | 501 | 'reverse' => 'comment_deapprove', |
502 | 502 | 'spam' => 'comment_spam', |
503 | 503 | ), |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | ); |
509 | 509 | } |
510 | 510 | |
511 | - if ( is_multisite() ) { |
|
512 | - foreach ( $event_slugs as $event_slug ) { |
|
511 | + if (is_multisite()) { |
|
512 | + foreach ($event_slugs as $event_slug) { |
|
513 | 513 | $events->args->register( |
514 | 514 | $event_slug |
515 | 515 | , 'current:site' |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @param string $slug The slug ("name") of the post type. |
527 | 527 | */ |
528 | - do_action( 'wordpoints_register_post_type_hook_events', $slug ); |
|
528 | + do_action('wordpoints_register_post_type_hook_events', $slug); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @param string $slug The slug of the taxonomy. |
537 | 537 | */ |
538 | -function wordpoints_register_taxonomy_entities( $slug ) { |
|
538 | +function wordpoints_register_taxonomy_entities($slug) { |
|
539 | 539 | |
540 | 540 | $entities = wordpoints_entities(); |
541 | 541 | $children = $entities->children; |
542 | 542 | |
543 | - $entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' ); |
|
544 | - $children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' ); |
|
543 | + $entities->register("term\\{$slug}", 'WordPoints_Entity_Term'); |
|
544 | + $children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id'); |
|
545 | 545 | |
546 | 546 | /** |
547 | 547 | * Fired when registering the entities for a taxonomy. |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * |
551 | 551 | * @param string $slug The taxonomy's slug. |
552 | 552 | */ |
553 | - do_action( 'wordpoints_register_taxonomy_entities', $slug ); |
|
553 | + do_action('wordpoints_register_taxonomy_entities', $slug); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
564 | 564 | */ |
565 | -function wordpoints_data_types_init( $data_types ) { |
|
565 | +function wordpoints_data_types_init($data_types) { |
|
566 | 566 | |
567 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
568 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
567 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
568 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return bool Whether the user can view the points log. |
582 | 582 | */ |
583 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
583 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
584 | 584 | |
585 | - if ( ! $can_view ) { |
|
585 | + if ( ! $can_view) { |
|
586 | 586 | return $can_view; |
587 | 587 | } |
588 | 588 | |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | $event_slug = $log->log_type; |
592 | 592 | |
593 | 593 | /** @var WordPoints_Hook_Arg $arg */ |
594 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
594 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
595 | 595 | |
596 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
596 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
597 | 597 | |
598 | - if ( ! $value ) { |
|
598 | + if ( ! $value) { |
|
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | , $value |
606 | 606 | ); |
607 | 607 | |
608 | - if ( ! $can_view ) { |
|
608 | + if ( ! $can_view) { |
|
609 | 609 | break; |
610 | 610 | } |
611 | 611 | } |
@@ -624,20 +624,20 @@ discard block |
||
624 | 624 | * |
625 | 625 | * @return bool Whether the user can view this entity. |
626 | 626 | */ |
627 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
627 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
628 | 628 | |
629 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
629 | + $entity = wordpoints_entities()->get($entity_slug); |
|
630 | 630 | |
631 | 631 | // If this entity type is not found, we have no way of determining whether it is |
632 | 632 | // safe for the user to view it. |
633 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
633 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
634 | 634 | return false; |
635 | 635 | } |
636 | 636 | |
637 | 637 | $can_view = true; |
638 | 638 | |
639 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
640 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
639 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
640 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | */ |
669 | 669 | function wordpoints_apps() { |
670 | 670 | |
671 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
672 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
671 | + if ( ! isset(WordPoints_App::$main)) { |
|
672 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | return WordPoints_App::$main; |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function wordpoints_hooks() { |
686 | 686 | |
687 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
687 | + if ( ! isset(WordPoints_App::$main)) { |
|
688 | 688 | wordpoints_apps(); |
689 | 689 | } |
690 | 690 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | function wordpoints_entities() { |
702 | 702 | |
703 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
703 | + if ( ! isset(WordPoints_App::$main)) { |
|
704 | 704 | wordpoints_apps(); |
705 | 705 | } |
706 | 706 | |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | * |
717 | 717 | * @param WordPoints_App $app The main apps app. |
718 | 718 | */ |
719 | -function wordpoints_apps_init( $app ) { |
|
719 | +function wordpoints_apps_init($app) { |
|
720 | 720 | |
721 | 721 | $apps = $app->sub_apps; |
722 | 722 | |
723 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
724 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
725 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
723 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
724 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
725 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -735,19 +735,19 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return object|false The constructed object, or false if to many args were passed. |
737 | 737 | */ |
738 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
738 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
739 | 739 | |
740 | - switch ( count( $args ) ) { |
|
740 | + switch (count($args)) { |
|
741 | 741 | case 0: |
742 | 742 | return new $class_name(); |
743 | 743 | case 1: |
744 | - return new $class_name( $args[0] ); |
|
744 | + return new $class_name($args[0]); |
|
745 | 745 | case 2: |
746 | - return new $class_name( $args[0], $args[1] ); |
|
746 | + return new $class_name($args[0], $args[1]); |
|
747 | 747 | case 3: |
748 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
748 | + return new $class_name($args[0], $args[1], $args[2]); |
|
749 | 749 | case 4: |
750 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
750 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
751 | 751 | default: |
752 | 752 | return false; |
753 | 753 | } |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the |
770 | 770 | * slug is not dynamic, the value of each of those keys will be false. |
771 | 771 | */ |
772 | -function wordpoints_parse_dynamic_slug( $slug ) { |
|
772 | +function wordpoints_parse_dynamic_slug($slug) { |
|
773 | 773 | |
774 | - $parsed = array( 'dynamic' => false, 'generic' => false ); |
|
774 | + $parsed = array('dynamic' => false, 'generic' => false); |
|
775 | 775 | |
776 | - $parts = explode( '\\', $slug, 2 ); |
|
776 | + $parts = explode('\\', $slug, 2); |
|
777 | 777 | |
778 | - if ( isset( $parts[1] ) ) { |
|
778 | + if (isset($parts[1])) { |
|
779 | 779 | $parsed['dynamic'] = $parts[1]; |
780 | 780 | $parsed['generic'] = $parts[0]; |
781 | 781 | } |
@@ -812,28 +812,28 @@ discard block |
||
812 | 812 | * contexts, indexed by context slug, or false if any of the |
813 | 813 | * contexts isn't current. |
814 | 814 | */ |
815 | -function wordpoints_entities_get_current_context_id( $slug ) { |
|
815 | +function wordpoints_entities_get_current_context_id($slug) { |
|
816 | 816 | |
817 | 817 | $current_context = array(); |
818 | 818 | |
819 | 819 | /** @var WordPoints_Class_Registry $contexts */ |
820 | 820 | $contexts = wordpoints_entities()->contexts; |
821 | 821 | |
822 | - while ( $slug ) { |
|
822 | + while ($slug) { |
|
823 | 823 | |
824 | - $context = $contexts->get( $slug ); |
|
824 | + $context = $contexts->get($slug); |
|
825 | 825 | |
826 | - if ( ! $context instanceof WordPoints_Entity_Context ) { |
|
826 | + if ( ! $context instanceof WordPoints_Entity_Context) { |
|
827 | 827 | return false; |
828 | 828 | } |
829 | 829 | |
830 | 830 | $id = $context->get_current_id(); |
831 | 831 | |
832 | - if ( false === $id ) { |
|
832 | + if (false === $id) { |
|
833 | 833 | return false; |
834 | 834 | } |
835 | 835 | |
836 | - $current_context[ $slug ] = $id; |
|
836 | + $current_context[$slug] = $id; |
|
837 | 837 | |
838 | 838 | $slug = $context->get_parent_slug(); |
839 | 839 | } |
@@ -854,18 +854,18 @@ discard block |
||
854 | 854 | */ |
855 | 855 | function wordpoints_is_network_context() { |
856 | 856 | |
857 | - if ( is_network_admin() ) { |
|
857 | + if (is_network_admin()) { |
|
858 | 858 | return true; |
859 | 859 | } |
860 | 860 | |
861 | 861 | // See https://core.trac.wordpress.org/ticket/22589 |
862 | 862 | if ( |
863 | - defined( 'DOING_AJAX' ) |
|
863 | + defined('DOING_AJAX') |
|
864 | 864 | && DOING_AJAX |
865 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
865 | + && isset($_SERVER['HTTP_REFERER']) |
|
866 | 866 | && preg_match( |
867 | - '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
|
868 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
867 | + '#^'.preg_quote(network_admin_url(), '#').'#i' |
|
868 | + , esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) |
|
869 | 869 | ) |
870 | 870 | ) { |
871 | 871 | return true; |
@@ -878,19 +878,19 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @param bool $in_network_context Whether we are in network context. |
880 | 880 | */ |
881 | - return apply_filters( 'wordpoints_is_network_context', false ); |
|
881 | + return apply_filters('wordpoints_is_network_context', false); |
|
882 | 882 | } |
883 | 883 | |
884 | -function wordpoints_hooks_get_event_signature( WordPoints_Hook_Event_Args $event_args ) { |
|
884 | +function wordpoints_hooks_get_event_signature(WordPoints_Hook_Event_Args $event_args) { |
|
885 | 885 | |
886 | 886 | $entity = $event_args->get_primary_arg(); |
887 | 887 | |
888 | 888 | // TODO what if GUID isn't set? |
889 | - if ( ! $entity ) { |
|
890 | - return str_repeat( '-', 64 ); |
|
889 | + if ( ! $entity) { |
|
890 | + return str_repeat('-', 64); |
|
891 | 891 | } |
892 | 892 | |
893 | - return wordpoints_hash( wp_json_encode( $entity->get_the_guid() ) ); |
|
893 | + return wordpoints_hash(wp_json_encode($entity->get_the_guid())); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | // EOF |