@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | interface WordPoints_Hook_Reaction_SettingI { |
11 | - public function __construct( $slug ); |
|
11 | + public function __construct($slug); |
|
12 | 12 | public function get_type(); |
13 | 13 | public function get_label(); |
14 | 14 | public function is_required(); |
15 | - public function get( WordPoints_Hook_ReactionI $reaction ); |
|
16 | - public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ); |
|
17 | - public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ); |
|
15 | + public function get(WordPoints_Hook_ReactionI $reaction); |
|
16 | + public function validate($value, WordPoints_Hook_Reaction_Validator $validator); |
|
17 | + public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class WordPoints_Hook_Reaction_Setting implements WordPoints_Hook_Reaction_SettingI { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | protected $type = 'hidden'; |
24 | 24 | protected $required = true; |
25 | 25 | |
26 | - public function __construct( $slug ) { |
|
26 | + public function __construct($slug) { |
|
27 | 27 | $this->slug = $slug; |
28 | 28 | } |
29 | 29 | |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | return $this->required; |
40 | 40 | } |
41 | 41 | |
42 | - public function get( WordPoints_Hook_ReactionI $reaction ) { |
|
43 | - return $reaction->get_meta( $this->slug ); |
|
42 | + public function get(WordPoints_Hook_ReactionI $reaction) { |
|
43 | + return $reaction->get_meta($this->slug); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ) { |
|
46 | + public function validate($value, WordPoints_Hook_Reaction_Validator $validator) { |
|
47 | 47 | |
48 | - if ( $this->is_required() && '' === trim( $value ) ) { |
|
48 | + if ($this->is_required() && '' === trim($value)) { |
|
49 | 49 | |
50 | 50 | $validator->add_error( |
51 | 51 | sprintf( |
52 | - __( '%s cannot be empty.', 'wordpoints' ) |
|
52 | + __('%s cannot be empty.', 'wordpoints') |
|
53 | 53 | , $this->get_label() |
54 | 54 | ) |
55 | 55 | , $this->slug |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | return $value; |
60 | 60 | } |
61 | 61 | |
62 | - public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ) { |
|
63 | - $reaction->update_meta( $this->slug, $value ); |
|
62 | + public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new) { |
|
63 | + $reaction->update_meta($this->slug, $value); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | // |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | |
83 | 83 | $fields = array(); |
84 | 84 | |
85 | - foreach ( $this->settings as $slug => $class ) { |
|
85 | + foreach ($this->settings as $slug => $class) { |
|
86 | 86 | |
87 | 87 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
88 | - $setting = new $class( $slug ); |
|
88 | + $setting = new $class($slug); |
|
89 | 89 | |
90 | - $fields[ $slug ] = array( |
|
90 | + $fields[$slug] = array( |
|
91 | 91 | 'type' => $setting->get_type(), |
92 | 92 | 'label' => $setting->get_label(), |
93 | 93 | 'required' => $setting->is_required(), |
@@ -97,29 +97,29 @@ discard block |
||
97 | 97 | return $fields; |
98 | 98 | } |
99 | 99 | |
100 | - public function save_settings( $reaction, $settings, $is_new ) { |
|
100 | + public function save_settings($reaction, $settings, $is_new) { |
|
101 | 101 | |
102 | - foreach ( $this->settings as $slug => $class ) { |
|
102 | + foreach ($this->settings as $slug => $class) { |
|
103 | 103 | |
104 | 104 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
105 | - $setting = new $class( $slug ); |
|
105 | + $setting = new $class($slug); |
|
106 | 106 | |
107 | - $value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null; |
|
107 | + $value = isset($settings[$slug]) ? $settings[$slug] : null; |
|
108 | 108 | |
109 | - $setting->save( $value, $reaction, $is_new ); |
|
109 | + $setting->save($value, $reaction, $is_new); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - public function validate_settings( $settings, $validator ) { |
|
113 | + public function validate_settings($settings, $validator) { |
|
114 | 114 | |
115 | - foreach ( $this->settings as $slug => $class ) { |
|
115 | + foreach ($this->settings as $slug => $class) { |
|
116 | 116 | |
117 | 117 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
118 | - $setting = new $class( $slug ); |
|
118 | + $setting = new $class($slug); |
|
119 | 119 | |
120 | - $value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null; |
|
120 | + $value = isset($settings[$slug]) ? $settings[$slug] : null; |
|
121 | 121 | |
122 | - $settings[ $slug ] = $setting->validate( $value, $validator ); |
|
122 | + $settings[$slug] = $setting->validate($value, $validator); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $settings; |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param WordPoints_Hooks $hooks |
135 | 135 | */ |
136 | -function wordpoints_hook_settings_app( $hooks ) { |
|
137 | - $hooks->sub_apps->register( 'settings', 'WordPoints_Hook_Settings' ); |
|
136 | +function wordpoints_hook_settings_app($hooks) { |
|
137 | + $hooks->sub_apps->register('settings', 'WordPoints_Hook_Settings'); |
|
138 | 138 | } |
139 | 139 | //add_action( 'wordpoints_hooks_init', 'wordpoints_hook_settings_app' ); |
140 | 140 | |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param WordPoints_Hook_Settings $settings |
147 | 147 | */ |
148 | -function wordpoints_register_hook_settings( $settings ) { |
|
148 | +function wordpoints_register_hook_settings($settings) { |
|
149 | 149 | |
150 | - add_action( 'wordpoints_hook_reaction_save', array( $settings, 'save_settings' ), 10, 3 ); |
|
151 | - add_filter( 'wordpoints_hook_reaction_validate', array( $settings, 'validate_settings' ), 10, 2 ); |
|
150 | + add_action('wordpoints_hook_reaction_save', array($settings, 'save_settings'), 10, 3); |
|
151 | + add_filter('wordpoints_hook_reaction_validate', array($settings, 'validate_settings'), 10, 2); |
|
152 | 152 | |
153 | - $settings->register( 'description', 'WordPoints_Hook_Reaction_Setting_Description' ); |
|
153 | + $settings->register('description', 'WordPoints_Hook_Reaction_Setting_Description'); |
|
154 | 154 | } |
155 | 155 | //add_action( 'wordpoints_hook_settings_init', 'wordpoints_register_hook_settings' ); |
156 | 156 |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI { |
76 | - public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction ); |
|
76 | + public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | abstract class WordPoints_Hook_Reactor_Retroactive implements WordPoints_Hook_Reactor_RetroactiveI { |
80 | 80 | |
81 | - public function modify_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query ) { |
|
81 | + public function modify_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query) { |
|
82 | 82 | |
83 | - $query->set_target( $query->get_reaction()->get_meta( 'target' ) ); |
|
83 | + $query->set_target($query->get_reaction()->get_meta('target')); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public function reverse_hits() { |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @since 1.0.0 |
99 | 99 | */ |
100 | - public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction ) { |
|
100 | + public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction) { |
|
101 | 101 | |
102 | - $count = count( $records ); |
|
102 | + $count = count($records); |
|
103 | 103 | |
104 | 104 | wordpoints_alter_points( |
105 | 105 | $target |
106 | - , $reaction->get_meta( 'points' ) * $count |
|
107 | - , $reaction->get_meta( 'points_type' ) |
|
108 | - , 'retroactive_' . $reaction->get_event_slug() |
|
109 | - , array( 'count' => $count ) |
|
110 | - , $event->get_retroactive_description( $reaction ) |
|
106 | + , $reaction->get_meta('points') * $count |
|
107 | + , $reaction->get_meta('points_type') |
|
108 | + , 'retroactive_'.$reaction->get_event_slug() |
|
109 | + , array('count' => $count) |
|
110 | + , $event->get_retroactive_description($reaction) |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | |
140 | 140 | $logs = $query->get(); |
141 | 141 | |
142 | - if ( ! $logs ) { |
|
142 | + if ( ! $logs) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
146 | - foreach ( $logs as $log ) { |
|
146 | + foreach ($logs as $log) { |
|
147 | 147 | |
148 | 148 | wordpoints_alter_points( |
149 | 149 | $log->user_id |
150 | - , - ( $log->points / wordpoints_get_points_log_meta( $log->id, 'count', true ) ) |
|
150 | + , -($log->points / wordpoints_get_points_log_meta($log->id, 'count', true)) |
|
151 | 151 | , $log->points_type |
152 | 152 | , "reverse_{$event}" |
153 | - , array( 'original_log_id' => $log->id ) |
|
153 | + , array('original_log_id' => $log->id) |
|
154 | 154 | , $args->get_description() |
155 | 155 | ); |
156 | 156 | |
157 | - wordpoints_add_points_log_meta( $log->id, 'auto_reversed', $args->get_entity_id() ); |
|
157 | + wordpoints_add_points_log_meta($log->id, 'auto_reversed', $args->get_entity_id()); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | |
197 | 197 | protected $results; |
198 | 198 | |
199 | - public function __construct( WordPoints_Hook_ReactionI $reaction ) { |
|
199 | + public function __construct(WordPoints_Hook_ReactionI $reaction) { |
|
200 | 200 | |
201 | 201 | $this->reaction = $reaction; |
202 | - $this->arg_hierarchy = new WordPoints_Hierarchy( 'sub_args' ); |
|
202 | + $this->arg_hierarchy = new WordPoints_Hierarchy('sub_args'); |
|
203 | 203 | $this->hooks = wordpoints_hooks(); |
204 | 204 | $this->entities = wordpoints_entities(); |
205 | - $this->validator = new WordPoints_Hook_Reaction_Validator( $reaction, true ); |
|
205 | + $this->validator = new WordPoints_Hook_Reaction_Validator($reaction, true); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | public function get_reaction() { |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | |
216 | 216 | public function get_results() { |
217 | 217 | |
218 | - if ( ! isset( $this->results ) ) { |
|
218 | + if ( ! isset($this->results)) { |
|
219 | 219 | |
220 | 220 | $this->execute(); |
221 | 221 | |
222 | - if ( $this->validator->had_errors() ) { |
|
222 | + if ($this->validator->had_errors()) { |
|
223 | 223 | $this->results = $this->validator; |
224 | 224 | } |
225 | 225 | } |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | $this->filter_results(); |
237 | 237 | $this->group_results(); |
238 | 238 | |
239 | - } catch ( WordPoints_Hook_Validator_Exception $e ) { |
|
240 | - unset( $e ); |
|
239 | + } catch (WordPoints_Hook_Validator_Exception $e) { |
|
240 | + unset($e); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -245,32 +245,32 @@ discard block |
||
245 | 245 | |
246 | 246 | $event_slug = $this->reaction->get_event_slug(); |
247 | 247 | |
248 | - $event = $this->hooks->events->get( $event_slug ); |
|
248 | + $event = $this->hooks->events->get($event_slug); |
|
249 | 249 | |
250 | - if ( ! ( $event instanceof WordPoints_Hook_Event_RetroactiveI ) ) { |
|
251 | - $this->validator->add_error( 'invalid hook' ); |
|
250 | + if ( ! ($event instanceof WordPoints_Hook_Event_RetroactiveI)) { |
|
251 | + $this->validator->add_error('invalid hook'); |
|
252 | 252 | } |
253 | 253 | |
254 | - foreach ( $this->hooks->events->args->get_children( $event_slug ) as $arg ) { |
|
254 | + foreach ($this->hooks->events->args->get_children($event_slug) as $arg) { |
|
255 | 255 | $this->arg_hierarchy_push( // TODO |
256 | 256 | $arg |
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | - if ( $event instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) { |
|
261 | - $event->modify_retroactive_query( $this ); |
|
260 | + if ($event instanceof WordPoints_Hook_Retroactive_Query_ModifierI) { |
|
261 | + $event->modify_retroactive_query($this); |
|
262 | 262 | $this->reset(); |
263 | 263 | } |
264 | 264 | |
265 | - $reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() ); |
|
265 | + $reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug()); |
|
266 | 266 | |
267 | - $reactor->modify_retroactive_query( $this ); |
|
267 | + $reactor->modify_retroactive_query($this); |
|
268 | 268 | $this->reset(); |
269 | 269 | |
270 | - foreach ( $this->hooks->extensions->get_all() as $extension ) { |
|
270 | + foreach ($this->hooks->extensions->get_all() as $extension) { |
|
271 | 271 | |
272 | - if ( $extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) { |
|
273 | - $extension->modify_retroactive_query( $this ); |
|
272 | + if ($extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI) { |
|
273 | + $extension->modify_retroactive_query($this); |
|
274 | 274 | $this->reset(); |
275 | 275 | } |
276 | 276 | } |
@@ -278,126 +278,126 @@ discard block |
||
278 | 278 | |
279 | 279 | protected function perform_query() { |
280 | 280 | |
281 | - $this->queries = new WordPoints_Hierarchy( 'sub_queries' ); |
|
282 | - $this->consolidate_queries( array( $this->arg_hierarchy->get() ) ); |
|
283 | - unset( $this->query ); |
|
281 | + $this->queries = new WordPoints_Hierarchy('sub_queries'); |
|
282 | + $this->consolidate_queries(array($this->arg_hierarchy->get())); |
|
283 | + unset($this->query); |
|
284 | 284 | |
285 | 285 | $this->queries->reset(); |
286 | 286 | |
287 | 287 | // Find the tip of a query. |
288 | - $this->results = $this->execute_queries( $this->queries->get() ); |
|
288 | + $this->results = $this->execute_queries($this->queries->get()); |
|
289 | 289 | |
290 | - if ( is_wp_error( $this->results ) ) { |
|
291 | - $this->validator->add_error( $this->results ); |
|
290 | + if (is_wp_error($this->results)) { |
|
291 | + $this->validator->add_error($this->results); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - protected function consolidate_queries( $arg_hierarchy, $storage_type = null ) { |
|
295 | + protected function consolidate_queries($arg_hierarchy, $storage_type = null) { |
|
296 | 296 | |
297 | - foreach ( $arg_hierarchy as $data ) { |
|
298 | - $this->consolidate_query( $data ); |
|
297 | + foreach ($arg_hierarchy as $data) { |
|
298 | + $this->consolidate_query($data); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | - protected function consolidate_query( $data ) { |
|
302 | + protected function consolidate_query($data) { |
|
303 | 303 | |
304 | - if ( $data['storage_info']['type'] !== $this->queries->get_field( 'slug' ) ) { |
|
304 | + if ($data['storage_info']['type'] !== $this->queries->get_field('slug')) { |
|
305 | 305 | |
306 | 306 | $parent_id = null; |
307 | - if ( isset( $this->query ) ) { |
|
307 | + if (isset($this->query)) { |
|
308 | 308 | $parent_id = $this->query->get_id(); |
309 | 309 | } |
310 | 310 | |
311 | - $this->query = new WordPoints_Hierarchy( 'sub_args' ); |
|
311 | + $this->query = new WordPoints_Hierarchy('sub_args'); |
|
312 | 312 | |
313 | 313 | $this->queries->push( |
314 | 314 | $data['storage_info']['type'] |
315 | - , array( 'query' => $this->query, 'parent_id' => $parent_id ) |
|
315 | + , array('query' => $this->query, 'parent_id' => $parent_id) |
|
316 | 316 | ); |
317 | 317 | |
318 | 318 | $pushed_query = true; |
319 | 319 | } |
320 | 320 | |
321 | - if ( isset( $data['sub_args'] ) ) { |
|
321 | + if (isset($data['sub_args'])) { |
|
322 | 322 | $sub_args = $data['sub_args']; |
323 | - unset( $data['sub_args'] ); |
|
323 | + unset($data['sub_args']); |
|
324 | 324 | } |
325 | 325 | |
326 | - $this->query->push( $data['slug'], $data ); |
|
326 | + $this->query->push($data['slug'], $data); |
|
327 | 327 | |
328 | - if ( isset( $sub_args ) ) { |
|
329 | - $this->consolidate_queries( $sub_args, $data['storage_info']['type'] ); |
|
328 | + if (isset($sub_args)) { |
|
329 | + $this->consolidate_queries($sub_args, $data['storage_info']['type']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $this->query->pop(); |
333 | 333 | |
334 | - if ( ! empty( $pushed_query ) ) { |
|
334 | + if ( ! empty($pushed_query)) { |
|
335 | 335 | $this->queries->pop(); |
336 | - $this->query = $this->queries->get_field( 'query' ); |
|
336 | + $this->query = $this->queries->get_field('query'); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - protected function execute_queries( $queries ) { |
|
340 | + protected function execute_queries($queries) { |
|
341 | 341 | |
342 | 342 | /** @var WordPoints_HierarchyI $query */ |
343 | 343 | $query = $queries['query']; |
344 | 344 | |
345 | - if ( isset( $queries['sub_queries'] ) ) { |
|
346 | - foreach ( $queries['sub_queries'] as $query_data ) { |
|
345 | + if (isset($queries['sub_queries'])) { |
|
346 | + foreach ($queries['sub_queries'] as $query_data) { |
|
347 | 347 | |
348 | - $results = $this->execute_queries( $query_data ); |
|
348 | + $results = $this->execute_queries($query_data); |
|
349 | 349 | |
350 | - if ( is_wp_error( $results ) ) { |
|
350 | + if (is_wp_error($results)) { |
|
351 | 351 | return $results; |
352 | 352 | } |
353 | 353 | |
354 | - if ( empty( $results ) ) { |
|
354 | + if (empty($results)) { |
|
355 | 355 | return array(); |
356 | 356 | } |
357 | 357 | |
358 | 358 | /** @var WordPoints_HierarchyI $child_query */ |
359 | 359 | $child_query = $query_data['query']; |
360 | - $query->go_to( $query_data['parent_id'] ); |
|
360 | + $query->go_to($query_data['parent_id']); |
|
361 | 361 | |
362 | 362 | $condition = array( |
363 | 363 | // 'field' => $child_query->get_field( 'slug' ), |
364 | 364 | 'compare' => 'in', |
365 | 365 | 'value' => wp_list_pluck( |
366 | 366 | $results |
367 | - , $child_query->get_field( 'storage_info', 'meta', 'id_field' ) |
|
367 | + , $child_query->get_field('storage_info', 'meta', 'id_field') |
|
368 | 368 | ), |
369 | 369 | ); |
370 | 370 | |
371 | - $query->push_to( 'conditions', $condition ); |
|
371 | + $query->push_to('conditions', $condition); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | 375 | $query->reset(); |
376 | - $storage_type = $query->get_field( 'storage_info', 'type' ); |
|
376 | + $storage_type = $query->get_field('storage_info', 'type'); |
|
377 | 377 | |
378 | 378 | // it is pretty stupid to wait until now to figure this out. |
379 | - $executor = $this->hooks->retroactive_query_executors->get( $storage_type ); |
|
379 | + $executor = $this->hooks->retroactive_query_executors->get($storage_type); |
|
380 | 380 | |
381 | - if ( ! $executor ) { |
|
381 | + if ( ! $executor) { |
|
382 | 382 | $this->validator->add_error( |
383 | - sprintf( 'unknown storage type "%s".', $storage_type ) |
|
383 | + sprintf('unknown storage type "%s".', $storage_type) |
|
384 | 384 | ); |
385 | 385 | } |
386 | 386 | |
387 | - return $executor->execute( array( $query->get() ) ); |
|
387 | + return $executor->execute(array($query->get())); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | protected function filter_results() { |
391 | 391 | |
392 | - $reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() ); |
|
392 | + $reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug()); |
|
393 | 393 | |
394 | - if ( $reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI ) { |
|
395 | - $reactor->filter_retroactive_query( $this ); |
|
394 | + if ($reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI) { |
|
395 | + $reactor->filter_retroactive_query($this); |
|
396 | 396 | } |
397 | 397 | |
398 | - foreach ( $this->hooks->extensions->get_all() as $extension ) { |
|
399 | - if ( $extension instanceof WordPoints_Hook_Retroactive_Query_FilterI ) { |
|
400 | - $extension->filter_retroactive_query( $this ); |
|
398 | + foreach ($this->hooks->extensions->get_all() as $extension) { |
|
399 | + if ($extension instanceof WordPoints_Hook_Retroactive_Query_FilterI) { |
|
400 | + $extension->filter_retroactive_query($this); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | } |
@@ -406,27 +406,27 @@ discard block |
||
406 | 406 | |
407 | 407 | $grouped_results = array(); |
408 | 408 | |
409 | - foreach ( $this->results as $result ) { |
|
410 | - $grouped_results[ $result->target ][] = $result; |
|
409 | + foreach ($this->results as $result) { |
|
410 | + $grouped_results[$result->target][] = $result; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | $this->results = $grouped_results; |
414 | 414 | } |
415 | 415 | |
416 | - public function add_condition( array $condition ) { |
|
416 | + public function add_condition(array $condition) { |
|
417 | 417 | |
418 | - $this->arg_hierarchy->push_to( 'conditions', $condition ); |
|
418 | + $this->arg_hierarchy->push_to('conditions', $condition); |
|
419 | 419 | } |
420 | 420 | |
421 | - public function select_value( $data = array() ) { |
|
421 | + public function select_value($data = array()) { |
|
422 | 422 | |
423 | - $this->arg_hierarchy->set_field( 'select', $data ); |
|
423 | + $this->arg_hierarchy->set_field('select', $data); |
|
424 | 424 | } |
425 | 425 | |
426 | - public function set_target( $target_arg ) { |
|
426 | + public function set_target($target_arg) { |
|
427 | 427 | |
428 | - foreach ( $target_arg as $arg_slug ) { |
|
429 | - $this->arg_hierarchy_push( $arg_slug ); |
|
428 | + foreach ($target_arg as $arg_slug) { |
|
429 | + $this->arg_hierarchy_push($arg_slug); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // $id = $this->arg_hierarchy->get_id(); |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | // $field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'field' ); |
437 | 437 | // $this->arg_hierarchy->ascend(); |
438 | 438 | // } else { |
439 | - $field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'id_field' ); |
|
439 | + $field = $this->arg_hierarchy->get_field('storage_info', 'meta', 'id_field'); |
|
440 | 440 | // } |
441 | 441 | |
442 | - $this->select_value( array( 'field' => $field, 'as' => 'target' ) ); |
|
442 | + $this->select_value(array('field' => $field, 'as' => 'target')); |
|
443 | 443 | |
444 | 444 | // $this->arg_hierarchy->go_to( $id ); |
445 | 445 | } |
@@ -451,40 +451,40 @@ discard block |
||
451 | 451 | * @return WordPoints_EntityishI |
452 | 452 | */ |
453 | 453 | public function get_arg() { |
454 | - return $this->arg_hierarchy->get_field( 'arg' ); |
|
454 | + return $this->arg_hierarchy->get_field('arg'); |
|
455 | 455 | } |
456 | 456 | |
457 | - public function arg_hierarchy_push( $slug ) { |
|
457 | + public function arg_hierarchy_push($slug) { |
|
458 | 458 | |
459 | - $current_slug = $this->arg_hierarchy->get_field( 'slug' ); |
|
459 | + $current_slug = $this->arg_hierarchy->get_field('slug'); |
|
460 | 460 | |
461 | - if ( $current_slug === $slug && $this->arg_hierarchy->is_main() ) { |
|
461 | + if ($current_slug === $slug && $this->arg_hierarchy->is_main()) { |
|
462 | 462 | return; |
463 | 463 | } |
464 | 464 | |
465 | 465 | // if ( $current_slug !== $slug ) { |
466 | 466 | |
467 | - if ( empty( $current_slug ) ) { |
|
468 | - $arg = $this->entities->get( $slug ); |
|
467 | + if (empty($current_slug)) { |
|
468 | + $arg = $this->entities->get($slug); |
|
469 | 469 | } else { |
470 | 470 | |
471 | 471 | // If this child exists, don't overwrite it, just descend into it. |
472 | - if ( $this->arg_hierarchy->has_child( $slug ) ) { |
|
473 | - $this->arg_hierarchy->descend( $slug ); |
|
472 | + if ($this->arg_hierarchy->has_child($slug)) { |
|
473 | + $this->arg_hierarchy->descend($slug); |
|
474 | 474 | return; |
475 | 475 | } |
476 | 476 | |
477 | - $parent_arg = $this->arg_hierarchy->get_field( 'arg' ); |
|
477 | + $parent_arg = $this->arg_hierarchy->get_field('arg'); |
|
478 | 478 | |
479 | - if ( $parent_arg instanceof WordPoints_Entity_ParentI ) { |
|
480 | - $arg = $parent_arg->get_child( $slug ); |
|
479 | + if ($parent_arg instanceof WordPoints_Entity_ParentI) { |
|
480 | + $arg = $parent_arg->get_child($slug); |
|
481 | 481 | } else { |
482 | 482 | return; // TODO |
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - if ( $arg instanceof WordPoints_Entity_Array ) { |
|
487 | - $arg = $this->entities->get( $arg->get_entity_slug() ); |
|
486 | + if ($arg instanceof WordPoints_Entity_Array) { |
|
487 | + $arg = $this->entities->get($arg->get_entity_slug()); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | $data['arg'] = $arg; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | // TODO check if storage type is recognized? |
493 | 493 | $data['storage_info'] = $arg->get_storage_info(); |
494 | 494 | |
495 | - $this->arg_hierarchy->push( $slug, $data ); |
|
495 | + $this->arg_hierarchy->push($slug, $data); |
|
496 | 496 | |
497 | 497 | // } else { |
498 | 498 | // $data = array(); |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | interface WordPoints_Hook_Retroactive_Query_FilterI { |
512 | - public function filter_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query ); |
|
512 | + public function filter_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | interface WordPoints_Hook_Retroactive_Query_ExecutorI { |
516 | - public function execute( $query ); |
|
516 | + public function execute($query); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /* |
@@ -542,48 +542,48 @@ discard block |
||
542 | 542 | protected $array; |
543 | 543 | protected $results; |
544 | 544 | |
545 | - public function execute( $query ) { |
|
545 | + public function execute($query) { |
|
546 | 546 | |
547 | - foreach ( $query as $arg_data ) { |
|
547 | + foreach ($query as $arg_data) { |
|
548 | 548 | |
549 | 549 | $meta = $arg_data['storage_info']['meta']; |
550 | 550 | |
551 | - if ( isset( $meta['getter'] ) ) { |
|
551 | + if (isset($meta['getter'])) { |
|
552 | 552 | $this->array = $meta['getter'](); |
553 | 553 | } |
554 | 554 | |
555 | - if ( isset( $arg_data['conditions'] ) ) { |
|
555 | + if (isset($arg_data['conditions'])) { |
|
556 | 556 | |
557 | - foreach ( $arg_data['conditions'] as $condition ) { |
|
557 | + foreach ($arg_data['conditions'] as $condition) { |
|
558 | 558 | |
559 | - if ( ! isset( $condition['field'] ) ) { |
|
560 | - if ( $arg_data['arg'] instanceof WordPoints_Entity_Attr ) { |
|
559 | + if ( ! isset($condition['field'])) { |
|
560 | + if ($arg_data['arg'] instanceof WordPoints_Entity_Attr) { |
|
561 | 561 | $condition['field'] = $meta['field']; |
562 | 562 | } else { |
563 | 563 | $condition['field'] = $meta['id_field']; |
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - if ( ! isset( $condition['condition'] ) ) { |
|
567 | + if ( ! isset($condition['condition'])) { |
|
568 | 568 | $condition['condition'] = '='; |
569 | 569 | } |
570 | 570 | |
571 | 571 | $filter_args = array(); |
572 | 572 | |
573 | - switch ( $condition['condition'] ) { |
|
573 | + switch ($condition['condition']) { |
|
574 | 574 | |
575 | 575 | case '=': |
576 | - $filter_args[ $condition['field'] ] = $condition['value']; |
|
576 | + $filter_args[$condition['field']] = $condition['value']; |
|
577 | 577 | break; |
578 | 578 | |
579 | 579 | case 'in': |
580 | 580 | // TODO |
581 | 581 | |
582 | 582 | default: |
583 | - return new WP_Error( 'invalid condition type' ); |
|
583 | + return new WP_Error('invalid condition type'); |
|
584 | 584 | } |
585 | 585 | |
586 | - $this->array = wp_list_filter( $this->array, $filter_args ); |
|
586 | + $this->array = wp_list_filter($this->array, $filter_args); |
|
587 | 587 | } |
588 | 588 | } |
589 | 589 | |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | // $builder->add_field( $arg_data['select'] ); |
592 | 592 | // } |
593 | 593 | |
594 | - if ( isset( $arg_data['sub_args'] ) ) { |
|
594 | + if (isset($arg_data['sub_args'])) { |
|
595 | 595 | $this->parent_data = $arg_data; |
596 | - $this->array = $this->execute( $arg_data['sub_args'] ); |
|
596 | + $this->array = $this->execute($arg_data['sub_args']); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | $this->results = $this->array; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | protected $entered_join; |
624 | 624 | |
625 | - public function execute( $query ) { |
|
625 | + public function execute($query) { |
|
626 | 626 | // WE should be getting a hierarchy object here. |
627 | 627 | // This will let us loop over things easier. |
628 | 628 | // We'll also need to be marking the non-usable parts of the query. |
@@ -632,69 +632,69 @@ discard block |
||
632 | 632 | |
633 | 633 | $this->builder = new WordPoints_Query_Builder_DB_MySQL(); |
634 | 634 | |
635 | - $this->build_query( $query ); |
|
635 | + $this->build_query($query); |
|
636 | 636 | |
637 | 637 | $sql = $this->builder->get_query(); |
638 | 638 | |
639 | - if ( is_wp_error( $sql ) ) { |
|
639 | + if (is_wp_error($sql)) { |
|
640 | 640 | return $sql; |
641 | 641 | } |
642 | 642 | |
643 | - return $wpdb->get_results( $sql ); |
|
643 | + return $wpdb->get_results($sql); |
|
644 | 644 | } |
645 | 645 | |
646 | - protected function build_query( $args ) { |
|
646 | + protected function build_query($args) { |
|
647 | 647 | |
648 | - foreach ( $args as $arg_data ) { |
|
648 | + foreach ($args as $arg_data) { |
|
649 | 649 | |
650 | 650 | $this->arg_data = $arg_data; |
651 | 651 | |
652 | - if ( isset( $arg_data['storage_info']['meta']['table_name'] ) ) { |
|
653 | - $this->build_table_schema( $arg_data['storage_info']['meta'] ); |
|
652 | + if (isset($arg_data['storage_info']['meta']['table_name'])) { |
|
653 | + $this->build_table_schema($arg_data['storage_info']['meta']); |
|
654 | 654 | } |
655 | 655 | |
656 | - if ( isset( $arg_data['conditions'] ) ) { |
|
657 | - $this->build_conditions( $arg_data['conditions'] ); |
|
656 | + if (isset($arg_data['conditions'])) { |
|
657 | + $this->build_conditions($arg_data['conditions']); |
|
658 | 658 | } |
659 | 659 | |
660 | - if ( isset( $arg_data['select'] ) ) { |
|
661 | - $this->builder->add_field( $arg_data['select'] ); |
|
660 | + if (isset($arg_data['select'])) { |
|
661 | + $this->builder->add_field($arg_data['select']); |
|
662 | 662 | } |
663 | 663 | |
664 | - if ( isset( $arg_data['sub_args'] ) ) { |
|
664 | + if (isset($arg_data['sub_args'])) { |
|
665 | 665 | |
666 | 666 | $this->grandparent_data = $this->parent_data; |
667 | 667 | $this->parent_data = $arg_data; |
668 | 668 | |
669 | - $this->build_query( $arg_data['sub_args'] ); |
|
669 | + $this->build_query($arg_data['sub_args']); |
|
670 | 670 | |
671 | 671 | $this->parent_data = $this->grandparent_data; |
672 | 672 | } |
673 | 673 | |
674 | - if ( isset( $this->entered_join ) ) { |
|
674 | + if (isset($this->entered_join)) { |
|
675 | 675 | $this->builder->exit_join(); |
676 | 676 | $this->entered_join = null; |
677 | 677 | } |
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | - protected function build_table_schema( $db ) { |
|
681 | + protected function build_table_schema($db) { |
|
682 | 682 | |
683 | - if ( $this->builder->get_table() ) { |
|
683 | + if ($this->builder->get_table()) { |
|
684 | 684 | |
685 | - if ( $this->parent_data['arg'] instanceof WordPoints_Entity_Relationship ) { |
|
685 | + if ($this->parent_data['arg'] instanceof WordPoints_Entity_Relationship) { |
|
686 | 686 | $primary_field = $this->parent_data['storage_info']['meta']['field']; |
687 | 687 | $join_field = $db['id_field']; |
688 | 688 | //$primary_field = $this->arg_data['arg']->get_secondary_field(); |
689 | - } elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) { |
|
689 | + } elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) { |
|
690 | 690 | $join_field = $db['join_field']; |
691 | 691 | $primary_field = $this->parent_data['storage_info']['meta']['id_field']; |
692 | 692 | } else { |
693 | - throw new WordPoints_Query_Builder_Exception( 'Houston, we have a problem.' ); |
|
693 | + throw new WordPoints_Query_Builder_Exception('Houston, we have a problem.'); |
|
694 | 694 | } |
695 | 695 | |
696 | - if ( is_array( $primary_field ) && isset( $primary_field['table_name'] ) ) { |
|
697 | - $this->builder->enter_join( $primary_field ); |
|
696 | + if (is_array($primary_field) && isset($primary_field['table_name'])) { |
|
697 | + $this->builder->enter_join($primary_field); |
|
698 | 698 | $primary_field = $primary_field['on']['join_field']; |
699 | 699 | } |
700 | 700 | |
@@ -706,26 +706,26 @@ discard block |
||
706 | 706 | ), |
707 | 707 | ); |
708 | 708 | |
709 | - if ( isset( $db['join_where'] ) ) { |
|
709 | + if (isset($db['join_where'])) { |
|
710 | 710 | $join['where'] = $db['join_where']; |
711 | 711 | } |
712 | 712 | |
713 | - $this->builder->enter_join( $join ); |
|
713 | + $this->builder->enter_join($join); |
|
714 | 714 | |
715 | 715 | $this->entered_join = true; |
716 | 716 | |
717 | 717 | } else { |
718 | - $this->builder->set_table( $db['table_name'] ); |
|
719 | - $this->builder->add_field( $db['id_field'] ); |
|
718 | + $this->builder->set_table($db['table_name']); |
|
719 | + $this->builder->add_field($db['id_field']); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
723 | - protected function build_conditions( $conditions ) { |
|
723 | + protected function build_conditions($conditions) { |
|
724 | 724 | |
725 | 725 | // Join conditions should be pushed to the end. |
726 | 726 | $join_conditions = array(); |
727 | 727 | |
728 | - foreach ( $conditions as $condition ) { |
|
728 | + foreach ($conditions as $condition) { |
|
729 | 729 | |
730 | 730 | // THis needs to be the identifier field for the type of arg that this |
731 | 731 | // field represents. |
@@ -733,43 +733,43 @@ discard block |
||
733 | 733 | // However, for a relationship it could be something else. |
734 | 734 | // Ultimately, this will have to be left up to the arg object to |
735 | 735 | // decide. |
736 | - if ( ! isset( $condition['field'] ) ) { |
|
737 | - if ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) { |
|
736 | + if ( ! isset($condition['field'])) { |
|
737 | + if ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) { |
|
738 | 738 | // $condition['field'] = $this->arg_data['arg']->get_secondary_field(); |
739 | 739 | $condition['field'] = $this->arg_data['storage_info']['meta']['field']; |
740 | 740 | |
741 | - if ( is_array( $condition['field'] && isset( $condition['field']['table_name'] ) ) ) { |
|
741 | + if (is_array($condition['field'] && isset($condition['field']['table_name']))) { |
|
742 | 742 | $join_conditions[] = $condition; |
743 | 743 | continue; |
744 | 744 | } |
745 | - } elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Attr ) { |
|
745 | + } elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Attr) { |
|
746 | 746 | $condition['field'] = $this->arg_data['arg']->get_field(); |
747 | 747 | } else { |
748 | - var_dump($this->arg_data['arg']);exit; |
|
748 | + var_dump($this->arg_data['arg']); exit; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | - $this->builder->where( $condition ); |
|
752 | + $this->builder->where($condition); |
|
753 | 753 | } |
754 | 754 | |
755 | - $join_count = count( $join_conditions ); |
|
755 | + $join_count = count($join_conditions); |
|
756 | 756 | $i = 0; |
757 | 757 | |
758 | - foreach ( $join_conditions as $condition ) { |
|
758 | + foreach ($join_conditions as $condition) { |
|
759 | 759 | |
760 | 760 | $i++; |
761 | 761 | |
762 | - $this->builder->enter_join( $condition['field'] ); |
|
762 | + $this->builder->enter_join($condition['field']); |
|
763 | 763 | |
764 | 764 | $condition['field'] = $condition['field']['on']['primary_field']; |
765 | 765 | |
766 | - $this->builder->where( $condition ); |
|
766 | + $this->builder->where($condition); |
|
767 | 767 | |
768 | 768 | $this->builder->exit_join(); |
769 | 769 | |
770 | 770 | // If there are more join conditions, we need to leave a fresh, trailing |
771 | 771 | // join for the next one to join to. |
772 | - if ( $i < $join_count ) { |
|
772 | + if ($i < $join_count) { |
|
773 | 773 | |
774 | 774 | // There is a current join, but it is already being used, so we |
775 | 775 | // need to exit it. |
@@ -10,123 +10,123 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // auto-generated { |
13 | -$dir = dirname( __FILE__ ); |
|
14 | -require_once( $dir . '/specedi.php' ); |
|
15 | -require_once( $dir . '/hook/settingsi.php' ); |
|
16 | -require_once( $dir . '/hook/retroactive/queryi.php' ); |
|
17 | -require_once( $dir . '/hook/retroactive/query/modifieri.php' ); |
|
18 | -require_once( $dir . '/hook/reactioni.php' ); |
|
19 | -require_once( $dir . '/hook/reaction/storei.php' ); |
|
20 | -require_once( $dir . '/hook/extension/miss/listeneri.php' ); |
|
21 | -require_once( $dir . '/hook/extension/hit/listeneri.php' ); |
|
22 | -require_once( $dir . '/hook/eventi.php' ); |
|
23 | -require_once( $dir . '/hook/event/reversingi.php' ); |
|
24 | -require_once( $dir . '/hook/conditioni.php' ); |
|
25 | -require_once( $dir . '/hook/actioni.php' ); |
|
26 | -require_once( $dir . '/entityishi.php' ); |
|
27 | -require_once( $dir . '/entityish/storedi.php' ); |
|
28 | -require_once( $dir . '/entity/restricted/visibilityi.php' ); |
|
29 | -require_once( $dir . '/entity/parenti.php' ); |
|
30 | -require_once( $dir . '/entity/hierarchyi.php' ); |
|
31 | -require_once( $dir . '/entity/enumerablei.php' ); |
|
32 | -require_once( $dir . '/entity/childi.php' ); |
|
33 | -require_once( $dir . '/data/typei.php' ); |
|
34 | -require_once( $dir . '/class/registryi.php' ); |
|
35 | -require_once( $dir . '/class/registry/childreni.php' ); |
|
36 | -require_once( $dir . '/app.php' ); |
|
37 | -require_once( $dir . '/app/registry.php' ); |
|
38 | -require_once( $dir . '/class/autoloader.php' ); |
|
39 | -require_once( $dir . '/class/registry.php' ); |
|
40 | -require_once( $dir . '/class/registry/children.php' ); |
|
41 | -require_once( $dir . '/class/registry/persistent.php' ); |
|
42 | -require_once( $dir . '/data/type.php' ); |
|
43 | -require_once( $dir . '/data/type/integer.php' ); |
|
44 | -require_once( $dir . '/data/type/text.php' ); |
|
45 | -require_once( $dir . '/db/query.php' ); |
|
46 | -require_once( $dir . '/entityish.php' ); |
|
47 | -require_once( $dir . '/entity.php' ); |
|
48 | -require_once( $dir . '/entity/relationship.php' ); |
|
49 | -require_once( $dir . '/entity/relationship/dynamic.php' ); |
|
50 | -require_once( $dir . '/entity/relationship/stored/field.php' ); |
|
51 | -require_once( $dir . '/entity/stored/array.php' ); |
|
52 | -require_once( $dir . '/entity/stored/db/table.php' ); |
|
53 | -require_once( $dir . '/entity/array.php' ); |
|
54 | -require_once( $dir . '/entity/attr.php' ); |
|
55 | -require_once( $dir . '/entity/attr/field.php' ); |
|
56 | -require_once( $dir . '/entity/change.php' ); |
|
57 | -require_once( $dir . '/entity/comment.php' ); |
|
58 | -require_once( $dir . '/entity/comment/author.php' ); |
|
59 | -require_once( $dir . '/entity/comment/post.php' ); |
|
60 | -require_once( $dir . '/entity/context.php' ); |
|
61 | -require_once( $dir . '/entity/context/network.php' ); |
|
62 | -require_once( $dir . '/entity/context/site.php' ); |
|
63 | -require_once( $dir . '/entity/hierarchy.php' ); |
|
64 | -require_once( $dir . '/entity/post.php' ); |
|
65 | -require_once( $dir . '/entity/post/author.php' ); |
|
66 | -require_once( $dir . '/entity/post/content.php' ); |
|
67 | -require_once( $dir . '/entity/post/terms.php' ); |
|
68 | -require_once( $dir . '/entity/post/type.php' ); |
|
69 | -require_once( $dir . '/entity/post/type/name.php' ); |
|
70 | -require_once( $dir . '/entity/post/type/relationship.php' ); |
|
71 | -require_once( $dir . '/entity/site.php' ); |
|
72 | -require_once( $dir . '/entity/term.php' ); |
|
73 | -require_once( $dir . '/entity/term/id.php' ); |
|
74 | -require_once( $dir . '/entity/user.php' ); |
|
75 | -require_once( $dir . '/entity/user/role.php' ); |
|
76 | -require_once( $dir . '/entity/user/role/name.php' ); |
|
77 | -require_once( $dir . '/entity/user/roles.php' ); |
|
78 | -require_once( $dir . '/hierarchy.php' ); |
|
79 | -require_once( $dir . '/hook/action.php' ); |
|
80 | -require_once( $dir . '/hook/action/comment/new.php' ); |
|
81 | -require_once( $dir . '/hook/action/post/publish.php' ); |
|
82 | -require_once( $dir . '/hook/actions.php' ); |
|
83 | -require_once( $dir . '/hook/arg.php' ); |
|
84 | -require_once( $dir . '/hook/arg/current/post.php' ); |
|
85 | -require_once( $dir . '/hook/arg/current/site.php' ); |
|
86 | -require_once( $dir . '/hook/arg/current/user.php' ); |
|
87 | -require_once( $dir . '/hook/arg/dynamic.php' ); |
|
88 | -require_once( $dir . '/hook/condition.php' ); |
|
89 | -require_once( $dir . '/hook/condition/entity/array/contains.php' ); |
|
90 | -require_once( $dir . '/hook/condition/equals.php' ); |
|
91 | -require_once( $dir . '/hook/condition/string/contains.php' ); |
|
92 | -require_once( $dir . '/hook/event.php' ); |
|
93 | -require_once( $dir . '/hook/event/dynamic.php' ); |
|
94 | -require_once( $dir . '/hook/event/args.php' ); |
|
95 | -require_once( $dir . '/hook/event/comment/leave.php' ); |
|
96 | -require_once( $dir . '/hook/event/media/upload.php' ); |
|
97 | -require_once( $dir . '/hook/event/post/publish.php' ); |
|
98 | -require_once( $dir . '/hook/event/user/register.php' ); |
|
99 | -require_once( $dir . '/hook/event/user/visit.php' ); |
|
100 | -require_once( $dir . '/hook/events.php' ); |
|
101 | -require_once( $dir . '/hook/extension.php' ); |
|
102 | -require_once( $dir . '/hook/extension/blocker.php' ); |
|
103 | -require_once( $dir . '/hook/extension/conditions.php' ); |
|
104 | -require_once( $dir . '/hook/extension/periods.php' ); |
|
105 | -require_once( $dir . '/hook/extension/repeat/blocker.php' ); |
|
106 | -require_once( $dir . '/hook/extension/reversals.php' ); |
|
107 | -require_once( $dir . '/hook/extension/reversals/legacy/points.php' ); |
|
108 | -require_once( $dir . '/hook/fire.php' ); |
|
109 | -require_once( $dir . '/hook/hit/logger.php' ); |
|
110 | -require_once( $dir . '/hook/hit/query.php' ); |
|
111 | -require_once( $dir . '/hook/reaction.php' ); |
|
112 | -require_once( $dir . '/hook/reaction/options.php' ); |
|
113 | -require_once( $dir . '/hook/reaction/store.php' ); |
|
114 | -require_once( $dir . '/hook/reaction/store/options.php' ); |
|
115 | -require_once( $dir . '/hook/reaction/store/options/network.php' ); |
|
116 | -require_once( $dir . '/hook/reaction/validator.php' ); |
|
117 | -require_once( $dir . '/hook/reactor.php' ); |
|
118 | -require_once( $dir . '/hook/reactor/points.php' ); |
|
119 | -require_once( $dir . '/hook/reactor/points/legacy.php' ); |
|
120 | -require_once( $dir . '/hook/retroactive/conditions.php' ); |
|
121 | -require_once( $dir . '/hook/retroactive/query.php' ); |
|
122 | -require_once( $dir . '/hook/retroactive/queryable.php' ); |
|
123 | -require_once( $dir . '/hook/router.php' ); |
|
124 | -require_once( $dir . '/hook/settings.php' ); |
|
125 | -require_once( $dir . '/hook/validator/exception.php' ); |
|
126 | -require_once( $dir . '/hooks.php' ); |
|
127 | -require_once( $dir . '/query/builder/db/mysql.php' ); |
|
128 | -require_once( $dir . '/spec.php' ); |
|
129 | -require_once( $dir . '/wpdb/wrapper.php' ); |
|
13 | +$dir = dirname(__FILE__); |
|
14 | +require_once($dir.'/specedi.php'); |
|
15 | +require_once($dir.'/hook/settingsi.php'); |
|
16 | +require_once($dir.'/hook/retroactive/queryi.php'); |
|
17 | +require_once($dir.'/hook/retroactive/query/modifieri.php'); |
|
18 | +require_once($dir.'/hook/reactioni.php'); |
|
19 | +require_once($dir.'/hook/reaction/storei.php'); |
|
20 | +require_once($dir.'/hook/extension/miss/listeneri.php'); |
|
21 | +require_once($dir.'/hook/extension/hit/listeneri.php'); |
|
22 | +require_once($dir.'/hook/eventi.php'); |
|
23 | +require_once($dir.'/hook/event/reversingi.php'); |
|
24 | +require_once($dir.'/hook/conditioni.php'); |
|
25 | +require_once($dir.'/hook/actioni.php'); |
|
26 | +require_once($dir.'/entityishi.php'); |
|
27 | +require_once($dir.'/entityish/storedi.php'); |
|
28 | +require_once($dir.'/entity/restricted/visibilityi.php'); |
|
29 | +require_once($dir.'/entity/parenti.php'); |
|
30 | +require_once($dir.'/entity/hierarchyi.php'); |
|
31 | +require_once($dir.'/entity/enumerablei.php'); |
|
32 | +require_once($dir.'/entity/childi.php'); |
|
33 | +require_once($dir.'/data/typei.php'); |
|
34 | +require_once($dir.'/class/registryi.php'); |
|
35 | +require_once($dir.'/class/registry/childreni.php'); |
|
36 | +require_once($dir.'/app.php'); |
|
37 | +require_once($dir.'/app/registry.php'); |
|
38 | +require_once($dir.'/class/autoloader.php'); |
|
39 | +require_once($dir.'/class/registry.php'); |
|
40 | +require_once($dir.'/class/registry/children.php'); |
|
41 | +require_once($dir.'/class/registry/persistent.php'); |
|
42 | +require_once($dir.'/data/type.php'); |
|
43 | +require_once($dir.'/data/type/integer.php'); |
|
44 | +require_once($dir.'/data/type/text.php'); |
|
45 | +require_once($dir.'/db/query.php'); |
|
46 | +require_once($dir.'/entityish.php'); |
|
47 | +require_once($dir.'/entity.php'); |
|
48 | +require_once($dir.'/entity/relationship.php'); |
|
49 | +require_once($dir.'/entity/relationship/dynamic.php'); |
|
50 | +require_once($dir.'/entity/relationship/stored/field.php'); |
|
51 | +require_once($dir.'/entity/stored/array.php'); |
|
52 | +require_once($dir.'/entity/stored/db/table.php'); |
|
53 | +require_once($dir.'/entity/array.php'); |
|
54 | +require_once($dir.'/entity/attr.php'); |
|
55 | +require_once($dir.'/entity/attr/field.php'); |
|
56 | +require_once($dir.'/entity/change.php'); |
|
57 | +require_once($dir.'/entity/comment.php'); |
|
58 | +require_once($dir.'/entity/comment/author.php'); |
|
59 | +require_once($dir.'/entity/comment/post.php'); |
|
60 | +require_once($dir.'/entity/context.php'); |
|
61 | +require_once($dir.'/entity/context/network.php'); |
|
62 | +require_once($dir.'/entity/context/site.php'); |
|
63 | +require_once($dir.'/entity/hierarchy.php'); |
|
64 | +require_once($dir.'/entity/post.php'); |
|
65 | +require_once($dir.'/entity/post/author.php'); |
|
66 | +require_once($dir.'/entity/post/content.php'); |
|
67 | +require_once($dir.'/entity/post/terms.php'); |
|
68 | +require_once($dir.'/entity/post/type.php'); |
|
69 | +require_once($dir.'/entity/post/type/name.php'); |
|
70 | +require_once($dir.'/entity/post/type/relationship.php'); |
|
71 | +require_once($dir.'/entity/site.php'); |
|
72 | +require_once($dir.'/entity/term.php'); |
|
73 | +require_once($dir.'/entity/term/id.php'); |
|
74 | +require_once($dir.'/entity/user.php'); |
|
75 | +require_once($dir.'/entity/user/role.php'); |
|
76 | +require_once($dir.'/entity/user/role/name.php'); |
|
77 | +require_once($dir.'/entity/user/roles.php'); |
|
78 | +require_once($dir.'/hierarchy.php'); |
|
79 | +require_once($dir.'/hook/action.php'); |
|
80 | +require_once($dir.'/hook/action/comment/new.php'); |
|
81 | +require_once($dir.'/hook/action/post/publish.php'); |
|
82 | +require_once($dir.'/hook/actions.php'); |
|
83 | +require_once($dir.'/hook/arg.php'); |
|
84 | +require_once($dir.'/hook/arg/current/post.php'); |
|
85 | +require_once($dir.'/hook/arg/current/site.php'); |
|
86 | +require_once($dir.'/hook/arg/current/user.php'); |
|
87 | +require_once($dir.'/hook/arg/dynamic.php'); |
|
88 | +require_once($dir.'/hook/condition.php'); |
|
89 | +require_once($dir.'/hook/condition/entity/array/contains.php'); |
|
90 | +require_once($dir.'/hook/condition/equals.php'); |
|
91 | +require_once($dir.'/hook/condition/string/contains.php'); |
|
92 | +require_once($dir.'/hook/event.php'); |
|
93 | +require_once($dir.'/hook/event/dynamic.php'); |
|
94 | +require_once($dir.'/hook/event/args.php'); |
|
95 | +require_once($dir.'/hook/event/comment/leave.php'); |
|
96 | +require_once($dir.'/hook/event/media/upload.php'); |
|
97 | +require_once($dir.'/hook/event/post/publish.php'); |
|
98 | +require_once($dir.'/hook/event/user/register.php'); |
|
99 | +require_once($dir.'/hook/event/user/visit.php'); |
|
100 | +require_once($dir.'/hook/events.php'); |
|
101 | +require_once($dir.'/hook/extension.php'); |
|
102 | +require_once($dir.'/hook/extension/blocker.php'); |
|
103 | +require_once($dir.'/hook/extension/conditions.php'); |
|
104 | +require_once($dir.'/hook/extension/periods.php'); |
|
105 | +require_once($dir.'/hook/extension/repeat/blocker.php'); |
|
106 | +require_once($dir.'/hook/extension/reversals.php'); |
|
107 | +require_once($dir.'/hook/extension/reversals/legacy/points.php'); |
|
108 | +require_once($dir.'/hook/fire.php'); |
|
109 | +require_once($dir.'/hook/hit/logger.php'); |
|
110 | +require_once($dir.'/hook/hit/query.php'); |
|
111 | +require_once($dir.'/hook/reaction.php'); |
|
112 | +require_once($dir.'/hook/reaction/options.php'); |
|
113 | +require_once($dir.'/hook/reaction/store.php'); |
|
114 | +require_once($dir.'/hook/reaction/store/options.php'); |
|
115 | +require_once($dir.'/hook/reaction/store/options/network.php'); |
|
116 | +require_once($dir.'/hook/reaction/validator.php'); |
|
117 | +require_once($dir.'/hook/reactor.php'); |
|
118 | +require_once($dir.'/hook/reactor/points.php'); |
|
119 | +require_once($dir.'/hook/reactor/points/legacy.php'); |
|
120 | +require_once($dir.'/hook/retroactive/conditions.php'); |
|
121 | +require_once($dir.'/hook/retroactive/query.php'); |
|
122 | +require_once($dir.'/hook/retroactive/queryable.php'); |
|
123 | +require_once($dir.'/hook/router.php'); |
|
124 | +require_once($dir.'/hook/settings.php'); |
|
125 | +require_once($dir.'/hook/validator/exception.php'); |
|
126 | +require_once($dir.'/hooks.php'); |
|
127 | +require_once($dir.'/query/builder/db/mysql.php'); |
|
128 | +require_once($dir.'/spec.php'); |
|
129 | +require_once($dir.'/wpdb/wrapper.php'); |
|
130 | 130 | // } |
131 | 131 | |
132 | 132 | // EOF |
@@ -33,10 +33,10 @@ 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' ); |
|
39 | - $reactors->register( 'points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | + $reactors->register('points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param WordPoints_Class_Registry_Children $reaction_stores The store registry. |
50 | 50 | */ |
51 | -function wordpoints_hook_reaction_stores_init( $reaction_stores ) { |
|
51 | +function wordpoints_hook_reaction_stores_init($reaction_stores) { |
|
52 | 52 | |
53 | 53 | $reaction_stores->register( |
54 | 54 | 'standard' |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | , 'WordPoints_Hook_Reaction_Store_Options' |
57 | 57 | ); |
58 | 58 | |
59 | - if ( is_wordpoints_network_active() ) { |
|
59 | + if (is_wordpoints_network_active()) { |
|
60 | 60 | $reaction_stores->register( |
61 | 61 | 'network' |
62 | 62 | , 'points' |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
76 | 76 | */ |
77 | -function wordpoints_hook_extension_init( $extensions ) { |
|
78 | - |
|
79 | - $extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' ); |
|
80 | - $extensions->register( 'repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker' ); |
|
81 | - $extensions->register( 'reversals', 'WordPoints_Hook_Extension_Reversals' ); |
|
82 | - $extensions->register( 'reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points' ); |
|
83 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
84 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
77 | +function wordpoints_hook_extension_init($extensions) { |
|
78 | + |
|
79 | + $extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker'); |
|
80 | + $extensions->register('repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker'); |
|
81 | + $extensions->register('reversals', 'WordPoints_Hook_Extension_Reversals'); |
|
82 | + $extensions->register('reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points'); |
|
83 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
84 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
95 | 95 | */ |
96 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
96 | +function wordpoints_hook_conditions_init($conditions) { |
|
97 | 97 | |
98 | 98 | $conditions->register( |
99 | 99 | 'text' |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @param WordPoints_Hook_Actions $actions The action registry. |
131 | 131 | */ |
132 | -function wordpoints_hook_actions_init( $actions ) { |
|
132 | +function wordpoints_hook_actions_init($actions) { |
|
133 | 133 | |
134 | 134 | $actions->register( |
135 | 135 | 'comment_approve' |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | , array( |
138 | 138 | 'action' => 'transition_comment_status', |
139 | 139 | 'data' => array( |
140 | - 'arg_index' => array( 'comment' => 2 ), |
|
141 | - 'requirements' => array( 0 => 'approved' ), |
|
140 | + 'arg_index' => array('comment' => 2), |
|
141 | + 'requirements' => array(0 => 'approved'), |
|
142 | 142 | ), |
143 | 143 | ) |
144 | 144 | ); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | , array( |
150 | 150 | 'action' => 'wp_insert_comment', |
151 | 151 | 'data' => array( |
152 | - 'arg_index' => array( 'comment' => 1 ), |
|
152 | + 'arg_index' => array('comment' => 1), |
|
153 | 153 | ), |
154 | 154 | ) |
155 | 155 | ); |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | , array( |
161 | 161 | 'action' => 'transition_comment_status', |
162 | 162 | 'data' => array( |
163 | - 'arg_index' => array( 'comment' => 2 ), |
|
164 | - 'requirements' => array( 1 => 'approved' ), |
|
163 | + 'arg_index' => array('comment' => 2), |
|
164 | + 'requirements' => array(1 => 'approved'), |
|
165 | 165 | ), |
166 | 166 | ) |
167 | 167 | ); |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | , array( |
174 | 174 | 'action' => 'transition_post_status', |
175 | 175 | 'data' => array( |
176 | - 'arg_index' => array( 'post' => 2 ), |
|
177 | - 'requirements' => array( 0 => 'publish' ), |
|
176 | + 'arg_index' => array('post' => 2), |
|
177 | + 'requirements' => array(0 => 'publish'), |
|
178 | 178 | ), |
179 | 179 | ) |
180 | 180 | ); |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | , array( |
186 | 186 | 'action' => 'transition_post_status', |
187 | 187 | 'data' => array( |
188 | - 'arg_index' => array( 'post' => 2 ), |
|
189 | - 'requirements' => array( 1 => 'publish' ), |
|
188 | + 'arg_index' => array('post' => 2), |
|
189 | + 'requirements' => array(1 => 'publish'), |
|
190 | 190 | ), |
191 | 191 | ) |
192 | 192 | ); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | , array( |
198 | 198 | 'action' => 'add_attachment', |
199 | 199 | 'data' => array( |
200 | - 'arg_index' => array( 'post\attachment' => 0 ), |
|
200 | + 'arg_index' => array('post\attachment' => 0), |
|
201 | 201 | ), |
202 | 202 | ) |
203 | 203 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | , array( |
209 | 209 | 'action' => 'delete_post', |
210 | 210 | 'data' => array( |
211 | - 'arg_index' => array( 'post' => 0 ), |
|
211 | + 'arg_index' => array('post' => 0), |
|
212 | 212 | ), |
213 | 213 | ) |
214 | 214 | ); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | , array( |
220 | 220 | 'action' => 'user_register', |
221 | 221 | 'data' => array( |
222 | - 'arg_index' => array( 'user' => 0 ), |
|
222 | + 'arg_index' => array('user' => 0), |
|
223 | 223 | ), |
224 | 224 | ) |
225 | 225 | ); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | , array( |
231 | 231 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
232 | 232 | 'data' => array( |
233 | - 'arg_index' => array( 'user' => 0 ), |
|
233 | + 'arg_index' => array('user' => 0), |
|
234 | 234 | ), |
235 | 235 | ) |
236 | 236 | ); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param WordPoints_Hook_Events $events The event registry. |
255 | 255 | */ |
256 | -function wordpoints_hook_events_init( $events ) { |
|
256 | +function wordpoints_hook_events_init($events) { |
|
257 | 257 | |
258 | 258 | $events->register( |
259 | 259 | 'user_register' |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | ); |
284 | 284 | |
285 | 285 | // Register events for all of the public post types. |
286 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
286 | + $post_types = get_post_types(array('public' => true)); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Filter which post types to register hook events for. |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @param string[] The post type slugs ("names"). |
294 | 294 | */ |
295 | - $post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types ); |
|
295 | + $post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types); |
|
296 | 296 | |
297 | - foreach ( $post_types as $slug ) { |
|
298 | - wordpoints_register_post_type_hook_events( $slug ); |
|
297 | + foreach ($post_types as $slug) { |
|
298 | + wordpoints_register_post_type_hook_events($slug); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param WordPoints_App_Registry $entities The entities app. |
310 | 310 | */ |
311 | -function wordpoints_entities_app_init( $entities ) { |
|
311 | +function wordpoints_entities_app_init($entities) { |
|
312 | 312 | |
313 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
314 | - $entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' ); |
|
313 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
314 | + $entities->sub_apps->register('contexts', 'WordPoints_Class_Registry'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param WordPoints_Class_Registry $contexts The entity context registry. |
325 | 325 | */ |
326 | -function wordpoints_entity_contexts_init( $contexts ) { |
|
326 | +function wordpoints_entity_contexts_init($contexts) { |
|
327 | 327 | |
328 | - $contexts->register( 'network', 'WordPoints_Entity_Context_Network' ); |
|
329 | - $contexts->register( 'site', 'WordPoints_Entity_Context_Site' ); |
|
328 | + $contexts->register('network', 'WordPoints_Entity_Context_Network'); |
|
329 | + $contexts->register('site', 'WordPoints_Entity_Context_Site'); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param WordPoints_App_Registry $entities The entities app. |
340 | 340 | */ |
341 | -function wordpoints_entities_init( $entities ) { |
|
341 | +function wordpoints_entities_init($entities) { |
|
342 | 342 | |
343 | 343 | $children = $entities->children; |
344 | 344 | |
345 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
346 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
345 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
346 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
347 | 347 | |
348 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
349 | - $children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
348 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
349 | + $children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
350 | 350 | |
351 | 351 | // Register entities for all of the public post types. |
352 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
352 | + $post_types = get_post_types(array('public' => true)); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Filter which post types to register entities for. |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param string[] The post type slugs ("names"). |
360 | 360 | */ |
361 | - $post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types ); |
|
361 | + $post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types); |
|
362 | 362 | |
363 | - foreach ( $post_types as $slug ) { |
|
364 | - wordpoints_register_post_type_entities( $slug ); |
|
363 | + foreach ($post_types as $slug) { |
|
364 | + wordpoints_register_post_type_entities($slug); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | // Register entities for all of the public taxonomies. |
368 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
368 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Filter which taxonomies to register entities for. |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @param string[] The taxonomy slugs. |
376 | 376 | */ |
377 | - $taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies ); |
|
377 | + $taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies); |
|
378 | 378 | |
379 | - foreach ( $taxonomies as $slug ) { |
|
380 | - wordpoints_register_taxonomy_entities( $slug ); |
|
379 | + foreach ($taxonomies as $slug) { |
|
380 | + wordpoints_register_taxonomy_entities($slug); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -388,28 +388,28 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param string $slug The slug of the post type. |
390 | 390 | */ |
391 | -function wordpoints_register_post_type_entities( $slug ) { |
|
391 | +function wordpoints_register_post_type_entities($slug) { |
|
392 | 392 | |
393 | 393 | $entities = wordpoints_entities(); |
394 | 394 | $children = $entities->children; |
395 | 395 | |
396 | - $entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' ); |
|
397 | - $children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' ); |
|
396 | + $entities->register("post\\{$slug}", 'WordPoints_Entity_Post'); |
|
397 | + $children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author'); |
|
398 | 398 | |
399 | - $supports = get_all_post_type_supports( $slug ); |
|
399 | + $supports = get_all_post_type_supports($slug); |
|
400 | 400 | |
401 | - if ( isset( $supports['editor'] ) ) { |
|
402 | - $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
|
401 | + if (isset($supports['editor'])) { |
|
402 | + $children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content'); |
|
403 | 403 | } |
404 | 404 | |
405 | - if ( isset( $supports['comments'] ) ) { |
|
406 | - $entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' ); |
|
407 | - $children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' ); |
|
408 | - $children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' ); |
|
405 | + if (isset($supports['comments'])) { |
|
406 | + $entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment'); |
|
407 | + $children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post'); |
|
408 | + $children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author'); |
|
409 | 409 | } |
410 | 410 | |
411 | - foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) { |
|
412 | - $children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' ); |
|
411 | + foreach (get_object_taxonomies($slug) as $taxonomy_slug) { |
|
412 | + $children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms'); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @param string $slug The slug ("name") of the post type. |
421 | 421 | */ |
422 | - do_action( 'wordpoints_register_post_type_entities', $slug ); |
|
422 | + do_action('wordpoints_register_post_type_entities', $slug); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @param string $slug The slug of the post type. |
431 | 431 | */ |
432 | -function wordpoints_register_post_type_hook_events( $slug ) { |
|
432 | +function wordpoints_register_post_type_hook_events($slug) { |
|
433 | 433 | |
434 | 434 | $events = wordpoints_hooks()->events; |
435 | 435 | |
436 | - if ( 'attachment' === $slug ) { |
|
436 | + if ('attachment' === $slug) { |
|
437 | 437 | |
438 | 438 | $events->register( |
439 | 439 | 'media_upload' |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | , array( |
458 | 458 | 'actions' => array( |
459 | 459 | 'toggle_on' => 'post_publish', |
460 | - 'toggle_off' => array( 'post_depublish', 'post_delete' ), |
|
460 | + 'toggle_off' => array('post_depublish', 'post_delete'), |
|
461 | 461 | ), |
462 | 462 | 'args' => array( |
463 | 463 | "post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic', |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | ); |
467 | 467 | } |
468 | 468 | |
469 | - if ( post_type_supports( $slug, 'comments' ) ) { |
|
469 | + if (post_type_supports($slug, 'comments')) { |
|
470 | 470 | |
471 | 471 | $events->register( |
472 | 472 | "comment_leave\\{$slug}" |
473 | 473 | , 'WordPoints_Hook_Event_Comment_Leave' |
474 | 474 | , array( |
475 | 475 | 'actions' => array( |
476 | - 'toggle_on' => array( 'comment_approve', 'comment_new' ), |
|
476 | + 'toggle_on' => array('comment_approve', 'comment_new'), |
|
477 | 477 | 'toggle_off' => 'comment_deapprove', |
478 | 478 | ), |
479 | 479 | 'args' => array( |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * |
491 | 491 | * @param string $slug The slug ("name") of the post type. |
492 | 492 | */ |
493 | - do_action( 'wordpoints_register_post_type_hook_events', $slug ); |
|
493 | + do_action('wordpoints_register_post_type_hook_events', $slug); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @param string $slug The slug of the taxonomy. |
502 | 502 | */ |
503 | -function wordpoints_register_taxonomy_entities( $slug ) { |
|
503 | +function wordpoints_register_taxonomy_entities($slug) { |
|
504 | 504 | |
505 | 505 | $entities = wordpoints_entities(); |
506 | 506 | $children = $entities->children; |
507 | 507 | |
508 | - $entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' ); |
|
509 | - $children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' ); |
|
508 | + $entities->register("term\\{$slug}", 'WordPoints_Entity_Term'); |
|
509 | + $children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id'); |
|
510 | 510 | |
511 | 511 | /** |
512 | 512 | * Fired when registering the entities for a taxonomy. |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @param string $slug The taxonomy's slug. |
517 | 517 | */ |
518 | - do_action( 'wordpoints_register_taxonomy_entities', $slug ); |
|
518 | + do_action('wordpoints_register_taxonomy_entities', $slug); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
529 | 529 | */ |
530 | -function wordpoints_data_types_init( $data_types ) { |
|
530 | +function wordpoints_data_types_init($data_types) { |
|
531 | 531 | |
532 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
533 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
532 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
533 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @return bool Whether the user can view the points log. |
547 | 547 | */ |
548 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
548 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
549 | 549 | |
550 | - if ( ! $can_view ) { |
|
550 | + if ( ! $can_view) { |
|
551 | 551 | return $can_view; |
552 | 552 | } |
553 | 553 | |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | $event_slug = $log->log_type; |
557 | 557 | |
558 | 558 | /** @var WordPoints_Hook_Arg $arg */ |
559 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
559 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
560 | 560 | |
561 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
561 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
562 | 562 | |
563 | - if ( ! $value ) { |
|
563 | + if ( ! $value) { |
|
564 | 564 | continue; |
565 | 565 | } |
566 | 566 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | , $value |
571 | 571 | ); |
572 | 572 | |
573 | - if ( ! $can_view ) { |
|
573 | + if ( ! $can_view) { |
|
574 | 574 | break; |
575 | 575 | } |
576 | 576 | } |
@@ -589,20 +589,20 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return bool Whether the user can view this entity. |
591 | 591 | */ |
592 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
592 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
593 | 593 | |
594 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
594 | + $entity = wordpoints_entities()->get($entity_slug); |
|
595 | 595 | |
596 | 596 | // If this entity type is not found, we have no way of determining whether it is |
597 | 597 | // safe for the user to view it. |
598 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
598 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
599 | 599 | return false; |
600 | 600 | } |
601 | 601 | |
602 | 602 | $can_view = true; |
603 | 603 | |
604 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
605 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
604 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
605 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | */ |
634 | 634 | function wordpoints_apps() { |
635 | 635 | |
636 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
637 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
636 | + if ( ! isset(WordPoints_App::$main)) { |
|
637 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | return WordPoints_App::$main; |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function wordpoints_hooks() { |
651 | 651 | |
652 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
652 | + if ( ! isset(WordPoints_App::$main)) { |
|
653 | 653 | wordpoints_apps(); |
654 | 654 | } |
655 | 655 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | */ |
666 | 666 | function wordpoints_entities() { |
667 | 667 | |
668 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
668 | + if ( ! isset(WordPoints_App::$main)) { |
|
669 | 669 | wordpoints_apps(); |
670 | 670 | } |
671 | 671 | |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @param WordPoints_App $app The main apps app. |
683 | 683 | */ |
684 | -function wordpoints_apps_init( $app ) { |
|
684 | +function wordpoints_apps_init($app) { |
|
685 | 685 | |
686 | 686 | $apps = $app->sub_apps; |
687 | 687 | |
688 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
689 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
690 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
688 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
689 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
690 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -700,19 +700,19 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return object|false The constructed object, or false if to many args were passed. |
702 | 702 | */ |
703 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
703 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
704 | 704 | |
705 | - switch ( count( $args ) ) { |
|
705 | + switch (count($args)) { |
|
706 | 706 | case 0: |
707 | 707 | return new $class_name(); |
708 | 708 | case 1: |
709 | - return new $class_name( $args[0] ); |
|
709 | + return new $class_name($args[0]); |
|
710 | 710 | case 2: |
711 | - return new $class_name( $args[0], $args[1] ); |
|
711 | + return new $class_name($args[0], $args[1]); |
|
712 | 712 | case 3: |
713 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
713 | + return new $class_name($args[0], $args[1], $args[2]); |
|
714 | 714 | case 4: |
715 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
715 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
716 | 716 | default: |
717 | 717 | return false; |
718 | 718 | } |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the |
735 | 735 | * slug is not dynamic, the value of each of those keys will be false. |
736 | 736 | */ |
737 | -function wordpoints_parse_dynamic_slug( $slug ) { |
|
737 | +function wordpoints_parse_dynamic_slug($slug) { |
|
738 | 738 | |
739 | - $parsed = array( 'dynamic' => false, 'generic' => false ); |
|
739 | + $parsed = array('dynamic' => false, 'generic' => false); |
|
740 | 740 | |
741 | - $parts = explode( '\\', $slug, 2 ); |
|
741 | + $parts = explode('\\', $slug, 2); |
|
742 | 742 | |
743 | - if ( isset( $parts[1] ) ) { |
|
743 | + if (isset($parts[1])) { |
|
744 | 744 | $parsed['dynamic'] = $parts[1]; |
745 | 745 | $parsed['generic'] = $parts[0]; |
746 | 746 | } |
@@ -779,28 +779,28 @@ discard block |
||
779 | 779 | * contexts, indexed by context slug, or false if any of the |
780 | 780 | * contexts isn't current. |
781 | 781 | */ |
782 | -function wordpoints_entities_get_current_context_id( $slug ) { |
|
782 | +function wordpoints_entities_get_current_context_id($slug) { |
|
783 | 783 | |
784 | 784 | $current_context = array(); |
785 | 785 | |
786 | 786 | /** @var WordPoints_Class_Registry $contexts */ |
787 | 787 | $contexts = wordpoints_entities()->contexts; |
788 | 788 | |
789 | - while ( $slug ) { |
|
789 | + while ($slug) { |
|
790 | 790 | |
791 | - $context = $contexts->get( $slug ); |
|
791 | + $context = $contexts->get($slug); |
|
792 | 792 | |
793 | - if ( ! $context instanceof WordPoints_Entity_Context ) { |
|
793 | + if ( ! $context instanceof WordPoints_Entity_Context) { |
|
794 | 794 | return false; |
795 | 795 | } |
796 | 796 | |
797 | 797 | $id = $context->get_current_id(); |
798 | 798 | |
799 | - if ( false === $id ) { |
|
799 | + if (false === $id) { |
|
800 | 800 | return false; |
801 | 801 | } |
802 | 802 | |
803 | - $current_context[ $slug ] = $id; |
|
803 | + $current_context[$slug] = $id; |
|
804 | 804 | |
805 | 805 | $slug = $context->get_parent_slug(); |
806 | 806 | } |
@@ -821,22 +821,22 @@ discard block |
||
821 | 821 | */ |
822 | 822 | function wordpoints_is_network_context() { |
823 | 823 | |
824 | - if ( ! is_multisite() ) { |
|
824 | + if ( ! is_multisite()) { |
|
825 | 825 | return false; |
826 | 826 | } |
827 | 827 | |
828 | - if ( is_network_admin() ) { |
|
828 | + if (is_network_admin()) { |
|
829 | 829 | return true; |
830 | 830 | } |
831 | 831 | |
832 | 832 | // See https://core.trac.wordpress.org/ticket/22589 |
833 | 833 | if ( |
834 | - defined( 'DOING_AJAX' ) |
|
834 | + defined('DOING_AJAX') |
|
835 | 835 | && DOING_AJAX |
836 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
836 | + && isset($_SERVER['HTTP_REFERER']) |
|
837 | 837 | && preg_match( |
838 | - '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
|
839 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
838 | + '#^'.preg_quote(network_admin_url(), '#').'#i' |
|
839 | + , esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) |
|
840 | 840 | ) |
841 | 841 | ) { |
842 | 842 | return true; |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @param bool $in_network_context Whether we are in network context. |
851 | 851 | */ |
852 | - return apply_filters( 'wordpoints_is_network_context', false ); |
|
852 | + return apply_filters('wordpoints_is_network_context', false); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -863,21 +863,21 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @return string The primary arg's GUID, JSON encoded. |
865 | 865 | */ |
866 | -function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) { |
|
866 | +function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) { |
|
867 | 867 | |
868 | 868 | $entity = $event_args->get_primary_arg(); |
869 | 869 | |
870 | - if ( ! $entity ) { |
|
870 | + if ( ! $entity) { |
|
871 | 871 | return ''; |
872 | 872 | } |
873 | 873 | |
874 | 874 | $the_guid = $entity->get_the_guid(); |
875 | 875 | |
876 | - if ( ! $the_guid ) { |
|
876 | + if ( ! $the_guid) { |
|
877 | 877 | return ''; |
878 | 878 | } |
879 | 879 | |
880 | - return wp_json_encode( $the_guid ); |
|
880 | + return wp_json_encode($the_guid); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | */ |
891 | 891 | function wordpoints_hooks_api_add_global_cache_groups() { |
892 | 892 | |
893 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
893 | + if (function_exists('wp_cache_add_global_groups')) { |
|
894 | 894 | |
895 | 895 | wp_cache_add_global_groups( |
896 | 896 | array( |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @return string The escaped identifier. Already quoted, do not place within |
917 | 917 | * backticks. |
918 | 918 | */ |
919 | -function wordpoints_escape_mysql_identifier( $identifier ) { |
|
920 | - return '`' . str_replace( '`', '``', $identifier ) . '`'; |
|
919 | +function wordpoints_escape_mysql_identifier($identifier) { |
|
920 | + return '`'.str_replace('`', '``', $identifier).'`'; |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | // EOF |