Completed
Push — master ( b43b5b...dcfda7 )
by J.D.
02:58
created
src/includes/classes/db/query.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
269 269
 
270 270
 		global $wpdb;
271 271
 
272
-		$count = (int) $wpdb->get_var( $this->get_sql( 'SELECT COUNT' ) );
272
+		$count = (int) $wpdb->get_var($this->get_sql('SELECT COUNT'));
273 273
 
274 274
 		return $count;
275 275
 	}
@@ -284,20 +284,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
564 564
 			"{$column} {$compare} {$data['format']}"
@@ -576,21 +576,21 @@  discard block
 block discarded – undo
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 595
 			$comparator = $this->args["{$column}__compare"];
596 596
 		}
@@ -607,36 +607,36 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/includes/classes/hook/fire.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
src/includes/classes/hook/firer/reverse.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -17,55 +17,55 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @since 1.0.0
19 19
 	 */
20
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
20
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) {
21 21
 
22 22
 		$hooks = wordpoints_hooks();
23 23
 
24
-		$hits = $this->get_hits( $event_slug, $event_args );
24
+		$hits = $this->get_hits($event_slug, $event_args);
25 25
 		$reverse_hit_ids = array();
26 26
 
27
-		foreach ( $hits as $hit ) {
27
+		foreach ($hits as $hit) {
28 28
 
29 29
 			/** @var WordPoints_Hook_Reactor $reactor */
30
-			$reactor = $hooks->reactors->get( $hit->reactor );
30
+			$reactor = $hooks->reactors->get($hit->reactor);
31 31
 
32
-			if ( ! $reactor instanceof WordPoints_Hook_Reactor_ReverseI ) {
32
+			if ( ! $reactor instanceof WordPoints_Hook_Reactor_ReverseI) {
33 33
 				continue;
34 34
 			}
35 35
 
36
-			$reactions = $reactor->get_reaction_store( $hit->reaction_store );
36
+			$reactions = $reactor->get_reaction_store($hit->reaction_store);
37 37
 
38 38
 			if (
39 39
 				! $reactions
40
-				|| wp_json_encode( $reactions->get_context_id() ) !== $hit->reaction_context_id
40
+				|| wp_json_encode($reactions->get_context_id()) !== $hit->reaction_context_id
41 41
 			) {
42 42
 				continue;
43 43
 			}
44 44
 
45
-			$reaction = $reactions->get_reaction( $hit->reaction_id );
45
+			$reaction = $reactions->get_reaction($hit->reaction_id);
46 46
 
47
-			if ( ! $reaction ) {
47
+			if ( ! $reaction) {
48 48
 				continue;
49 49
 			}
50 50
 
51
-			$fire = new WordPoints_Hook_Fire( $this, $event_args, $reaction, $hit );
51
+			$fire = new WordPoints_Hook_Fire($this, $event_args, $reaction, $hit);
52 52
 
53
-			$reverse_hit_ids[ $hit->id ] = $fire->hit();
53
+			$reverse_hit_ids[$hit->id] = $fire->hit();
54 54
 
55
-			$reactor->reverse_hit( $fire );
55
+			$reactor->reverse_hit($fire);
56 56
 
57 57
 			/** @var WordPoints_Hook_Extension $extension */
58
-			foreach ( $hooks->extensions->get_all() as $extension ) {
59
-				$extension->after_reverse( $fire );
58
+			foreach ($hooks->extensions->get_all() as $extension) {
59
+				$extension->after_reverse($fire);
60 60
 			}
61 61
 		}
62 62
 
63 63
 		// Set the reversed_by meta key for all hits so that we know that they have
64 64
 		// been reverse fired, even if they didn't hit.
65
-		foreach ( $hits as $hit ) {
65
+		foreach ($hits as $hit) {
66 66
 
67
-			if ( isset( $reverse_hit_ids[ $hit->id ] ) ) {
68
-				$reversed_by = $reverse_hit_ids[ $hit->id ];
67
+			if (isset($reverse_hit_ids[$hit->id])) {
68
+				$reversed_by = $reverse_hit_ids[$hit->id];
69 69
 			} else {
70 70
 				$reversed_by = 0;
71 71
 			}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return object[] The data for each hit from the hit logs database table.
92 92
 	 */
93
-	protected function get_hits( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
93
+	protected function get_hits($event_slug, WordPoints_Hook_Event_Args $event_args) {
94 94
 
95 95
 		$query = new WordPoints_Hook_Hit_Query(
96 96
 			array(
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 		$hits = $query->get();
108 108
 
109
-		if ( ! is_array( $hits ) ) {
109
+		if ( ! is_array($hits)) {
110 110
 			return array();
111 111
 		}
112 112
 
Please login to merge, or discard this patch.
src/includes/classes/hook/hit/logger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/includes/classes/hook/hit/query.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	protected $columns = array(
21
-		'id' => array( 'format' => '%d', 'unsigned' => true ),
22
-		'firer' => 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
+		'firer' => 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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/includes/classes/index.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -10,111 +10,111 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // auto-generated {
13
-require_once( dirname( __FILE__ ) . 'app.php' );
14
-require_once( dirname( __FILE__ ) . 'app/registry.php' );
15
-require_once( dirname( __FILE__ ) . 'class/autoloader.php' );
16
-require_once( dirname( __FILE__ ) . 'class/registry.php' );
17
-require_once( dirname( __FILE__ ) . 'class/registry/children.php' );
18
-require_once( dirname( __FILE__ ) . 'class/registry/childreni.php' );
19
-require_once( dirname( __FILE__ ) . 'class/registry/persistent.php' );
20
-require_once( dirname( __FILE__ ) . 'class/registryi.php' );
21
-require_once( dirname( __FILE__ ) . 'data/type.php' );
22
-require_once( dirname( __FILE__ ) . 'data/type/integer.php' );
23
-require_once( dirname( __FILE__ ) . 'data/type/text.php' );
24
-require_once( dirname( __FILE__ ) . 'data/typei.php' );
25
-require_once( dirname( __FILE__ ) . 'db/query.php' );
26
-require_once( dirname( __FILE__ ) . 'entity.php' );
27
-require_once( dirname( __FILE__ ) . 'entity/array.php' );
28
-require_once( dirname( __FILE__ ) . 'entity/attr.php' );
29
-require_once( dirname( __FILE__ ) . 'entity/childi.php' );
30
-require_once( dirname( __FILE__ ) . 'entity/comment.php' );
31
-require_once( dirname( __FILE__ ) . 'entity/comment/author.php' );
32
-require_once( dirname( __FILE__ ) . 'entity/comment/post.php' );
33
-require_once( dirname( __FILE__ ) . 'entity/context.php' );
34
-require_once( dirname( __FILE__ ) . 'entity/context/network.php' );
35
-require_once( dirname( __FILE__ ) . 'entity/context/site.php' );
36
-require_once( dirname( __FILE__ ) . 'entity/enumerablei.php' );
37
-require_once( dirname( __FILE__ ) . 'entity/hierarchy.php' );
38
-require_once( dirname( __FILE__ ) . 'entity/hierarchyi.php' );
39
-require_once( dirname( __FILE__ ) . 'entity/parenti.php' );
40
-require_once( dirname( __FILE__ ) . 'entity/post.php' );
41
-require_once( dirname( __FILE__ ) . 'entity/post/author.php' );
42
-require_once( dirname( __FILE__ ) . 'entity/post/content.php' );
43
-require_once( dirname( __FILE__ ) . 'entity/post/terms.php' );
44
-require_once( dirname( __FILE__ ) . 'entity/post/type.php' );
45
-require_once( dirname( __FILE__ ) . 'entity/post/type/name.php' );
46
-require_once( dirname( __FILE__ ) . 'entity/post/type/relationship.php' );
47
-require_once( dirname( __FILE__ ) . 'entity/relationship.php' );
48
-require_once( dirname( __FILE__ ) . 'entity/relationship/dynamic.php' );
49
-require_once( dirname( __FILE__ ) . 'entity/restricted/visibilityi.php' );
50
-require_once( dirname( __FILE__ ) . 'entity/site.php' );
51
-require_once( dirname( __FILE__ ) . 'entity/term.php' );
52
-require_once( dirname( __FILE__ ) . 'entity/term/id.php' );
53
-require_once( dirname( __FILE__ ) . 'entity/user.php' );
54
-require_once( dirname( __FILE__ ) . 'entity/user/role.php' );
55
-require_once( dirname( __FILE__ ) . 'entity/user/role/name.php' );
56
-require_once( dirname( __FILE__ ) . 'entity/user/roles.php' );
57
-require_once( dirname( __FILE__ ) . 'entityish.php' );
58
-require_once( dirname( __FILE__ ) . 'entityishi.php' );
59
-require_once( dirname( __FILE__ ) . 'hierarchy.php' );
60
-require_once( dirname( __FILE__ ) . 'hook/action.php' );
61
-require_once( dirname( __FILE__ ) . 'hook/action/comment/new.php' );
62
-require_once( dirname( __FILE__ ) . 'hook/action/post/publish.php' );
63
-require_once( dirname( __FILE__ ) . 'hook/actioni.php' );
64
-require_once( dirname( __FILE__ ) . 'hook/actions.php' );
65
-require_once( dirname( __FILE__ ) . 'hook/arg.php' );
66
-require_once( dirname( __FILE__ ) . 'hook/arg/current/post.php' );
67
-require_once( dirname( __FILE__ ) . 'hook/arg/current/site.php' );
68
-require_once( dirname( __FILE__ ) . 'hook/arg/current/user.php' );
69
-require_once( dirname( __FILE__ ) . 'hook/arg/dynamic.php' );
70
-require_once( dirname( __FILE__ ) . 'hook/condition.php' );
71
-require_once( dirname( __FILE__ ) . 'hook/condition/entity/array/contains.php' );
72
-require_once( dirname( __FILE__ ) . 'hook/condition/equals.php' );
73
-require_once( dirname( __FILE__ ) . 'hook/condition/string/contains.php' );
74
-require_once( dirname( __FILE__ ) . 'hook/conditioni.php' );
75
-require_once( dirname( __FILE__ ) . 'hook/event.php' );
76
-require_once( dirname( __FILE__ ) . 'hook/event/args.php' );
77
-require_once( dirname( __FILE__ ) . 'hook/event/comment/leave.php' );
78
-require_once( dirname( __FILE__ ) . 'hook/event/dynamic.php' );
79
-require_once( dirname( __FILE__ ) . 'hook/event/media/upload.php' );
80
-require_once( dirname( __FILE__ ) . 'hook/event/post/publish.php' );
81
-require_once( dirname( __FILE__ ) . 'hook/event/user/register.php' );
82
-require_once( dirname( __FILE__ ) . 'hook/event/user/visit.php' );
83
-require_once( dirname( __FILE__ ) . 'hook/eventi.php' );
84
-require_once( dirname( __FILE__ ) . 'hook/events.php' );
85
-require_once( dirname( __FILE__ ) . 'hook/extension.php' );
86
-require_once( dirname( __FILE__ ) . 'hook/extension/conditions.php' );
87
-require_once( dirname( __FILE__ ) . 'hook/extension/periods.php' );
88
-require_once( dirname( __FILE__ ) . 'hook/fire.php' );
89
-require_once( dirname( __FILE__ ) . 'hook/firer.php' );
90
-require_once( dirname( __FILE__ ) . 'hook/firer/reverse.php' );
91
-require_once( dirname( __FILE__ ) . 'hook/fireri.php' );
92
-require_once( dirname( __FILE__ ) . 'hook/hit/logger.php' );
93
-require_once( dirname( __FILE__ ) . 'hook/hit/query.php' );
94
-require_once( dirname( __FILE__ ) . 'hook/reaction.php' );
95
-require_once( dirname( __FILE__ ) . 'hook/reaction/options.php' );
96
-require_once( dirname( __FILE__ ) . 'hook/reaction/store.php' );
97
-require_once( dirname( __FILE__ ) . 'hook/reaction/store/options.php' );
98
-require_once( dirname( __FILE__ ) . 'hook/reaction/store/options/network.php' );
99
-require_once( dirname( __FILE__ ) . 'hook/reaction/storei.php' );
100
-require_once( dirname( __FILE__ ) . 'hook/reaction/validator.php' );
101
-require_once( dirname( __FILE__ ) . 'hook/reactioni.php' );
102
-require_once( dirname( __FILE__ ) . 'hook/reactor.php' );
103
-require_once( dirname( __FILE__ ) . 'hook/reactor/points.php' );
104
-require_once( dirname( __FILE__ ) . 'hook/reactor/reversei.php' );
105
-require_once( dirname( __FILE__ ) . 'hook/retroactive/conditions.php' );
106
-require_once( dirname( __FILE__ ) . 'hook/retroactive/query.php' );
107
-require_once( dirname( __FILE__ ) . 'hook/retroactive/query/modifieri.php' );
108
-require_once( dirname( __FILE__ ) . 'hook/retroactive/queryable.php' );
109
-require_once( dirname( __FILE__ ) . 'hook/retroactive/queryi.php' );
110
-require_once( dirname( __FILE__ ) . 'hook/router.php' );
111
-require_once( dirname( __FILE__ ) . 'hook/settings.php' );
112
-require_once( dirname( __FILE__ ) . 'hook/settingsi.php' );
113
-require_once( dirname( __FILE__ ) . 'hook/validator/exception.php' );
114
-require_once( dirname( __FILE__ ) . 'hooks.php' );
115
-require_once( dirname( __FILE__ ) . 'query/builder/db/mysql.php' );
116
-require_once( dirname( __FILE__ ) . 'spec.php' );
117
-require_once( dirname( __FILE__ ) . 'specedi.php' );
13
+require_once(dirname(__FILE__).'app.php');
14
+require_once(dirname(__FILE__).'app/registry.php');
15
+require_once(dirname(__FILE__).'class/autoloader.php');
16
+require_once(dirname(__FILE__).'class/registry.php');
17
+require_once(dirname(__FILE__).'class/registry/children.php');
18
+require_once(dirname(__FILE__).'class/registry/childreni.php');
19
+require_once(dirname(__FILE__).'class/registry/persistent.php');
20
+require_once(dirname(__FILE__).'class/registryi.php');
21
+require_once(dirname(__FILE__).'data/type.php');
22
+require_once(dirname(__FILE__).'data/type/integer.php');
23
+require_once(dirname(__FILE__).'data/type/text.php');
24
+require_once(dirname(__FILE__).'data/typei.php');
25
+require_once(dirname(__FILE__).'db/query.php');
26
+require_once(dirname(__FILE__).'entity.php');
27
+require_once(dirname(__FILE__).'entity/array.php');
28
+require_once(dirname(__FILE__).'entity/attr.php');
29
+require_once(dirname(__FILE__).'entity/childi.php');
30
+require_once(dirname(__FILE__).'entity/comment.php');
31
+require_once(dirname(__FILE__).'entity/comment/author.php');
32
+require_once(dirname(__FILE__).'entity/comment/post.php');
33
+require_once(dirname(__FILE__).'entity/context.php');
34
+require_once(dirname(__FILE__).'entity/context/network.php');
35
+require_once(dirname(__FILE__).'entity/context/site.php');
36
+require_once(dirname(__FILE__).'entity/enumerablei.php');
37
+require_once(dirname(__FILE__).'entity/hierarchy.php');
38
+require_once(dirname(__FILE__).'entity/hierarchyi.php');
39
+require_once(dirname(__FILE__).'entity/parenti.php');
40
+require_once(dirname(__FILE__).'entity/post.php');
41
+require_once(dirname(__FILE__).'entity/post/author.php');
42
+require_once(dirname(__FILE__).'entity/post/content.php');
43
+require_once(dirname(__FILE__).'entity/post/terms.php');
44
+require_once(dirname(__FILE__).'entity/post/type.php');
45
+require_once(dirname(__FILE__).'entity/post/type/name.php');
46
+require_once(dirname(__FILE__).'entity/post/type/relationship.php');
47
+require_once(dirname(__FILE__).'entity/relationship.php');
48
+require_once(dirname(__FILE__).'entity/relationship/dynamic.php');
49
+require_once(dirname(__FILE__).'entity/restricted/visibilityi.php');
50
+require_once(dirname(__FILE__).'entity/site.php');
51
+require_once(dirname(__FILE__).'entity/term.php');
52
+require_once(dirname(__FILE__).'entity/term/id.php');
53
+require_once(dirname(__FILE__).'entity/user.php');
54
+require_once(dirname(__FILE__).'entity/user/role.php');
55
+require_once(dirname(__FILE__).'entity/user/role/name.php');
56
+require_once(dirname(__FILE__).'entity/user/roles.php');
57
+require_once(dirname(__FILE__).'entityish.php');
58
+require_once(dirname(__FILE__).'entityishi.php');
59
+require_once(dirname(__FILE__).'hierarchy.php');
60
+require_once(dirname(__FILE__).'hook/action.php');
61
+require_once(dirname(__FILE__).'hook/action/comment/new.php');
62
+require_once(dirname(__FILE__).'hook/action/post/publish.php');
63
+require_once(dirname(__FILE__).'hook/actioni.php');
64
+require_once(dirname(__FILE__).'hook/actions.php');
65
+require_once(dirname(__FILE__).'hook/arg.php');
66
+require_once(dirname(__FILE__).'hook/arg/current/post.php');
67
+require_once(dirname(__FILE__).'hook/arg/current/site.php');
68
+require_once(dirname(__FILE__).'hook/arg/current/user.php');
69
+require_once(dirname(__FILE__).'hook/arg/dynamic.php');
70
+require_once(dirname(__FILE__).'hook/condition.php');
71
+require_once(dirname(__FILE__).'hook/condition/entity/array/contains.php');
72
+require_once(dirname(__FILE__).'hook/condition/equals.php');
73
+require_once(dirname(__FILE__).'hook/condition/string/contains.php');
74
+require_once(dirname(__FILE__).'hook/conditioni.php');
75
+require_once(dirname(__FILE__).'hook/event.php');
76
+require_once(dirname(__FILE__).'hook/event/args.php');
77
+require_once(dirname(__FILE__).'hook/event/comment/leave.php');
78
+require_once(dirname(__FILE__).'hook/event/dynamic.php');
79
+require_once(dirname(__FILE__).'hook/event/media/upload.php');
80
+require_once(dirname(__FILE__).'hook/event/post/publish.php');
81
+require_once(dirname(__FILE__).'hook/event/user/register.php');
82
+require_once(dirname(__FILE__).'hook/event/user/visit.php');
83
+require_once(dirname(__FILE__).'hook/eventi.php');
84
+require_once(dirname(__FILE__).'hook/events.php');
85
+require_once(dirname(__FILE__).'hook/extension.php');
86
+require_once(dirname(__FILE__).'hook/extension/conditions.php');
87
+require_once(dirname(__FILE__).'hook/extension/periods.php');
88
+require_once(dirname(__FILE__).'hook/fire.php');
89
+require_once(dirname(__FILE__).'hook/firer.php');
90
+require_once(dirname(__FILE__).'hook/firer/reverse.php');
91
+require_once(dirname(__FILE__).'hook/fireri.php');
92
+require_once(dirname(__FILE__).'hook/hit/logger.php');
93
+require_once(dirname(__FILE__).'hook/hit/query.php');
94
+require_once(dirname(__FILE__).'hook/reaction.php');
95
+require_once(dirname(__FILE__).'hook/reaction/options.php');
96
+require_once(dirname(__FILE__).'hook/reaction/store.php');
97
+require_once(dirname(__FILE__).'hook/reaction/store/options.php');
98
+require_once(dirname(__FILE__).'hook/reaction/store/options/network.php');
99
+require_once(dirname(__FILE__).'hook/reaction/storei.php');
100
+require_once(dirname(__FILE__).'hook/reaction/validator.php');
101
+require_once(dirname(__FILE__).'hook/reactioni.php');
102
+require_once(dirname(__FILE__).'hook/reactor.php');
103
+require_once(dirname(__FILE__).'hook/reactor/points.php');
104
+require_once(dirname(__FILE__).'hook/reactor/reversei.php');
105
+require_once(dirname(__FILE__).'hook/retroactive/conditions.php');
106
+require_once(dirname(__FILE__).'hook/retroactive/query.php');
107
+require_once(dirname(__FILE__).'hook/retroactive/query/modifieri.php');
108
+require_once(dirname(__FILE__).'hook/retroactive/queryable.php');
109
+require_once(dirname(__FILE__).'hook/retroactive/queryi.php');
110
+require_once(dirname(__FILE__).'hook/router.php');
111
+require_once(dirname(__FILE__).'hook/settings.php');
112
+require_once(dirname(__FILE__).'hook/settingsi.php');
113
+require_once(dirname(__FILE__).'hook/validator/exception.php');
114
+require_once(dirname(__FILE__).'hooks.php');
115
+require_once(dirname(__FILE__).'query/builder/db/mysql.php');
116
+require_once(dirname(__FILE__).'spec.php');
117
+require_once(dirname(__FILE__).'specedi.php');
118 118
 // }
119 119
 
120 120
 // EOF
Please login to merge, or discard this patch.
src/includes/constants.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry.
35 35
  */
36
-function wordpoints_hook_reactors_init( $reactors ) {
36
+function wordpoints_hook_reactors_init($reactors) {
37 37
 
38
-	$reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' );
38
+	$reactors->register('points', 'WordPoints_Hook_Reactor_Points');
39 39
 }
40 40
 
41 41
 /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @param WordPoints_Class_Registry_Children $reaction_stores The store registry.
49 49
  */
50
-function wordpoints_hook_reaction_stores_init( $reaction_stores ) {
50
+function wordpoints_hook_reaction_stores_init($reaction_stores) {
51 51
 
52 52
 	$reaction_stores->register(
53 53
 		'points'
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		, 'WordPoints_Hook_Reaction_Store_Options'
56 56
 	);
57 57
 
58
-	if ( is_wordpoints_network_active() ) {
58
+	if (is_wordpoints_network_active()) {
59 59
 		$reaction_stores->register(
60 60
 			'points'
61 61
 			, 'network'
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
75 75
  */
76
-function wordpoints_hook_extension_init( $extensions ) {
76
+function wordpoints_hook_extension_init($extensions) {
77 77
 
78
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
79
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
78
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
79
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
80 80
 }
81 81
 
82 82
 /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  *
89 89
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
90 90
  */
91
-function wordpoints_hook_conditions_init( $conditions ) {
91
+function wordpoints_hook_conditions_init($conditions) {
92 92
 
93 93
 	$conditions->register(
94 94
 		'text'
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @param WordPoints_Hook_Actions $actions The action registry.
126 126
  */
127
-function wordpoints_hook_actions_init( $actions ) {
127
+function wordpoints_hook_actions_init($actions) {
128 128
 
129 129
 	$actions->register(
130 130
 		'comment_approve'
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 		, array(
133 133
 			'action' => 'transition_comment_status',
134 134
 			'data'   => array(
135
-				'arg_index'    => array( 'comment' => 2 ),
136
-				'requirements' => array( 0 => 'approved' ),
135
+				'arg_index'    => array('comment' => 2),
136
+				'requirements' => array(0 => 'approved'),
137 137
 			),
138 138
 		)
139 139
 	);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		, array(
145 145
 			'action' => 'wp_insert_comment',
146 146
 			'data'   => array(
147
-				'arg_index' => array( 'comment' => 1 ),
147
+				'arg_index' => array('comment' => 1),
148 148
 			),
149 149
 		)
150 150
 	);
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 		, array(
156 156
 			'action' => 'transition_comment_status',
157 157
 			'data'   => array(
158
-				'arg_index' => array( 'comment' => 2 ),
159
-				'requirements' => array( 1 => 'approved' ),
158
+				'arg_index' => array('comment' => 2),
159
+				'requirements' => array(1 => 'approved'),
160 160
 			),
161 161
 		)
162 162
 	);
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 		, array(
169 169
 			'action' => 'transition_post_status',
170 170
 			'data'   => array(
171
-				'arg_index' => array( 'post' => 2 ),
172
-				'requirements' => array( 0 => 'publish' ),
171
+				'arg_index' => array('post' => 2),
172
+				'requirements' => array(0 => 'publish'),
173 173
 			),
174 174
 		)
175 175
 	);
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 		, array(
181 181
 			'action' => 'transition_post_status',
182 182
 			'data'   => array(
183
-				'arg_index' => array( 'post' => 2 ),
184
-				'requirements' => array( 1 => 'publish' ),
183
+				'arg_index' => array('post' => 2),
184
+				'requirements' => array(1 => 'publish'),
185 185
 			),
186 186
 		)
187 187
 	);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		, array(
193 193
 			'action' => 'add_attachment',
194 194
 			'data'   => array(
195
-				'arg_index' => array( 'post\attachment' => 0 ),
195
+				'arg_index' => array('post\attachment' => 0),
196 196
 			),
197 197
 		)
198 198
 	);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		, array(
204 204
 			'action' => 'delete_post',
205 205
 			'data'   => array(
206
-				'arg_index' => array( 'post' => 0 ),
206
+				'arg_index' => array('post' => 0),
207 207
 			),
208 208
 		)
209 209
 	);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		, array(
215 215
 			'action' => 'user_register',
216 216
 			'data'   => array(
217
-				'arg_index' => array( 'user' => 0 ),
217
+				'arg_index' => array('user' => 0),
218 218
 			),
219 219
 		)
220 220
 	);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		, array(
226 226
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
227 227
 			'data'   => array(
228
-				'arg_index' => array( 'user' => 0 ),
228
+				'arg_index' => array('user' => 0),
229 229
 			),
230 230
 		)
231 231
 	);
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
  *
249 249
  * @param WordPoints_Hook_Events $events The event registry.
250 250
  */
251
-function wordpoints_hook_events_init( $events ) {
251
+function wordpoints_hook_events_init($events) {
252 252
 
253 253
 	$events->register(
254 254
 		'user_register'
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	);
279 279
 
280 280
 	// Register events for all of the public post types.
281
-	$post_types = get_post_types( array( 'public' => true ) );
281
+	$post_types = get_post_types(array('public' => true));
282 282
 
283 283
 	/**
284 284
 	 * Filter which post types to register hook events for.
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @param string[] The post type slugs ("names").
289 289
 	 */
290
-	$post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types );
290
+	$post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types);
291 291
 
292
-	foreach ( $post_types as $slug ) {
293
-		wordpoints_register_post_type_hook_events( $slug );
292
+	foreach ($post_types as $slug) {
293
+		wordpoints_register_post_type_hook_events($slug);
294 294
 	}
295 295
 
296
-	if ( is_multisite() ) {
296
+	if (is_multisite()) {
297 297
 
298 298
 		$event_slugs = array(
299 299
 			'user_visit',
300 300
 			'user_register',
301 301
 		);
302 302
 
303
-		foreach ( $event_slugs as $event_slug ) {
303
+		foreach ($event_slugs as $event_slug) {
304 304
 			// TODO network hooks
305 305
 			$events->args->register(
306 306
 				$event_slug
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
  *
321 321
  * @param WordPoints_Class_Registry_Persistent $firers The firer registry.
322 322
  */
323
-function wordpoints_hook_firers_init( $firers ) {
323
+function wordpoints_hook_firers_init($firers) {
324 324
 
325
-	$firers->register( 'fire', 'WordPoints_Hook_Firer' );
326
-	$firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' );
325
+	$firers->register('fire', 'WordPoints_Hook_Firer');
326
+	$firers->register('reverse', 'WordPoints_Hook_Firer_Reverse');
327 327
 }
328 328
 
329 329
 /**
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @param WordPoints_App_Registry $entities The entities app.
337 337
  */
338
-function wordpoints_entities_app_init( $entities ) {
338
+function wordpoints_entities_app_init($entities) {
339 339
 
340
-	$entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
341
-	$entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' );
340
+	$entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children');
341
+	$entities->sub_apps->register('contexts', 'WordPoints_Class_Registry');
342 342
 }
343 343
 
344 344
 /**
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
  *
351 351
  * @param WordPoints_Class_Registry $contexts The entity context registry.
352 352
  */
353
-function wordpoints_entity_contexts_init( $contexts ) {
353
+function wordpoints_entity_contexts_init($contexts) {
354 354
 
355
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
356
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
355
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
356
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
357 357
 }
358 358
 
359 359
 /**
@@ -365,18 +365,18 @@  discard block
 block discarded – undo
365 365
  *
366 366
  * @param WordPoints_App_Registry $entities The entities app.
367 367
  */
368
-function wordpoints_entities_init( $entities ) {
368
+function wordpoints_entities_init($entities) {
369 369
 
370 370
 	$children = $entities->children;
371 371
 
372
-	$entities->register( 'user', 'WordPoints_Entity_User' );
373
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
372
+	$entities->register('user', 'WordPoints_Entity_User');
373
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
374 374
 
375
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
376
-	$children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' );
375
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
376
+	$children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name');
377 377
 
378 378
 	// Register entities for all of the public post types.
379
-	$post_types = get_post_types( array( 'public' => true ) );
379
+	$post_types = get_post_types(array('public' => true));
380 380
 
381 381
 	/**
382 382
 	 * Filter which post types to register entities for.
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @param string[] The post type slugs ("names").
387 387
 	 */
388
-	$post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
388
+	$post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types);
389 389
 
390
-	foreach ( $post_types as $slug ) {
391
-		wordpoints_register_post_type_entities( $slug );
390
+	foreach ($post_types as $slug) {
391
+		wordpoints_register_post_type_entities($slug);
392 392
 	}
393 393
 
394 394
 	// Register entities for all of the public taxonomies.
395
-	$taxonomies = get_taxonomies( array( 'public' => true ) );
395
+	$taxonomies = get_taxonomies(array('public' => true));
396 396
 
397 397
 	/**
398 398
 	 * Filter which taxonomies to register entities for.
@@ -401,10 +401,10 @@  discard block
 block discarded – undo
401 401
 	 *
402 402
 	 * @param string[] The taxonomy slugs.
403 403
 	 */
404
-	$taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies );
404
+	$taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies);
405 405
 
406
-	foreach ( $taxonomies as $slug ) {
407
-		wordpoints_register_taxonomy_entities( $slug );
406
+	foreach ($taxonomies as $slug) {
407
+		wordpoints_register_taxonomy_entities($slug);
408 408
 	}
409 409
 }
410 410
 
@@ -415,28 +415,28 @@  discard block
 block discarded – undo
415 415
  *
416 416
  * @param string $slug The slug of the post type.
417 417
  */
418
-function wordpoints_register_post_type_entities( $slug ) {
418
+function wordpoints_register_post_type_entities($slug) {
419 419
 
420 420
 	$entities = wordpoints_entities();
421 421
 	$children = $entities->children;
422 422
 
423
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
424
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
423
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
424
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
425 425
 
426
-	$supports = get_all_post_type_supports( $slug );
426
+	$supports = get_all_post_type_supports($slug);
427 427
 
428
-	if ( isset( $supports['editor'] ) ) {
429
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
428
+	if (isset($supports['editor'])) {
429
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
430 430
 	}
431 431
 
432
-	if ( isset( $supports['comments'] ) ) {
433
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
434
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
435
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
432
+	if (isset($supports['comments'])) {
433
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
434
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
435
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
436 436
 	}
437 437
 
438
-	foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) {
439
-		$children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' );
438
+	foreach (get_object_taxonomies($slug) as $taxonomy_slug) {
439
+		$children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms');
440 440
 	}
441 441
 
442 442
 	/**
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	 *
447 447
 	 * @param string $slug The slug ("name") of the post type.
448 448
 	 */
449
-	do_action( 'wordpoints_register_post_type_entities', $slug );
449
+	do_action('wordpoints_register_post_type_entities', $slug);
450 450
 }
451 451
 
452 452
 /**
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @param string $slug The slug of the post type.
458 458
  */
459
-function wordpoints_register_post_type_hook_events( $slug ) {
459
+function wordpoints_register_post_type_hook_events($slug) {
460 460
 
461 461
 	$event_slugs = array();
462 462
 
463 463
 	$events = wordpoints_hooks()->events;
464 464
 
465
-	if ( 'attachment' === $slug ) {
465
+	if ('attachment' === $slug) {
466 466
 
467 467
 		$event_slugs[] = 'media_upload';
468 468
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 			, array(
491 491
 				'actions' => array(
492 492
 					'fire'    => 'post_publish',
493
-					'reverse' => array( 'post_depublish', 'post_delete' ),
493
+					'reverse' => array('post_depublish', 'post_delete'),
494 494
 				),
495 495
 				'args'    => array(
496 496
 					"post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic',
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 		);
500 500
 	}
501 501
 
502
-	if ( post_type_supports( $slug, 'comments' ) ) {
502
+	if (post_type_supports($slug, 'comments')) {
503 503
 
504 504
 		$event_slugs[] = "comment_leave\\{$slug}";
505 505
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			, 'WordPoints_Hook_Event_Comment_Leave'
509 509
 			, array(
510 510
 				'actions' => array(
511
-					'fire' => array( 'comment_approve', 'comment_new' ),
511
+					'fire' => array('comment_approve', 'comment_new'),
512 512
 					'reverse' => 'comment_deapprove',
513 513
 				),
514 514
 				'args' => array(
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 		);
519 519
 	}
520 520
 
521
-	if ( is_multisite() ) {
522
-		foreach ( $event_slugs as $event_slug ) {
521
+	if (is_multisite()) {
522
+		foreach ($event_slugs as $event_slug) {
523 523
 			$events->args->register(
524 524
 				$event_slug
525 525
 				, 'current:site'
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	 *
536 536
 	 * @param string $slug The slug ("name") of the post type.
537 537
 	 */
538
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
538
+	do_action('wordpoints_register_post_type_hook_events', $slug);
539 539
 }
540 540
 
541 541
 /**
@@ -545,13 +545,13 @@  discard block
 block discarded – undo
545 545
  *
546 546
  * @param string $slug The slug of the taxonomy.
547 547
  */
548
-function wordpoints_register_taxonomy_entities( $slug ) {
548
+function wordpoints_register_taxonomy_entities($slug) {
549 549
 
550 550
 	$entities = wordpoints_entities();
551 551
 	$children = $entities->children;
552 552
 
553
-	$entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' );
554
-	$children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' );
553
+	$entities->register("term\\{$slug}", 'WordPoints_Entity_Term');
554
+	$children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id');
555 555
 
556 556
 	/**
557 557
 	 * Fired when registering the entities for a taxonomy.
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @param string $slug The taxonomy's slug.
562 562
 	 */
563
-	do_action( 'wordpoints_register_taxonomy_entities', $slug );
563
+	do_action('wordpoints_register_taxonomy_entities', $slug);
564 564
 }
565 565
 
566 566
 /**
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
  *
573 573
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
574 574
  */
575
-function wordpoints_data_types_init( $data_types ) {
575
+function wordpoints_data_types_init($data_types) {
576 576
 
577
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
578
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
577
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
578
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
579 579
 }
580 580
 
581 581
 /**
@@ -590,9 +590,9 @@  discard block
 block discarded – undo
590 590
  *
591 591
  * @return bool Whether the user can view the points log.
592 592
  */
593
-function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) {
593
+function wordpoints_hooks_user_can_view_points_log($can_view, $log) {
594 594
 
595
-	if ( ! $can_view ) {
595
+	if ( ! $can_view) {
596 596
 		return $can_view;
597 597
 	}
598 598
 
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
 	$event_slug = $log->log_type;
602 602
 
603 603
 	/** @var WordPoints_Hook_Arg $arg */
604
-	foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) {
604
+	foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) {
605 605
 
606
-		$value = wordpoints_get_points_log_meta( $log->id, $slug, true );
606
+		$value = wordpoints_get_points_log_meta($log->id, $slug, true);
607 607
 
608
-		if ( ! $value ) {
608
+		if ( ! $value) {
609 609
 			continue;
610 610
 		}
611 611
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			, $value
616 616
 		);
617 617
 
618
-		if ( ! $can_view ) {
618
+		if ( ! $can_view) {
619 619
 			break;
620 620
 		}
621 621
 	}
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
  *
635 635
  * @return bool Whether the user can view this entity.
636 636
  */
637
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
637
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
638 638
 
639
-	$entity = wordpoints_entities()->get( $entity_slug );
639
+	$entity = wordpoints_entities()->get($entity_slug);
640 640
 
641 641
 	// If this entity type is not found, we have no way of determining whether it is
642 642
 	// safe for the user to view it.
643
-	if ( ! ( $entity instanceof WordPoints_Entity ) ) {
643
+	if ( ! ($entity instanceof WordPoints_Entity)) {
644 644
 		return false;
645 645
 	}
646 646
 
647 647
 	$can_view = true;
648 648
 
649
-	if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) {
650
-		$can_view = $entity->user_can_view( $user_id, $entity_id );
649
+	if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) {
650
+		$can_view = $entity->user_can_view($user_id, $entity_id);
651 651
 	}
652 652
 
653 653
 	/**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
  */
679 679
 function wordpoints_apps() {
680 680
 
681
-	if ( ! isset( WordPoints_App::$main ) ) {
682
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
681
+	if ( ! isset(WordPoints_App::$main)) {
682
+		WordPoints_App::$main = new WordPoints_App('apps');
683 683
 	}
684 684
 
685 685
 	return WordPoints_App::$main;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function wordpoints_hooks() {
696 696
 
697
-	if ( ! isset( WordPoints_App::$main ) ) {
697
+	if ( ! isset(WordPoints_App::$main)) {
698 698
 		wordpoints_apps();
699 699
 	}
700 700
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
  */
711 711
 function wordpoints_entities() {
712 712
 
713
-	if ( ! isset( WordPoints_App::$main ) ) {
713
+	if ( ! isset(WordPoints_App::$main)) {
714 714
 		wordpoints_apps();
715 715
 	}
716 716
 
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
  *
727 727
  * @param WordPoints_App $app The main apps app.
728 728
  */
729
-function wordpoints_apps_init( $app ) {
729
+function wordpoints_apps_init($app) {
730 730
 
731 731
 	$apps = $app->sub_apps;
732 732
 
733
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
734
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
735
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
733
+	$apps->register('hooks', 'WordPoints_Hooks');
734
+	$apps->register('entities', 'WordPoints_App_Registry');
735
+	$apps->register('data_types', 'WordPoints_Class_Registry');
736 736
 }
737 737
 
738 738
 /**
@@ -745,19 +745,19 @@  discard block
 block discarded – undo
745 745
  *
746 746
  * @return object|false The constructed object, or false if to many args were passed.
747 747
  */
748
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
748
+function wordpoints_construct_class_with_args($class_name, array $args) {
749 749
 
750
-	switch ( count( $args ) ) {
750
+	switch (count($args)) {
751 751
 		case 0:
752 752
 			return new $class_name();
753 753
 		case 1:
754
-			return new $class_name( $args[0] );
754
+			return new $class_name($args[0]);
755 755
 		case 2:
756
-			return new $class_name( $args[0], $args[1] );
756
+			return new $class_name($args[0], $args[1]);
757 757
 		case 3:
758
-			return new $class_name( $args[0], $args[1], $args[2] );
758
+			return new $class_name($args[0], $args[1], $args[2]);
759 759
 		case 4:
760
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
760
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
761 761
 		default:
762 762
 			return false;
763 763
 	}
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
780 780
  *               slug is not dynamic, the value of each of those keys will be false.
781 781
  */
782
-function wordpoints_parse_dynamic_slug( $slug ) {
782
+function wordpoints_parse_dynamic_slug($slug) {
783 783
 
784
-	$parsed = array( 'dynamic' => false, 'generic' => false );
784
+	$parsed = array('dynamic' => false, 'generic' => false);
785 785
 
786
-	$parts = explode( '\\', $slug, 2 );
786
+	$parts = explode('\\', $slug, 2);
787 787
 
788
-	if ( isset( $parts[1] ) ) {
788
+	if (isset($parts[1])) {
789 789
 		$parsed['dynamic'] = $parts[1];
790 790
 		$parsed['generic'] = $parts[0];
791 791
 	}
@@ -824,28 +824,28 @@  discard block
 block discarded – undo
824 824
  *                     contexts, indexed by context slug, or false if any of the
825 825
  *                     contexts isn't current.
826 826
  */
827
-function wordpoints_entities_get_current_context_id( $slug ) {
827
+function wordpoints_entities_get_current_context_id($slug) {
828 828
 
829 829
 	$current_context = array();
830 830
 
831 831
 	/** @var WordPoints_Class_Registry $contexts */
832 832
 	$contexts = wordpoints_entities()->contexts;
833 833
 
834
-	while ( $slug ) {
834
+	while ($slug) {
835 835
 
836
-		$context = $contexts->get( $slug );
836
+		$context = $contexts->get($slug);
837 837
 
838
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
838
+		if ( ! $context instanceof WordPoints_Entity_Context) {
839 839
 			return false;
840 840
 		}
841 841
 
842 842
 		$id = $context->get_current_id();
843 843
 
844
-		if ( false === $id ) {
844
+		if (false === $id) {
845 845
 			return false;
846 846
 		}
847 847
 
848
-		$current_context[ $slug ] = $id;
848
+		$current_context[$slug] = $id;
849 849
 
850 850
 		$slug = $context->get_parent_slug();
851 851
 	}
@@ -866,22 +866,22 @@  discard block
 block discarded – undo
866 866
  */
867 867
 function wordpoints_is_network_context() {
868 868
 
869
-	if ( ! is_multisite() ) {
869
+	if ( ! is_multisite()) {
870 870
 		return false;
871 871
 	}
872 872
 
873
-	if ( is_network_admin() ) {
873
+	if (is_network_admin()) {
874 874
 		return true;
875 875
 	}
876 876
 
877 877
 	// See https://core.trac.wordpress.org/ticket/22589
878 878
 	if (
879
-		defined( 'DOING_AJAX' )
879
+		defined('DOING_AJAX')
880 880
 		&& DOING_AJAX
881
-		&& isset( $_SERVER['HTTP_REFERER'] )
881
+		&& isset($_SERVER['HTTP_REFERER'])
882 882
 		&& preg_match(
883
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
884
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
883
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
884
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
885 885
 		)
886 886
 	) {
887 887
 		return true;
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 	 *
895 895
 	 * @param bool $in_network_context Whether we are in network context.
896 896
 	 */
897
-	return apply_filters( 'wordpoints_is_network_context', false );
897
+	return apply_filters('wordpoints_is_network_context', false);
898 898
 }
899 899
 
900 900
 /**
@@ -908,21 +908,21 @@  discard block
 block discarded – undo
908 908
  *
909 909
  * @return string The primary arg's GUID, JSON encoded.
910 910
  */
911
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
911
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
912 912
 
913 913
 	$entity = $event_args->get_primary_arg();
914 914
 
915
-	if ( ! $entity ) {
915
+	if ( ! $entity) {
916 916
 		return '';
917 917
 	}
918 918
 
919 919
 	$the_guid = $entity->get_the_guid();
920 920
 
921
-	if ( ! $the_guid ) {
921
+	if ( ! $the_guid) {
922 922
 		return '';
923 923
 	}
924 924
 
925
-	return wp_json_encode( $the_guid );
925
+	return wp_json_encode($the_guid);
926 926
 }
927 927
 
928 928
 /**
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  */
936 936
 function wordpoints_hooks_api_add_global_cache_groups() {
937 937
 
938
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
938
+	if (function_exists('wp_cache_add_global_groups')) {
939 939
 
940 940
 		wp_cache_add_global_groups(
941 941
 			array(
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
  * @return string The escaped identifier. Already quoted, do not place within
962 962
  *                backticks.
963 963
  */
964
-function wordpoints_escape_mysql_identifier( $identifier ) {
965
-	return '`' . str_replace( '`', '``', $identifier ) . '`';
964
+function wordpoints_escape_mysql_identifier($identifier) {
965
+	return '`'.str_replace('`', '``', $identifier).'`';
966 966
 }
967 967
 
968 968
 // EOF
Please login to merge, or discard this patch.