@@ -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 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->firer = $firer; |
74 | 74 | $this->event_args = $event_args; |
75 | 75 | $this->reaction = $reaction; |
76 | - $this->hit_logger = new WordPoints_Hook_Hit_Logger( $this ); |
|
76 | + $this->hit_logger = new WordPoints_Hook_Hit_Logger($this); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function hit() { |
87 | 87 | |
88 | - if ( ! $this->hit_id ) { |
|
88 | + if ( ! $this->hit_id) { |
|
89 | 89 | |
90 | 90 | $this->hit_id = $this->hit_logger->log_hit(); |
91 | 91 | |
92 | - if ( ! $this->hit_id ) { |
|
92 | + if ( ! $this->hit_id) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param WordPoints_Hook_Fire $fire The fire that might be logged as a hit. |
30 | 30 | */ |
31 | - public function __construct( WordPoints_Hook_Fire $fire ) { |
|
31 | + public function __construct(WordPoints_Hook_Fire $fire) { |
|
32 | 32 | |
33 | 33 | $this->fire = $fire; |
34 | 34 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | global $wpdb; |
46 | 46 | |
47 | - $signature = wordpoints_hooks_get_event_primary_arg_guid_json( $this->fire->event_args ); |
|
47 | + $signature = wordpoints_hooks_get_event_primary_arg_guid_json($this->fire->event_args); |
|
48 | 48 | |
49 | 49 | $inserted = $wpdb->insert( |
50 | 50 | $wpdb->wordpoints_hook_hits |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | 'event' => $this->fire->reaction->get_event_slug(), |
55 | 55 | 'reactor' => $this->fire->reaction->get_reactor_slug(), |
56 | 56 | 'reaction_store' => $this->fire->reaction->get_store_slug(), |
57 | - 'reaction_context_id' => wp_json_encode( $this->fire->reaction->get_context_id() ), |
|
57 | + 'reaction_context_id' => wp_json_encode($this->fire->reaction->get_context_id()), |
|
58 | 58 | 'reaction_id' => $this->fire->reaction->ID, |
59 | - 'date' => current_time( 'mysql' ), |
|
59 | + 'date' => current_time('mysql'), |
|
60 | 60 | ) |
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! $inserted ) { |
|
63 | + if ( ! $inserted) { |
|
64 | 64 | return false; |
65 | 65 | } |
66 | 66 |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | global $wpdb; |
11 | 11 | |
12 | -$wpdb->wordpoints_hook_hits = $wpdb->base_prefix . 'wordpoints_hook_hits'; |
|
13 | -$wpdb->wordpoints_hook_hitmeta = $wpdb->base_prefix . 'wordpoints_hook_hitmeta'; |
|
14 | -$wpdb->wordpoints_hook_periods = $wpdb->base_prefix . 'wordpoints_hook_periods'; |
|
12 | +$wpdb->wordpoints_hook_hits = $wpdb->base_prefix.'wordpoints_hook_hits'; |
|
13 | +$wpdb->wordpoints_hook_hitmeta = $wpdb->base_prefix.'wordpoints_hook_hitmeta'; |
|
14 | +$wpdb->wordpoints_hook_periods = $wpdb->base_prefix.'wordpoints_hook_periods'; |
|
15 | 15 | |
16 | 16 | // EOF |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @type array $meta_query See WP_Meta_Query. |
215 | 215 | * } |
216 | 216 | */ |
217 | - public function __construct( $args = array() ) { |
|
218 | - $this->args = array_merge( $this->defaults, $args ); |
|
217 | + public function __construct($args = array()) { |
|
218 | + $this->args = array_merge($this->defaults, $args); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return mixed|null The query arg's value, or null if it isn't set. |
229 | 229 | */ |
230 | - public function get_arg( $arg ) { |
|
230 | + public function get_arg($arg) { |
|
231 | 231 | |
232 | - if ( isset( $this->args[ $arg ] ) ) { |
|
233 | - return $this->args[ $arg ]; |
|
232 | + if (isset($this->args[$arg])) { |
|
233 | + return $this->args[$arg]; |
|
234 | 234 | } else { |
235 | 235 | return null; |
236 | 236 | } |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param array $args A list of arguments to set and their values. |
248 | 248 | */ |
249 | - public function set_args( array $args ) { |
|
249 | + public function set_args(array $args) { |
|
250 | 250 | |
251 | - $this->args = array_merge( $this->args, $args ); |
|
251 | + $this->args = array_merge($this->args, $args); |
|
252 | 252 | |
253 | 253 | $this->is_query_ready = false; |
254 | 254 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | global $wpdb; |
271 | 271 | |
272 | - $count = (int) $wpdb->get_var( $this->get_sql( 'SELECT COUNT' ) ); // WPCS: unprepared SQL, cache OK |
|
272 | + $count = (int) $wpdb->get_var($this->get_sql('SELECT COUNT')); // WPCS: unprepared SQL, cache OK |
|
273 | 273 | |
274 | 274 | return $count; |
275 | 275 | } |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return mixed The results of the query, or false on failure. |
286 | 286 | */ |
287 | - public function get( $method = 'results' ) { |
|
287 | + public function get($method = 'results') { |
|
288 | 288 | |
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $methods = array( 'results', 'row', 'col', 'var' ); |
|
291 | + $methods = array('results', 'row', 'col', 'var'); |
|
292 | 292 | |
293 | - if ( ! in_array( $method, $methods ) ) { |
|
293 | + if ( ! in_array($method, $methods)) { |
|
294 | 294 | |
295 | - _doing_it_wrong( __METHOD__, esc_html( sprintf( 'WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode( ', ', $methods ) ) ), '1.0.0' ); |
|
295 | + _doing_it_wrong(__METHOD__, esc_html(sprintf('WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode(', ', $methods))), '1.0.0'); |
|
296 | 296 | |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - $result = $wpdb->{"get_{$method}"}( $this->get_sql() ); |
|
300 | + $result = $wpdb->{"get_{$method}"}($this->get_sql()); |
|
301 | 301 | |
302 | 302 | return $result; |
303 | 303 | } |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string The SQL for the query. |
319 | 319 | */ |
320 | - public function get_sql( $select_type = 'SELECT' ) { |
|
320 | + public function get_sql($select_type = 'SELECT') { |
|
321 | 321 | |
322 | 322 | $this->prepare_query(); |
323 | 323 | |
324 | - $select = ( 'SELECT COUNT' === $select_type ) |
|
324 | + $select = ('SELECT COUNT' === $select_type) |
|
325 | 325 | ? $this->select_count |
326 | 326 | : $this->select; |
327 | 327 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return string[] The valid columns. |
351 | 351 | */ |
352 | - public function date_query_valid_columns_filter( $valid_columns ) { |
|
352 | + public function date_query_valid_columns_filter($valid_columns) { |
|
353 | 353 | |
354 | 354 | $valid_columns = array_merge( |
355 | 355 | $valid_columns |
356 | 356 | , array_keys( |
357 | - wp_list_filter( $this->columns, array( 'is_date' => true ) ) |
|
357 | + wp_list_filter($this->columns, array('is_date' => true)) |
|
358 | 358 | ) |
359 | 359 | ); |
360 | 360 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function prepare_query() { |
374 | 374 | |
375 | - if ( ! $this->is_query_ready ) { |
|
375 | + if ( ! $this->is_query_ready) { |
|
376 | 376 | |
377 | 377 | $this->prepare_select(); |
378 | 378 | $this->prepare_where(); |
@@ -390,26 +390,26 @@ discard block |
||
390 | 390 | */ |
391 | 391 | protected function prepare_select() { |
392 | 392 | |
393 | - $all_fields = array_keys( $this->columns ); |
|
393 | + $all_fields = array_keys($this->columns); |
|
394 | 394 | $fields = array(); |
395 | 395 | |
396 | - if ( ! empty( $this->args['fields'] ) ) { |
|
396 | + if ( ! empty($this->args['fields'])) { |
|
397 | 397 | |
398 | 398 | $fields = (array) $this->args['fields']; |
399 | - $diff = array_diff( $fields, $all_fields ); |
|
400 | - $fields = array_intersect( $all_fields, $fields ); |
|
399 | + $diff = array_diff($fields, $all_fields); |
|
400 | + $fields = array_intersect($all_fields, $fields); |
|
401 | 401 | |
402 | - if ( ! empty( $diff ) ) { |
|
403 | - _doing_it_wrong( __METHOD__, esc_html( 'WordPoints Debug Error: invalid field(s) "' . implode( '", "', $diff ) . '" given' ), '1.0.0' ); |
|
402 | + if ( ! empty($diff)) { |
|
403 | + _doing_it_wrong(__METHOD__, esc_html('WordPoints Debug Error: invalid field(s) "'.implode('", "', $diff).'" given'), '1.0.0'); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | 407 | // Pull all fields by default. |
408 | - if ( empty( $fields ) ) { |
|
408 | + if (empty($fields)) { |
|
409 | 409 | $fields = $all_fields; |
410 | 410 | } |
411 | 411 | |
412 | - $fields = implode( ', ', array_map( 'wordpoints_escape_mysql_identifier', $fields ) ); |
|
412 | + $fields = implode(', ', array_map('wordpoints_escape_mysql_identifier', $fields)); |
|
413 | 413 | |
414 | 414 | $this->select = "SELECT {$fields}"; |
415 | 415 | } |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @return mixed The validated value, or false if invalid. |
426 | 426 | */ |
427 | - protected function validate_value( $value, $validators ) { |
|
427 | + protected function validate_value($value, $validators) { |
|
428 | 428 | |
429 | - foreach ( $validators as $validator ) { |
|
429 | + foreach ($validators as $validator) { |
|
430 | 430 | |
431 | - $value = call_user_func_array( $validator, array( &$value ) ); |
|
431 | + $value = call_user_func_array($validator, array(&$value)); |
|
432 | 432 | |
433 | - if ( false === $value ) { |
|
433 | + if (false === $value) { |
|
434 | 434 | break; |
435 | 435 | } |
436 | 436 | } |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return array The validated values, with any invalid ones removed. |
450 | 450 | */ |
451 | - protected function validate_values( $values, $validators ) { |
|
451 | + protected function validate_values($values, $validators) { |
|
452 | 452 | |
453 | - foreach ( $values as $index => $value ) { |
|
453 | + foreach ($values as $index => $value) { |
|
454 | 454 | |
455 | - $value = $this->validate_value( $value, $validators ); |
|
455 | + $value = $this->validate_value($value, $validators); |
|
456 | 456 | |
457 | - if ( false === $value ) { |
|
458 | - unset( $values[ $index ] ); |
|
457 | + if (false === $value) { |
|
458 | + unset($values[$index]); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return int|false The validated value or false. |
476 | 476 | */ |
477 | - protected function validate_unsigned_column( $value ) { |
|
477 | + protected function validate_unsigned_column($value) { |
|
478 | 478 | |
479 | - if ( false !== wordpoints_int( $value ) && $value >= 0 ) { |
|
479 | + if (false !== wordpoints_int($value) && $value >= 0) { |
|
480 | 480 | return $value; |
481 | 481 | } |
482 | 482 | |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return callable[] The validation functions. |
494 | 494 | */ |
495 | - protected function get_validators_for_column( $data ) { |
|
495 | + protected function get_validators_for_column($data) { |
|
496 | 496 | |
497 | 497 | $validators = array(); |
498 | 498 | |
499 | 499 | // Default validators for integer columns. |
500 | - if ( '%d' === $data['format'] ) { |
|
501 | - if ( ! empty( $data['unsigned'] ) ) { |
|
502 | - $validators[] = array( $this, 'validate_unsigned_column' ); |
|
500 | + if ('%d' === $data['format']) { |
|
501 | + if ( ! empty($data['unsigned'])) { |
|
502 | + $validators[] = array($this, 'validate_unsigned_column'); |
|
503 | 503 | } else { |
504 | 504 | $validators[] = 'wordpoints_int'; |
505 | 505 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @param string $column The column name. |
517 | 517 | * @param array $data The column data. |
518 | 518 | */ |
519 | - protected function prepare_column_where( $column, $data ) { |
|
519 | + protected function prepare_column_where($column, $data) { |
|
520 | 520 | |
521 | 521 | // If a single value has been supplied for the column, it takes precedence. |
522 | - if ( isset( $this->args[ $column ] ) ) { |
|
523 | - $this->prepare_column( $column, $data ); |
|
524 | - } elseif ( isset( $this->args[ "{$column}__in" ] ) ) { |
|
525 | - $this->prepare_column__in( $column, $data ); |
|
526 | - } elseif ( isset( $this->args[ "{$column}__not_in" ] ) ) { |
|
527 | - $this->prepare_column__in( $column, $data, 'NOT IN' ); |
|
522 | + if (isset($this->args[$column])) { |
|
523 | + $this->prepare_column($column, $data); |
|
524 | + } elseif (isset($this->args["{$column}__in"])) { |
|
525 | + $this->prepare_column__in($column, $data); |
|
526 | + } elseif (isset($this->args["{$column}__not_in"])) { |
|
527 | + $this->prepare_column__in($column, $data, 'NOT IN'); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | * @param string $column The name of the column |
537 | 537 | * @param array $data The column data. |
538 | 538 | */ |
539 | - protected function prepare_column( $column, $data ) { |
|
539 | + protected function prepare_column($column, $data) { |
|
540 | 540 | |
541 | 541 | global $wpdb; |
542 | 542 | |
543 | 543 | if ( |
544 | - isset( $data['values'] ) |
|
545 | - && ! in_array( $this->args[ $column ], $data['values'], true ) |
|
544 | + isset($data['values']) |
|
545 | + && ! in_array($this->args[$column], $data['values'], true) |
|
546 | 546 | ) { |
547 | 547 | return; |
548 | 548 | } |
549 | 549 | |
550 | 550 | $value = $this->validate_value( |
551 | - $this->args[ $column ] |
|
552 | - , $this->get_validators_for_column( $data ) |
|
551 | + $this->args[$column] |
|
552 | + , $this->get_validators_for_column($data) |
|
553 | 553 | ); |
554 | 554 | |
555 | - if ( false === $value ) { |
|
555 | + if (false === $value) { |
|
556 | 556 | return; |
557 | 557 | } |
558 | 558 | |
559 | - $compare = $this->get_comparator_for_column( $column, $data ); |
|
559 | + $compare = $this->get_comparator_for_column($column, $data); |
|
560 | 560 | |
561 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
561 | + $column = wordpoints_escape_mysql_identifier($column); |
|
562 | 562 | |
563 | 563 | $this->wheres[] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
564 | 564 | "{$column} {$compare} {$data['format']}" |
@@ -576,23 +576,23 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string The comparator for the column. |
578 | 578 | */ |
579 | - protected function get_comparator_for_column( $column, $data ) { |
|
579 | + protected function get_comparator_for_column($column, $data) { |
|
580 | 580 | |
581 | - $comparisons = array( '=', '<', '>', '<>', '!=', '<=', '>=' ); |
|
581 | + $comparisons = array('=', '<', '>', '<>', '!=', '<=', '>='); |
|
582 | 582 | |
583 | 583 | // MySQL doesn't support LIKE and NOT LIKE for int columns. |
584 | 584 | // See http://stackoverflow.com/q/8422455/1924128 |
585 | - if ( '%s' === $data['format'] ) { |
|
586 | - $comparisons = array_merge( $comparisons, array( 'LIKE', 'NOT LIKE' ) ); |
|
585 | + if ('%s' === $data['format']) { |
|
586 | + $comparisons = array_merge($comparisons, array('LIKE', 'NOT LIKE')); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $comparator = '='; |
590 | 590 | |
591 | 591 | if ( |
592 | - isset( $this->args[ "{$column}__compare" ] ) |
|
593 | - && in_array( $this->args[ "{$column}__compare" ], $comparisons, true ) |
|
592 | + isset($this->args["{$column}__compare"]) |
|
593 | + && in_array($this->args["{$column}__compare"], $comparisons, true) |
|
594 | 594 | ) { |
595 | - $comparator = $this->args[ "{$column}__compare" ]; |
|
595 | + $comparator = $this->args["{$column}__compare"]; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | return $comparator; |
@@ -607,36 +607,36 @@ discard block |
||
607 | 607 | * @param array $data The column data. |
608 | 608 | * @param string $type The type of IN clause, IN or NOT IN. |
609 | 609 | */ |
610 | - protected function prepare_column__in( $column, $data, $type = 'IN' ) { |
|
610 | + protected function prepare_column__in($column, $data, $type = 'IN') { |
|
611 | 611 | |
612 | - $key = "{$column}__" . strtolower( str_replace( ' ', '_', $type ) ); |
|
612 | + $key = "{$column}__".strtolower(str_replace(' ', '_', $type)); |
|
613 | 613 | |
614 | - if ( empty( $this->args[ $key ] ) || ! is_array( $this->args[ $key ] ) ) { |
|
614 | + if (empty($this->args[$key]) || ! is_array($this->args[$key])) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | - $values = $this->args[ $key ]; |
|
618 | + $values = $this->args[$key]; |
|
619 | 619 | |
620 | - if ( isset( $data['values'] ) ) { |
|
621 | - $values = array_intersect( $values, $data['values'] ); |
|
620 | + if (isset($data['values'])) { |
|
621 | + $values = array_intersect($values, $data['values']); |
|
622 | 622 | } else { |
623 | 623 | $values = $this->validate_values( |
624 | 624 | $values |
625 | - , $this->get_validators_for_column( $data ) |
|
625 | + , $this->get_validators_for_column($data) |
|
626 | 626 | ); |
627 | 627 | } |
628 | 628 | |
629 | - if ( empty( $values ) ) { |
|
629 | + if (empty($values)) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | - $in = wordpoints_prepare__in( $values, $data['format'] ); |
|
633 | + $in = wordpoints_prepare__in($values, $data['format']); |
|
634 | 634 | |
635 | - if ( false === $in ) { |
|
635 | + if (false === $in) { |
|
636 | 636 | return; |
637 | 637 | } |
638 | 638 | |
639 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
639 | + $column = wordpoints_escape_mysql_identifier($column); |
|
640 | 640 | |
641 | 641 | $this->wheres[] = "{$column} {$type} ({$in})"; |
642 | 642 | } |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | |
651 | 651 | $this->wheres = array(); |
652 | 652 | |
653 | - foreach ( $this->columns as $column => $data ) { |
|
653 | + foreach ($this->columns as $column => $data) { |
|
654 | 654 | |
655 | - if ( ! empty( $data['is_date'] ) ) { |
|
656 | - $this->prepare_date_where( $column ); |
|
655 | + if ( ! empty($data['is_date'])) { |
|
656 | + $this->prepare_date_where($column); |
|
657 | 657 | } else { |
658 | - $this->prepare_column_where( $column, $data ); |
|
658 | + $this->prepare_column_where($column, $data); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | 662 | $this->prepare_meta_where(); |
663 | 663 | |
664 | - if ( ! empty( $this->wheres ) ) { |
|
665 | - $this->where = 'WHERE ' . implode( ' AND ', $this->wheres ) . "\n"; |
|
664 | + if ( ! empty($this->wheres)) { |
|
665 | + $this->where = 'WHERE '.implode(' AND ', $this->wheres)."\n"; |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -675,32 +675,32 @@ discard block |
||
675 | 675 | |
676 | 676 | // MySQL doesn't allow for the offset without a limit, so if no limit is set |
677 | 677 | // we can ignore the start arg. See http://stackoverflow.com/a/271650/1924128 |
678 | - if ( ! isset( $this->args['limit'] ) ) { |
|
678 | + if ( ! isset($this->args['limit'])) { |
|
679 | 679 | return; |
680 | 680 | } |
681 | 681 | |
682 | - foreach ( array( 'limit', 'start' ) as $key ) { |
|
682 | + foreach (array('limit', 'start') as $key) { |
|
683 | 683 | |
684 | 684 | // Save a backup of the arg value since wordpoints_int() is by reference. |
685 | - $arg = $this->args[ $key ]; |
|
685 | + $arg = $this->args[$key]; |
|
686 | 686 | |
687 | - if ( false === wordpoints_int( $this->args[ $key ] ) ) { |
|
687 | + if (false === wordpoints_int($this->args[$key])) { |
|
688 | 688 | |
689 | 689 | _doing_it_wrong( |
690 | 690 | __METHOD__ |
691 | 691 | , sprintf( |
692 | 692 | "WordPoints Debug Error: '%s' must be a positive integer, %s given" |
693 | - , esc_html( $key ) |
|
694 | - , esc_html( strval( $arg ) ? $arg : gettype( $arg ) ) |
|
693 | + , esc_html($key) |
|
694 | + , esc_html(strval($arg) ? $arg : gettype($arg)) |
|
695 | 695 | ) |
696 | 696 | , '1.0.0' |
697 | 697 | ); |
698 | 698 | |
699 | - $this->args[ $key ] = 0; |
|
699 | + $this->args[$key] = 0; |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | - if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
|
703 | + if ($this->args['limit'] > 0 && $this->args['start'] >= 0) { |
|
704 | 704 | $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
705 | 705 | } |
706 | 706 | } |
@@ -712,20 +712,20 @@ discard block |
||
712 | 712 | */ |
713 | 713 | protected function prepare_order_by() { |
714 | 714 | |
715 | - if ( empty( $this->args['order_by'] ) ) { |
|
715 | + if (empty($this->args['order_by'])) { |
|
716 | 716 | return; |
717 | 717 | } |
718 | 718 | |
719 | 719 | $order = $this->args['order']; |
720 | 720 | $order_by = $this->args['order_by']; |
721 | 721 | |
722 | - if ( ! in_array( $order, array( 'DESC', 'ASC' ) ) ) { |
|
722 | + if ( ! in_array($order, array('DESC', 'ASC'))) { |
|
723 | 723 | |
724 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC" ), '1.0.0' ); |
|
724 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC"), '1.0.0'); |
|
725 | 725 | $order = 'DESC'; |
726 | 726 | } |
727 | 727 | |
728 | - if ( 'meta_value' === $order_by ) { |
|
728 | + if ('meta_value' === $order_by) { |
|
729 | 729 | |
730 | 730 | global $wpdb; |
731 | 731 | |
@@ -733,9 +733,9 @@ discard block |
||
733 | 733 | $wpdb->{"{$this->meta_type}meta"} |
734 | 734 | ); |
735 | 735 | |
736 | - if ( isset( $this->args['meta_type'] ) ) { |
|
736 | + if (isset($this->args['meta_type'])) { |
|
737 | 737 | |
738 | - $meta_type = $this->meta_query->get_cast_for_type( $this->args['meta_type'] ); |
|
738 | + $meta_type = $this->meta_query->get_cast_for_type($this->args['meta_type']); |
|
739 | 739 | $order_by = "CAST({$meta_table_name}.meta_value AS {$meta_type})"; |
740 | 740 | |
741 | 741 | } else { |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | $order_by = "{$meta_table_name}.meta_value"; |
744 | 744 | } |
745 | 745 | |
746 | - } elseif ( isset( $this->columns[ $order_by ] ) ) { |
|
746 | + } elseif (isset($this->columns[$order_by])) { |
|
747 | 747 | |
748 | - $order_by = wordpoints_escape_mysql_identifier( $order_by ); |
|
748 | + $order_by = wordpoints_escape_mysql_identifier($order_by); |
|
749 | 749 | |
750 | 750 | } else { |
751 | 751 | |
752 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order_by' \"{$order_by}\", possible values are " . implode( ', ', array_keys( $this->columns ) ) ), '1.0.0' ); |
|
752 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order_by' \"{$order_by}\", possible values are ".implode(', ', array_keys($this->columns))), '1.0.0'); |
|
753 | 753 | return; |
754 | 754 | } |
755 | 755 | |
@@ -763,25 +763,25 @@ discard block |
||
763 | 763 | * |
764 | 764 | * @param string $column The name of the column. |
765 | 765 | */ |
766 | - protected function prepare_date_where( $column ) { |
|
766 | + protected function prepare_date_where($column) { |
|
767 | 767 | |
768 | 768 | if ( |
769 | - empty( $this->args[ "{$column}_query" ] ) |
|
770 | - || ! is_array( $this->args[ "{$column}_query" ] ) |
|
769 | + empty($this->args["{$column}_query"]) |
|
770 | + || ! is_array($this->args["{$column}_query"]) |
|
771 | 771 | ) { |
772 | 772 | return; |
773 | 773 | } |
774 | 774 | |
775 | - add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
775 | + add_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
776 | 776 | |
777 | - $date_query = new WP_Date_Query( $this->args[ "{$column}_query" ], $column ); |
|
777 | + $date_query = new WP_Date_Query($this->args["{$column}_query"], $column); |
|
778 | 778 | $date_query = $date_query->get_sql(); |
779 | 779 | |
780 | - if ( ! empty( $date_query ) ) { |
|
781 | - $this->wheres[] = ltrim( $date_query, ' AND' ); |
|
780 | + if ( ! empty($date_query)) { |
|
781 | + $this->wheres[] = ltrim($date_query, ' AND'); |
|
782 | 782 | } |
783 | 783 | |
784 | - remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
784 | + remove_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | protected function prepare_meta_where() { |
793 | 793 | |
794 | - if ( empty( $this->meta_type ) ) { |
|
794 | + if (empty($this->meta_type)) { |
|
795 | 795 | return; |
796 | 796 | } |
797 | 797 | |
@@ -806,12 +806,12 @@ discard block |
||
806 | 806 | ) |
807 | 807 | ); |
808 | 808 | |
809 | - if ( empty( $meta_args ) ) { |
|
809 | + if (empty($meta_args)) { |
|
810 | 810 | return; |
811 | 811 | } |
812 | 812 | |
813 | 813 | $this->meta_query = new WP_Meta_Query(); |
814 | - $this->meta_query->parse_query_vars( $meta_args ); |
|
814 | + $this->meta_query->parse_query_vars($meta_args); |
|
815 | 815 | |
816 | 816 | $meta_query = $this->meta_query->get_sql( |
817 | 817 | $this->meta_type |
@@ -820,11 +820,11 @@ discard block |
||
820 | 820 | , $this |
821 | 821 | ); |
822 | 822 | |
823 | - if ( ! empty( $meta_query['where'] ) ) { |
|
824 | - $this->wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
823 | + if ( ! empty($meta_query['where'])) { |
|
824 | + $this->wheres[] = ltrim($meta_query['where'], ' AND'); |
|
825 | 825 | } |
826 | 826 | |
827 | - $this->meta_join = $meta_query['join'] . "\n"; |
|
827 | + $this->meta_join = $meta_query['join']."\n"; |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 |
@@ -144,7 +144,7 @@ |
||
144 | 144 | * |
145 | 145 | * @since 1.0.0 |
146 | 146 | * |
147 | - * @return WordPoints_Hook_Reaction_Validator|null The validator or null if none. |
|
147 | + * @return WordPoints_Hook_Reaction_Validator The validator or null if none. |
|
148 | 148 | */ |
149 | 149 | public function get_validator() { |
150 | 150 | return $this->validator; |
@@ -63,22 +63,22 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param WordPoints_Hook_Arg[] $args The hook args. |
65 | 65 | */ |
66 | - public function __construct( array $args ) { |
|
66 | + public function __construct(array $args) { |
|
67 | 67 | |
68 | 68 | parent::__construct(); |
69 | 69 | |
70 | - foreach ( $args as $arg ) { |
|
70 | + foreach ($args as $arg) { |
|
71 | 71 | |
72 | 72 | $entity = $arg->get_entity(); |
73 | 73 | $slug = $arg->get_slug(); |
74 | 74 | |
75 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
75 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | - $this->entities[ $slug ] = $entity; |
|
79 | + $this->entities[$slug] = $entity; |
|
80 | 80 | |
81 | - if ( ! $arg->is_stateful() ) { |
|
81 | + if ( ! $arg->is_stateful()) { |
|
82 | 82 | // If any of the args aren't stateful the event isn't repeatable. |
83 | 83 | $this->is_repeatable = false; |
84 | 84 | $this->primary_arg_slug = $slug; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function get_primary_arg() { |
116 | 116 | |
117 | - if ( ! $this->primary_arg_slug ) { |
|
117 | + if ( ! $this->primary_arg_slug) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - return $this->entities[ $this->primary_arg_slug ]; |
|
121 | + return $this->entities[$this->primary_arg_slug]; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | |
133 | 133 | $stateful = $this->entities; |
134 | 134 | |
135 | - if ( $this->primary_arg_slug ) { |
|
136 | - unset( $stateful[ $this->primary_arg_slug ] ); |
|
135 | + if ($this->primary_arg_slug) { |
|
136 | + unset($stateful[$this->primary_arg_slug]); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $stateful; |
@@ -157,50 +157,50 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param WordPoints_Hook_Reaction_Validator $validator The validator. |
159 | 159 | */ |
160 | - public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) { |
|
160 | + public function set_validator(WordPoints_Hook_Reaction_Validator $validator) { |
|
161 | 161 | $this->validator = $validator; |
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @since 1.0.0 |
166 | 166 | */ |
167 | - public function descend( $child_slug ) { |
|
167 | + public function descend($child_slug) { |
|
168 | 168 | |
169 | - $result = parent::descend( $child_slug ); |
|
169 | + $result = parent::descend($child_slug); |
|
170 | 170 | |
171 | 171 | // Just in case no validator has been set. |
172 | - if ( ! $this->validator ) { |
|
172 | + if ( ! $this->validator) { |
|
173 | 173 | return $result; |
174 | 174 | } |
175 | 175 | |
176 | - if ( ! $result ) { |
|
176 | + if ( ! $result) { |
|
177 | 177 | |
178 | - if ( ! isset( $this->current ) ) { |
|
178 | + if ( ! isset($this->current)) { |
|
179 | 179 | |
180 | 180 | $this->validator->add_error( |
181 | 181 | sprintf( |
182 | - __( 'The “%s” arg is not registered for this event.', 'wordpoints' ) |
|
182 | + __('The “%s” arg is not registered for this event.', 'wordpoints') |
|
183 | 183 | , $child_slug |
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - } elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) { |
|
187 | + } elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) { |
|
188 | 188 | |
189 | 189 | $this->validator->add_error( |
190 | 190 | sprintf( |
191 | - __( 'Cannot get descendant of %s: not a parent.', 'wordpoints' ) |
|
191 | + __('Cannot get descendant of %s: not a parent.', 'wordpoints') |
|
192 | 192 | , $this->current->get_title() |
193 | 193 | ) |
194 | 194 | ); |
195 | 195 | |
196 | 196 | } else { |
197 | 197 | |
198 | - $child_arg = $this->current->get_child( $child_slug ); |
|
198 | + $child_arg = $this->current->get_child($child_slug); |
|
199 | 199 | |
200 | - if ( ! $child_arg ) { |
|
200 | + if ( ! $child_arg) { |
|
201 | 201 | $this->validator->add_error( |
202 | 202 | sprintf( |
203 | - __( '%s does not have a child “%s”.', 'wordpoints' ) |
|
203 | + __('%s does not have a child “%s”.', 'wordpoints') |
|
204 | 204 | , $this->current->get_slug() |
205 | 205 | , $child_slug |
206 | 206 | ) |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - } elseif ( $this->push_on_descend ) { |
|
212 | + } elseif ($this->push_on_descend) { |
|
213 | 213 | |
214 | - $this->validator->push_field( $child_slug ); |
|
214 | + $this->validator->push_field($child_slug); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return $result; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | $ascended = parent::ascend(); |
226 | 226 | |
227 | - if ( $ascended && $this->validator ) { |
|
227 | + if ($ascended && $this->validator) { |
|
228 | 228 | $this->validator->pop_field(); |
229 | 229 | } |
230 | 230 | |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * @since 1.0.0 |
236 | 236 | */ |
237 | - public function get_from_hierarchy( array $hierarchy ) { |
|
237 | + public function get_from_hierarchy(array $hierarchy) { |
|
238 | 238 | |
239 | 239 | $this->push_on_descend = false; |
240 | - $entityish = parent::get_from_hierarchy( $hierarchy ); |
|
240 | + $entityish = parent::get_from_hierarchy($hierarchy); |
|
241 | 241 | $this->push_on_descend = true; |
242 | 242 | |
243 | 243 | return $entityish; |
@@ -24,15 +24,15 @@ |
||
24 | 24 | /** |
25 | 25 | * @since 1.0.0 |
26 | 26 | */ |
27 | - public function validate_action_type_settings( $settings ) { |
|
27 | + public function validate_action_type_settings($settings) { |
|
28 | 28 | return (bool) $settings; |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @since 1.0.0 |
33 | 33 | */ |
34 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
35 | - return ! $this->get_settings_from_fire( $fire ); |
|
34 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
35 | + return ! $this->get_settings_from_fire($fire); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | 20 | protected $columns = array( |
21 | - 'id' => array( 'format' => '%d', 'unsigned' => true ), |
|
22 | - 'action_type' => array( 'format' => '%s' ), |
|
23 | - 'primary_arg_guid' => array( 'format' => '%s' ), |
|
24 | - 'event' => array( 'format' => '%s' ), |
|
25 | - 'reactor' => array( 'format' => '%s' ), |
|
26 | - 'reaction_store' => array( 'format' => '%s' ), |
|
27 | - 'reaction_context_id' => array( 'format' => '%s' ), |
|
28 | - 'reaction_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
29 | - 'date' => array( 'format' => '%s', 'is_date' => true ), |
|
21 | + 'id' => array('format' => '%d', 'unsigned' => true), |
|
22 | + 'action_type' => array('format' => '%s'), |
|
23 | + 'primary_arg_guid' => array('format' => '%s'), |
|
24 | + 'event' => array('format' => '%s'), |
|
25 | + 'reactor' => array('format' => '%s'), |
|
26 | + 'reaction_store' => array('format' => '%s'), |
|
27 | + 'reaction_context_id' => array('format' => '%s'), |
|
28 | + 'reaction_id' => array('format' => '%d', 'unsigned' => true), |
|
29 | + 'date' => array('format' => '%s', 'is_date' => true), |
|
30 | 30 | ); |
31 | 31 | |
32 | 32 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @type array $meta_query See WP_Meta_Query. |
103 | 103 | * } |
104 | 104 | */ |
105 | - public function __construct( $args = array() ) { |
|
105 | + public function __construct($args = array()) { |
|
106 | 106 | |
107 | 107 | global $wpdb; |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $this->defaults['order_by'] = 'date'; |
112 | 112 | |
113 | - parent::__construct( $args ); |
|
113 | + parent::__construct($args); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 |
@@ -7,25 +7,25 @@ |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_init_app-apps', 'wordpoints_apps_init' ); |
|
11 | -add_action( 'wordpoints_init_app-entities', 'wordpoints_entities_app_init' ); |
|
10 | +add_action('wordpoints_init_app-apps', 'wordpoints_apps_init'); |
|
11 | +add_action('wordpoints_init_app-entities', 'wordpoints_entities_app_init'); |
|
12 | 12 | |
13 | -add_action( 'wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init' ); |
|
14 | -add_action( 'wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init' ); |
|
13 | +add_action('wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init'); |
|
14 | +add_action('wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init'); |
|
15 | 15 | |
16 | -add_action( 'wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init' ); |
|
16 | +add_action('wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init'); |
|
17 | 17 | |
18 | -add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' ); |
|
19 | -add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' ); |
|
20 | -add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' ); |
|
21 | -add_action( 'wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init' ); |
|
22 | -add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' ); |
|
23 | -add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' ); |
|
18 | +add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init'); |
|
19 | +add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init'); |
|
20 | +add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init'); |
|
21 | +add_action('wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init'); |
|
22 | +add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init'); |
|
23 | +add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init'); |
|
24 | 24 | |
25 | -add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' ); |
|
25 | +add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks'); |
|
26 | 26 | |
27 | -add_action( 'init', 'wordpoints_hooks_api_add_global_cache_groups', 5 ); |
|
27 | +add_action('init', 'wordpoints_hooks_api_add_global_cache_groups', 5); |
|
28 | 28 | |
29 | -add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' ); |
|
29 | +add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log'); |
|
30 | 30 | |
31 | 31 | // EOF |