@@ -10,17 +10,17 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if we aren't being uninstalled. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -require_once( dirname( __FILE__ ) . '/includes/constants.php' ); |
|
18 | -require_once( WORDPOINTS_DIR . '/includes/functions.php' ); |
|
19 | -require_once( WORDPOINTS_DIR . '/includes/class-installables.php' ); |
|
20 | -require_once( WORDPOINTS_DIR . '/includes/class-un-installer-base.php' ); |
|
17 | +require_once(dirname(__FILE__) . '/includes/constants.php'); |
|
18 | +require_once(WORDPOINTS_DIR . '/includes/functions.php'); |
|
19 | +require_once(WORDPOINTS_DIR . '/includes/class-installables.php'); |
|
20 | +require_once(WORDPOINTS_DIR . '/includes/class-un-installer-base.php'); |
|
21 | 21 | |
22 | 22 | wordpoints_register_installer(); |
23 | 23 | |
24 | -WordPoints_Installables::uninstall( 'plugin', 'wordpoints' ); |
|
24 | +WordPoints_Installables::uninstall('plugin', 'wordpoints'); |
|
25 | 25 | |
26 | 26 | // EOF |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->backup['original_blog_id'] = get_current_blog_id(); |
42 | 42 | |
43 | - if ( isset( $GLOBALS['_wp_switched_stack'] ) ) { |
|
43 | + if (isset($GLOBALS['_wp_switched_stack'])) { |
|
44 | 44 | $this->backup['switched_stack'] = $GLOBALS['_wp_switched_stack']; |
45 | 45 | } |
46 | 46 | |
47 | - if ( isset( $GLOBALS['switched'] ) ) { |
|
47 | + if (isset($GLOBALS['switched'])) { |
|
48 | 48 | $this->backup['switched'] = $GLOBALS['switched']; |
49 | 49 | } |
50 | 50 | |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function restore() { |
64 | 64 | |
65 | - switch_to_blog( $this->backup['original_blog_id'] ); |
|
65 | + switch_to_blog($this->backup['original_blog_id']); |
|
66 | 66 | |
67 | - if ( isset( $this->backup['switched_stack'] ) ) { |
|
67 | + if (isset($this->backup['switched_stack'])) { |
|
68 | 68 | $GLOBALS['_wp_switched_stack'] = $this->backup['switched_stack']; |
69 | 69 | } else { |
70 | - unset( $GLOBALS['_wp_switched_stack'] ); |
|
70 | + unset($GLOBALS['_wp_switched_stack']); |
|
71 | 71 | } |
72 | 72 | |
73 | - if ( isset( $this->backup['switched'] ) ) { |
|
73 | + if (isset($this->backup['switched'])) { |
|
74 | 74 | $GLOBALS['switched'] = $this->backup['switched']; |
75 | 75 | } else { |
76 | - unset( $GLOBALS['switched'] ); |
|
76 | + unset($GLOBALS['switched']); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $this->backup['original_blog_id']; |
@@ -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 | } |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return WordPoints_DB_Query To allow for method chaining. |
250 | 250 | */ |
251 | - public function set_args( array $args ) { |
|
251 | + public function set_args(array $args) { |
|
252 | 252 | |
253 | - $this->args = array_merge( $this->args, $args ); |
|
253 | + $this->args = array_merge($this->args, $args); |
|
254 | 254 | |
255 | 255 | $this->is_query_ready = false; |
256 | 256 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | global $wpdb; |
275 | 275 | |
276 | - $count = (int) $wpdb->get_var( $this->get_sql( 'SELECT COUNT' ) ); // WPCS: unprepared SQL, cache OK |
|
276 | + $count = (int) $wpdb->get_var($this->get_sql('SELECT COUNT')); // WPCS: unprepared SQL, cache OK |
|
277 | 277 | |
278 | 278 | return $count; |
279 | 279 | } |
@@ -288,20 +288,20 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return mixed The results of the query, or false on failure. |
290 | 290 | */ |
291 | - public function get( $method = 'results' ) { |
|
291 | + public function get($method = 'results') { |
|
292 | 292 | |
293 | 293 | global $wpdb; |
294 | 294 | |
295 | - $methods = array( 'results', 'row', 'col', 'var' ); |
|
295 | + $methods = array('results', 'row', 'col', 'var'); |
|
296 | 296 | |
297 | - if ( ! in_array( $method, $methods ) ) { |
|
297 | + if ( ! in_array($method, $methods)) { |
|
298 | 298 | |
299 | - _doing_it_wrong( __METHOD__, esc_html( sprintf( 'WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode( ', ', $methods ) ) ), '1.0.0' ); |
|
299 | + _doing_it_wrong(__METHOD__, esc_html(sprintf('WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode(', ', $methods))), '1.0.0'); |
|
300 | 300 | |
301 | 301 | return false; |
302 | 302 | } |
303 | 303 | |
304 | - $result = $wpdb->{"get_{$method}"}( $this->get_sql() ); |
|
304 | + $result = $wpdb->{"get_{$method}"}($this->get_sql()); |
|
305 | 305 | |
306 | 306 | return $result; |
307 | 307 | } |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string The SQL for the query. |
323 | 323 | */ |
324 | - public function get_sql( $select_type = 'SELECT' ) { |
|
324 | + public function get_sql($select_type = 'SELECT') { |
|
325 | 325 | |
326 | 326 | $this->prepare_query(); |
327 | 327 | |
328 | - $select = ( 'SELECT COUNT' === $select_type ) |
|
328 | + $select = ('SELECT COUNT' === $select_type) |
|
329 | 329 | ? $this->select_count |
330 | 330 | : $this->select; |
331 | 331 | |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string[] The valid columns. |
355 | 355 | */ |
356 | - public function date_query_valid_columns_filter( $valid_columns ) { |
|
356 | + public function date_query_valid_columns_filter($valid_columns) { |
|
357 | 357 | |
358 | 358 | $valid_columns = array_merge( |
359 | 359 | $valid_columns |
360 | 360 | , array_keys( |
361 | - wp_list_filter( $this->columns, array( 'is_date' => true ) ) |
|
361 | + wp_list_filter($this->columns, array('is_date' => true)) |
|
362 | 362 | ) |
363 | 363 | ); |
364 | 364 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | protected function prepare_query() { |
378 | 378 | |
379 | - if ( ! $this->is_query_ready ) { |
|
379 | + if ( ! $this->is_query_ready) { |
|
380 | 380 | |
381 | 381 | $this->prepare_select(); |
382 | 382 | $this->prepare_where(); |
@@ -394,26 +394,26 @@ discard block |
||
394 | 394 | */ |
395 | 395 | protected function prepare_select() { |
396 | 396 | |
397 | - $all_fields = array_keys( $this->columns ); |
|
397 | + $all_fields = array_keys($this->columns); |
|
398 | 398 | $fields = array(); |
399 | 399 | |
400 | - if ( ! empty( $this->args['fields'] ) ) { |
|
400 | + if ( ! empty($this->args['fields'])) { |
|
401 | 401 | |
402 | 402 | $fields = (array) $this->args['fields']; |
403 | - $diff = array_diff( $fields, $all_fields ); |
|
404 | - $fields = array_intersect( $all_fields, $fields ); |
|
403 | + $diff = array_diff($fields, $all_fields); |
|
404 | + $fields = array_intersect($all_fields, $fields); |
|
405 | 405 | |
406 | - if ( ! empty( $diff ) ) { |
|
407 | - _doing_it_wrong( __METHOD__, esc_html( 'WordPoints Debug Error: invalid field(s) "' . implode( '", "', $diff ) . '" given' ), '1.0.0' ); |
|
406 | + if ( ! empty($diff)) { |
|
407 | + _doing_it_wrong(__METHOD__, esc_html('WordPoints Debug Error: invalid field(s) "' . implode('", "', $diff) . '" given'), '1.0.0'); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | // Pull all fields by default. |
412 | - if ( empty( $fields ) ) { |
|
412 | + if (empty($fields)) { |
|
413 | 413 | $fields = $all_fields; |
414 | 414 | } |
415 | 415 | |
416 | - $fields = implode( ', ', array_map( 'wordpoints_escape_mysql_identifier', $fields ) ); |
|
416 | + $fields = implode(', ', array_map('wordpoints_escape_mysql_identifier', $fields)); |
|
417 | 417 | |
418 | 418 | $this->select = "SELECT {$fields}"; |
419 | 419 | } |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return mixed The validated value, or false if invalid. |
430 | 430 | */ |
431 | - protected function validate_value( $value, $validators ) { |
|
431 | + protected function validate_value($value, $validators) { |
|
432 | 432 | |
433 | - foreach ( $validators as $validator ) { |
|
433 | + foreach ($validators as $validator) { |
|
434 | 434 | |
435 | - $value = call_user_func_array( $validator, array( &$value ) ); |
|
435 | + $value = call_user_func_array($validator, array(&$value)); |
|
436 | 436 | |
437 | - if ( false === $value ) { |
|
437 | + if (false === $value) { |
|
438 | 438 | break; |
439 | 439 | } |
440 | 440 | } |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return array The validated values, with any invalid ones removed. |
454 | 454 | */ |
455 | - protected function validate_values( $values, $validators ) { |
|
455 | + protected function validate_values($values, $validators) { |
|
456 | 456 | |
457 | - foreach ( $values as $index => $value ) { |
|
457 | + foreach ($values as $index => $value) { |
|
458 | 458 | |
459 | - $value = $this->validate_value( $value, $validators ); |
|
459 | + $value = $this->validate_value($value, $validators); |
|
460 | 460 | |
461 | - if ( false === $value ) { |
|
462 | - unset( $values[ $index ] ); |
|
461 | + if (false === $value) { |
|
462 | + unset($values[$index]); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return int|false The validated value or false. |
480 | 480 | */ |
481 | - protected function validate_unsigned_column( $value ) { |
|
481 | + protected function validate_unsigned_column($value) { |
|
482 | 482 | |
483 | - if ( false !== wordpoints_int( $value ) && $value >= 0 ) { |
|
483 | + if (false !== wordpoints_int($value) && $value >= 0) { |
|
484 | 484 | return $value; |
485 | 485 | } |
486 | 486 | |
@@ -496,14 +496,14 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return callable[] The validation functions. |
498 | 498 | */ |
499 | - protected function get_validators_for_column( $data ) { |
|
499 | + protected function get_validators_for_column($data) { |
|
500 | 500 | |
501 | 501 | $validators = array(); |
502 | 502 | |
503 | 503 | // Default validators for integer columns. |
504 | - if ( '%d' === $data['format'] ) { |
|
505 | - if ( ! empty( $data['unsigned'] ) ) { |
|
506 | - $validators[] = array( $this, 'validate_unsigned_column' ); |
|
504 | + if ('%d' === $data['format']) { |
|
505 | + if ( ! empty($data['unsigned'])) { |
|
506 | + $validators[] = array($this, 'validate_unsigned_column'); |
|
507 | 507 | } else { |
508 | 508 | $validators[] = 'wordpoints_int'; |
509 | 509 | } |
@@ -520,15 +520,15 @@ discard block |
||
520 | 520 | * @param string $column The column name. |
521 | 521 | * @param array $data The column data. |
522 | 522 | */ |
523 | - protected function prepare_column_where( $column, $data ) { |
|
523 | + protected function prepare_column_where($column, $data) { |
|
524 | 524 | |
525 | 525 | // If a single value has been supplied for the column, it takes precedence. |
526 | - if ( isset( $this->args[ $column ] ) ) { |
|
527 | - $this->prepare_column( $column, $data ); |
|
528 | - } elseif ( isset( $this->args[ "{$column}__in" ] ) ) { |
|
529 | - $this->prepare_column__in( $column, $data ); |
|
530 | - } elseif ( isset( $this->args[ "{$column}__not_in" ] ) ) { |
|
531 | - $this->prepare_column__in( $column, $data, 'NOT IN' ); |
|
526 | + if (isset($this->args[$column])) { |
|
527 | + $this->prepare_column($column, $data); |
|
528 | + } elseif (isset($this->args["{$column}__in"])) { |
|
529 | + $this->prepare_column__in($column, $data); |
|
530 | + } elseif (isset($this->args["{$column}__not_in"])) { |
|
531 | + $this->prepare_column__in($column, $data, 'NOT IN'); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
@@ -540,29 +540,29 @@ discard block |
||
540 | 540 | * @param string $column The name of the column |
541 | 541 | * @param array $data The column data. |
542 | 542 | */ |
543 | - protected function prepare_column( $column, $data ) { |
|
543 | + protected function prepare_column($column, $data) { |
|
544 | 544 | |
545 | 545 | global $wpdb; |
546 | 546 | |
547 | 547 | if ( |
548 | - isset( $data['values'] ) |
|
549 | - && ! in_array( $this->args[ $column ], $data['values'], true ) |
|
548 | + isset($data['values']) |
|
549 | + && ! in_array($this->args[$column], $data['values'], true) |
|
550 | 550 | ) { |
551 | 551 | return; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $value = $this->validate_value( |
555 | - $this->args[ $column ] |
|
556 | - , $this->get_validators_for_column( $data ) |
|
555 | + $this->args[$column] |
|
556 | + , $this->get_validators_for_column($data) |
|
557 | 557 | ); |
558 | 558 | |
559 | - if ( false === $value ) { |
|
559 | + if (false === $value) { |
|
560 | 560 | return; |
561 | 561 | } |
562 | 562 | |
563 | - $compare = $this->get_comparator_for_column( $column, $data ); |
|
563 | + $compare = $this->get_comparator_for_column($column, $data); |
|
564 | 564 | |
565 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
565 | + $column = wordpoints_escape_mysql_identifier($column); |
|
566 | 566 | |
567 | 567 | $this->wheres[] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
568 | 568 | "{$column} {$compare} {$data['format']}" |
@@ -580,23 +580,23 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return string The comparator for the column. |
582 | 582 | */ |
583 | - protected function get_comparator_for_column( $column, $data ) { |
|
583 | + protected function get_comparator_for_column($column, $data) { |
|
584 | 584 | |
585 | - $comparisons = array( '=', '<', '>', '<>', '!=', '<=', '>=' ); |
|
585 | + $comparisons = array('=', '<', '>', '<>', '!=', '<=', '>='); |
|
586 | 586 | |
587 | 587 | // MySQL doesn't support LIKE and NOT LIKE for int columns. |
588 | 588 | // See https://stackoverflow.com/q/8422455/1924128 |
589 | - if ( '%s' === $data['format'] ) { |
|
590 | - $comparisons = array_merge( $comparisons, array( 'LIKE', 'NOT LIKE' ) ); |
|
589 | + if ('%s' === $data['format']) { |
|
590 | + $comparisons = array_merge($comparisons, array('LIKE', 'NOT LIKE')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | $comparator = '='; |
594 | 594 | |
595 | 595 | if ( |
596 | - isset( $this->args[ "{$column}__compare" ] ) |
|
597 | - && in_array( $this->args[ "{$column}__compare" ], $comparisons, true ) |
|
596 | + isset($this->args["{$column}__compare"]) |
|
597 | + && in_array($this->args["{$column}__compare"], $comparisons, true) |
|
598 | 598 | ) { |
599 | - $comparator = $this->args[ "{$column}__compare" ]; |
|
599 | + $comparator = $this->args["{$column}__compare"]; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | return $comparator; |
@@ -611,36 +611,36 @@ discard block |
||
611 | 611 | * @param array $data The column data. |
612 | 612 | * @param string $type The type of IN clause, IN or NOT IN. |
613 | 613 | */ |
614 | - protected function prepare_column__in( $column, $data, $type = 'IN' ) { |
|
614 | + protected function prepare_column__in($column, $data, $type = 'IN') { |
|
615 | 615 | |
616 | - $key = "{$column}__" . strtolower( str_replace( ' ', '_', $type ) ); |
|
616 | + $key = "{$column}__" . strtolower(str_replace(' ', '_', $type)); |
|
617 | 617 | |
618 | - if ( empty( $this->args[ $key ] ) || ! is_array( $this->args[ $key ] ) ) { |
|
618 | + if (empty($this->args[$key]) || ! is_array($this->args[$key])) { |
|
619 | 619 | return; |
620 | 620 | } |
621 | 621 | |
622 | - $values = $this->args[ $key ]; |
|
622 | + $values = $this->args[$key]; |
|
623 | 623 | |
624 | - if ( isset( $data['values'] ) ) { |
|
625 | - $values = array_intersect( $values, $data['values'] ); |
|
624 | + if (isset($data['values'])) { |
|
625 | + $values = array_intersect($values, $data['values']); |
|
626 | 626 | } else { |
627 | 627 | $values = $this->validate_values( |
628 | 628 | $values |
629 | - , $this->get_validators_for_column( $data ) |
|
629 | + , $this->get_validators_for_column($data) |
|
630 | 630 | ); |
631 | 631 | } |
632 | 632 | |
633 | - if ( empty( $values ) ) { |
|
633 | + if (empty($values)) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - $in = wordpoints_prepare__in( $values, $data['format'] ); |
|
637 | + $in = wordpoints_prepare__in($values, $data['format']); |
|
638 | 638 | |
639 | - if ( false === $in ) { |
|
639 | + if (false === $in) { |
|
640 | 640 | return; |
641 | 641 | } |
642 | 642 | |
643 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
643 | + $column = wordpoints_escape_mysql_identifier($column); |
|
644 | 644 | |
645 | 645 | $this->wheres[] = "{$column} {$type} ({$in})"; |
646 | 646 | } |
@@ -654,19 +654,19 @@ discard block |
||
654 | 654 | |
655 | 655 | $this->wheres = array(); |
656 | 656 | |
657 | - foreach ( $this->columns as $column => $data ) { |
|
657 | + foreach ($this->columns as $column => $data) { |
|
658 | 658 | |
659 | - if ( ! empty( $data['is_date'] ) ) { |
|
660 | - $this->prepare_date_where( $column ); |
|
659 | + if ( ! empty($data['is_date'])) { |
|
660 | + $this->prepare_date_where($column); |
|
661 | 661 | } else { |
662 | - $this->prepare_column_where( $column, $data ); |
|
662 | + $this->prepare_column_where($column, $data); |
|
663 | 663 | } |
664 | 664 | } |
665 | 665 | |
666 | 666 | $this->prepare_meta_where(); |
667 | 667 | |
668 | - if ( ! empty( $this->wheres ) ) { |
|
669 | - $this->where = 'WHERE ' . implode( ' AND ', $this->wheres ) . "\n"; |
|
668 | + if ( ! empty($this->wheres)) { |
|
669 | + $this->where = 'WHERE ' . implode(' AND ', $this->wheres) . "\n"; |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
@@ -679,32 +679,32 @@ discard block |
||
679 | 679 | |
680 | 680 | // MySQL doesn't allow for the offset without a limit, so if no limit is set |
681 | 681 | // we can ignore the start arg. See https://stackoverflow.com/a/271650/1924128 |
682 | - if ( ! isset( $this->args['limit'] ) ) { |
|
682 | + if ( ! isset($this->args['limit'])) { |
|
683 | 683 | return; |
684 | 684 | } |
685 | 685 | |
686 | - foreach ( array( 'limit', 'start' ) as $key ) { |
|
686 | + foreach (array('limit', 'start') as $key) { |
|
687 | 687 | |
688 | 688 | // Save a backup of the arg value since wordpoints_int() is by reference. |
689 | - $arg = $this->args[ $key ]; |
|
689 | + $arg = $this->args[$key]; |
|
690 | 690 | |
691 | - if ( false === wordpoints_int( $this->args[ $key ] ) ) { |
|
691 | + if (false === wordpoints_int($this->args[$key])) { |
|
692 | 692 | |
693 | 693 | _doing_it_wrong( |
694 | 694 | __METHOD__ |
695 | 695 | , sprintf( |
696 | 696 | "WordPoints Debug Error: '%s' must be a positive integer, %s given" |
697 | - , esc_html( $key ) |
|
698 | - , esc_html( strval( $arg ) ? $arg : gettype( $arg ) ) |
|
697 | + , esc_html($key) |
|
698 | + , esc_html(strval($arg) ? $arg : gettype($arg)) |
|
699 | 699 | ) |
700 | 700 | , '1.0.0' |
701 | 701 | ); |
702 | 702 | |
703 | - $this->args[ $key ] = 0; |
|
703 | + $this->args[$key] = 0; |
|
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
707 | - if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
|
707 | + if ($this->args['limit'] > 0 && $this->args['start'] >= 0) { |
|
708 | 708 | $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
709 | 709 | } |
710 | 710 | } |
@@ -716,20 +716,20 @@ discard block |
||
716 | 716 | */ |
717 | 717 | protected function prepare_order_by() { |
718 | 718 | |
719 | - if ( empty( $this->args['order_by'] ) ) { |
|
719 | + if (empty($this->args['order_by'])) { |
|
720 | 720 | return; |
721 | 721 | } |
722 | 722 | |
723 | 723 | $order = $this->args['order']; |
724 | 724 | $order_by = $this->args['order_by']; |
725 | 725 | |
726 | - if ( ! in_array( $order, array( 'DESC', 'ASC' ) ) ) { |
|
726 | + if ( ! in_array($order, array('DESC', 'ASC'))) { |
|
727 | 727 | |
728 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC" ), '1.0.0' ); |
|
728 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC"), '1.0.0'); |
|
729 | 729 | $order = 'DESC'; |
730 | 730 | } |
731 | 731 | |
732 | - if ( 'meta_value' === $order_by ) { |
|
732 | + if ('meta_value' === $order_by) { |
|
733 | 733 | |
734 | 734 | global $wpdb; |
735 | 735 | |
@@ -737,9 +737,9 @@ discard block |
||
737 | 737 | $wpdb->{"{$this->meta_type}meta"} |
738 | 738 | ); |
739 | 739 | |
740 | - if ( isset( $this->args['meta_type'] ) ) { |
|
740 | + if (isset($this->args['meta_type'])) { |
|
741 | 741 | |
742 | - $meta_type = $this->meta_query->get_cast_for_type( $this->args['meta_type'] ); |
|
742 | + $meta_type = $this->meta_query->get_cast_for_type($this->args['meta_type']); |
|
743 | 743 | $order_by = "CAST({$meta_table_name}.meta_value AS {$meta_type})"; |
744 | 744 | |
745 | 745 | } else { |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | $order_by = "{$meta_table_name}.meta_value"; |
748 | 748 | } |
749 | 749 | |
750 | - } elseif ( isset( $this->columns[ $order_by ] ) ) { |
|
750 | + } elseif (isset($this->columns[$order_by])) { |
|
751 | 751 | |
752 | - $order_by = wordpoints_escape_mysql_identifier( $order_by ); |
|
752 | + $order_by = wordpoints_escape_mysql_identifier($order_by); |
|
753 | 753 | |
754 | 754 | } else { |
755 | 755 | |
756 | - _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' ); |
|
756 | + _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'); |
|
757 | 757 | return; |
758 | 758 | } |
759 | 759 | |
@@ -767,25 +767,25 @@ discard block |
||
767 | 767 | * |
768 | 768 | * @param string $column The name of the column. |
769 | 769 | */ |
770 | - protected function prepare_date_where( $column ) { |
|
770 | + protected function prepare_date_where($column) { |
|
771 | 771 | |
772 | 772 | if ( |
773 | - empty( $this->args[ "{$column}_query" ] ) |
|
774 | - || ! is_array( $this->args[ "{$column}_query" ] ) |
|
773 | + empty($this->args["{$column}_query"]) |
|
774 | + || ! is_array($this->args["{$column}_query"]) |
|
775 | 775 | ) { |
776 | 776 | return; |
777 | 777 | } |
778 | 778 | |
779 | - add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
779 | + add_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
780 | 780 | |
781 | - $date_query = new WP_Date_Query( $this->args[ "{$column}_query" ], $column ); |
|
781 | + $date_query = new WP_Date_Query($this->args["{$column}_query"], $column); |
|
782 | 782 | $date_query = $date_query->get_sql(); |
783 | 783 | |
784 | - if ( ! empty( $date_query ) ) { |
|
785 | - $this->wheres[] = ltrim( $date_query, ' AND' ); |
|
784 | + if ( ! empty($date_query)) { |
|
785 | + $this->wheres[] = ltrim($date_query, ' AND'); |
|
786 | 786 | } |
787 | 787 | |
788 | - remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
788 | + remove_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | /** |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | */ |
796 | 796 | protected function prepare_meta_where() { |
797 | 797 | |
798 | - if ( empty( $this->meta_type ) ) { |
|
798 | + if (empty($this->meta_type)) { |
|
799 | 799 | return; |
800 | 800 | } |
801 | 801 | |
@@ -810,12 +810,12 @@ discard block |
||
810 | 810 | ) |
811 | 811 | ); |
812 | 812 | |
813 | - if ( empty( $meta_args ) ) { |
|
813 | + if (empty($meta_args)) { |
|
814 | 814 | return; |
815 | 815 | } |
816 | 816 | |
817 | 817 | $this->meta_query = new WP_Meta_Query(); |
818 | - $this->meta_query->parse_query_vars( $meta_args ); |
|
818 | + $this->meta_query->parse_query_vars($meta_args); |
|
819 | 819 | |
820 | 820 | $meta_query = $this->meta_query->get_sql( |
821 | 821 | $this->meta_type |
@@ -824,8 +824,8 @@ discard block |
||
824 | 824 | , $this |
825 | 825 | ); |
826 | 826 | |
827 | - if ( ! empty( $meta_query['where'] ) ) { |
|
828 | - $this->wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
827 | + if ( ! empty($meta_query['where'])) { |
|
828 | + $this->wheres[] = ltrim($meta_query['where'], ' AND'); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | $this->meta_join = $meta_query['join'] . "\n"; |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @since 2.1.0 |
96 | 96 | */ |
97 | - public function __construct( $slug, $parent = null ) { |
|
97 | + public function __construct($slug, $parent = null) { |
|
98 | 98 | |
99 | 99 | $this->slug = $slug; |
100 | 100 | $this->full_slug = $slug; |
101 | 101 | |
102 | - if ( $parent instanceof WordPoints_App ) { |
|
102 | + if ($parent instanceof WordPoints_App) { |
|
103 | 103 | $this->parent = $parent; |
104 | 104 | |
105 | - if ( 'apps' !== $this->parent->full_slug ) { |
|
105 | + if ('apps' !== $this->parent->full_slug) { |
|
106 | 106 | $this->full_slug = $this->parent->full_slug . '-' . $this->full_slug; |
107 | 107 | } |
108 | 108 | } |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | * @return null|object|WordPoints_App|WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI|WordPoints_Class_Registry_DeepI |
123 | 123 | * The sub app, or null if not found. |
124 | 124 | */ |
125 | - public function get_sub_app( $slug ) { |
|
125 | + public function get_sub_app($slug) { |
|
126 | 126 | |
127 | - $sub_app = $this->sub_apps->get( $slug, array( $this ) ); |
|
127 | + $sub_app = $this->sub_apps->get($slug, array($this)); |
|
128 | 128 | |
129 | - if ( ! $sub_app ) { |
|
129 | + if ( ! $sub_app) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | |
133 | 133 | if ( |
134 | - empty( $this->did_init[ $slug ] ) |
|
134 | + empty($this->did_init[$slug]) |
|
135 | 135 | && ! self::$main->silent |
136 | - && $this->should_do_registry_init( $sub_app ) |
|
136 | + && $this->should_do_registry_init($sub_app) |
|
137 | 137 | ) { |
138 | 138 | |
139 | - $this->did_init[ $slug ] = true; |
|
139 | + $this->did_init[$slug] = true; |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Initialization of an app registry. |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI |
147 | 147 | * $registry The registry object. |
148 | 148 | */ |
149 | - do_action( "wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app ); |
|
149 | + do_action("wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $sub_app; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool Whether to call the init action or not. |
174 | 174 | */ |
175 | - protected function should_do_registry_init( $registry ) { |
|
175 | + protected function should_do_registry_init($registry) { |
|
176 | 176 | return ( |
177 | 177 | $registry instanceof WordPoints_Class_RegistryI |
178 | 178 | || $registry instanceof WordPoints_Class_Registry_ChildrenI |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param WordPoints_App $app The app object. |
199 | 199 | */ |
200 | - do_action( "wordpoints_init_app-{$this->full_slug}", $this ); |
|
200 | + do_action("wordpoints_init_app-{$this->full_slug}", $this); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | protected function init() { |
41 | 41 | |
42 | 42 | $sub_apps = $this->sub_apps; |
43 | - $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
|
44 | - $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
|
45 | - $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
|
46 | - $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
|
47 | - $sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' ); |
|
48 | - $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
|
49 | - $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
|
43 | + $sub_apps->register('router', 'WordPoints_Hook_Router'); |
|
44 | + $sub_apps->register('actions', 'WordPoints_Hook_Actions'); |
|
45 | + $sub_apps->register('events', 'WordPoints_Hook_Events'); |
|
46 | + $sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent'); |
|
47 | + $sub_apps->register('reaction_stores', 'WordPoints_Class_Registry_Children'); |
|
48 | + $sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent'); |
|
49 | + $sub_apps->register('conditions', 'WordPoints_Class_Registry_Children'); |
|
50 | 50 | |
51 | 51 | parent::init(); |
52 | 52 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_current_mode() { |
71 | 71 | |
72 | - if ( ! isset( $this->current_mode ) ) { |
|
73 | - $this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' ); |
|
72 | + if ( ! isset($this->current_mode)) { |
|
73 | + $this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $this->current_mode; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param string $mode The slug of the mode to set as the current mode. |
90 | 90 | */ |
91 | - public function set_current_mode( $mode ) { |
|
91 | + public function set_current_mode($mode) { |
|
92 | 92 | $this->current_mode = $mode; |
93 | 93 | } |
94 | 94 | |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object. |
103 | 103 | */ |
104 | - public function get_reaction_store( $slug ) { |
|
104 | + public function get_reaction_store($slug) { |
|
105 | 105 | |
106 | - $reaction_store = $this->get_sub_app( 'reaction_stores' )->get( |
|
106 | + $reaction_store = $this->get_sub_app('reaction_stores')->get( |
|
107 | 107 | $this->get_current_mode() |
108 | 108 | , $slug |
109 | 109 | ); |
110 | 110 | |
111 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
111 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Allowing access to stores out-of-context would lead to strange behavior. |
116 | - if ( false === $reaction_store->get_context_id() ) { |
|
116 | + if (false === $reaction_store->get_context_id()) { |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | |
@@ -129,30 +129,30 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return WordPoints_Hook_Reaction_StoreI[] The reaction stores with this slug. |
131 | 131 | */ |
132 | - public function get_reaction_stores( $slug ) { |
|
132 | + public function get_reaction_stores($slug) { |
|
133 | 133 | |
134 | - $reaction_stores = $this->get_sub_app( 'reaction_stores' ); |
|
134 | + $reaction_stores = $this->get_sub_app('reaction_stores'); |
|
135 | 135 | |
136 | 136 | $stores = array(); |
137 | 137 | |
138 | - foreach ( $reaction_stores->get_all_slugs() as $mode => $slugs ) { |
|
138 | + foreach ($reaction_stores->get_all_slugs() as $mode => $slugs) { |
|
139 | 139 | |
140 | - if ( ! in_array( $slug, $slugs ) ) { |
|
140 | + if ( ! in_array($slug, $slugs)) { |
|
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | |
144 | - $store = $reaction_stores->get( $mode, $slug, array( $mode ) ); |
|
144 | + $store = $reaction_stores->get($mode, $slug, array($mode)); |
|
145 | 145 | |
146 | - if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
146 | + if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
147 | 147 | continue; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Allowing access to stores out-of-context would lead to strange behavior. |
151 | - if ( false === $store->get_context_id() ) { |
|
151 | + if (false === $store->get_context_id()) { |
|
152 | 152 | continue; |
153 | 153 | } |
154 | 154 | |
155 | - $stores[ $mode ] = $store; |
|
155 | + $stores[$mode] = $store; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $stores; |
@@ -174,19 +174,19 @@ discard block |
||
174 | 174 | $action_type |
175 | 175 | ) { |
176 | 176 | |
177 | - foreach ( $this->get_sub_app( 'reaction_stores' )->get_all() as $reaction_stores ) { |
|
178 | - foreach ( $reaction_stores as $reaction_store ) { |
|
177 | + foreach ($this->get_sub_app('reaction_stores')->get_all() as $reaction_stores) { |
|
178 | + foreach ($reaction_stores as $reaction_store) { |
|
179 | 179 | |
180 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
180 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
181 | 181 | continue; |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Allowing access to stores out-of-context would lead to strange behavior. |
185 | - if ( false === $reaction_store->get_context_id() ) { |
|
185 | + if (false === $reaction_store->get_context_id()) { |
|
186 | 186 | continue; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) { |
|
189 | + foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) { |
|
190 | 190 | |
191 | 191 | $fire = new WordPoints_Hook_Fire( |
192 | 192 | $event_args |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | , $action_type |
195 | 195 | ); |
196 | 196 | |
197 | - $this->fire_reaction( $fire ); |
|
197 | + $this->fire_reaction($fire); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
@@ -207,32 +207,32 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
209 | 209 | */ |
210 | - protected function fire_reaction( $fire ) { |
|
210 | + protected function fire_reaction($fire) { |
|
211 | 211 | |
212 | 212 | /** @var WordPoints_Hook_ReactorI $reactor */ |
213 | - $reactor = $this->get_sub_app( 'reactors' )->get( $fire->reaction->get_reactor_slug() ); |
|
213 | + $reactor = $this->get_sub_app('reactors')->get($fire->reaction->get_reactor_slug()); |
|
214 | 214 | |
215 | - if ( ! in_array( $fire->action_type, $reactor->get_action_types(), true ) ) { |
|
215 | + if ( ! in_array($fire->action_type, $reactor->get_action_types(), true)) { |
|
216 | 216 | return; |
217 | 217 | } |
218 | 218 | |
219 | - $validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true ); |
|
219 | + $validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true); |
|
220 | 220 | $validator->validate(); |
221 | 221 | |
222 | - if ( $validator->had_errors() ) { |
|
222 | + if ($validator->had_errors()) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - unset( $validator ); |
|
226 | + unset($validator); |
|
227 | 227 | |
228 | 228 | /** @var WordPoints_Hook_ExtensionI[] $extensions */ |
229 | - $extensions = $this->get_sub_app( 'extensions' )->get_all(); |
|
229 | + $extensions = $this->get_sub_app('extensions')->get_all(); |
|
230 | 230 | |
231 | - foreach ( $extensions as $extension ) { |
|
232 | - if ( ! $extension->should_hit( $fire ) ) { |
|
233 | - foreach ( $extensions as $ext ) { |
|
234 | - if ( $ext instanceof WordPoints_Hook_Extension_Miss_ListenerI ) { |
|
235 | - $ext->after_miss( $fire ); |
|
231 | + foreach ($extensions as $extension) { |
|
232 | + if ( ! $extension->should_hit($fire)) { |
|
233 | + foreach ($extensions as $ext) { |
|
234 | + if ($ext instanceof WordPoints_Hook_Extension_Miss_ListenerI) { |
|
235 | + $ext->after_miss($fire); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | |
243 | 243 | $fire->hit(); |
244 | 244 | |
245 | - $reactor->hit( $fire ); |
|
245 | + $reactor->hit($fire); |
|
246 | 246 | |
247 | - foreach ( $extensions as $extension ) { |
|
248 | - if ( $extension instanceof WordPoints_Hook_Extension_Hit_ListenerI ) { |
|
249 | - $extension->after_hit( $fire ); |
|
247 | + foreach ($extensions as $extension) { |
|
248 | + if ($extension instanceof WordPoints_Hook_Extension_Hit_ListenerI) { |
|
249 | + $extension->after_hit($fire); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $dir The full path of the directory. |
64 | 64 | */ |
65 | - public static function register_dir( $dir ) { |
|
65 | + public static function register_dir($dir) { |
|
66 | 66 | |
67 | - if ( ! isset( self::$spl_enabled ) ) { |
|
67 | + if ( ! isset(self::$spl_enabled)) { |
|
68 | 68 | |
69 | - self::$spl_enabled = function_exists( 'spl_autoload_register' ); |
|
69 | + self::$spl_enabled = function_exists('spl_autoload_register'); |
|
70 | 70 | |
71 | - if ( self::$spl_enabled ) { |
|
72 | - spl_autoload_register( __CLASS__ . '::load_class' ); |
|
71 | + if (self::$spl_enabled) { |
|
72 | + spl_autoload_register(__CLASS__ . '::load_class'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $dir = trailingslashit( $dir ); |
|
76 | + $dir = trailingslashit($dir); |
|
77 | 77 | |
78 | - self::$dirs[ $dir ] = require( $dir . '/index.php' ); |
|
78 | + self::$dirs[$dir] = require($dir . '/index.php'); |
|
79 | 79 | |
80 | - if ( ! self::$spl_enabled ) { |
|
81 | - foreach ( self::$dirs[ $dir ] as $file ) { |
|
82 | - require_once( $dir . $file ); |
|
80 | + if ( ! self::$spl_enabled) { |
|
81 | + foreach (self::$dirs[$dir] as $file) { |
|
82 | + require_once($dir . $file); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param string $class_name The name fo the class to load. |
93 | 93 | */ |
94 | - public static function load_class( $class_name ) { |
|
94 | + public static function load_class($class_name) { |
|
95 | 95 | |
96 | - $class_name = strtolower( $class_name ); |
|
96 | + $class_name = strtolower($class_name); |
|
97 | 97 | |
98 | - foreach ( self::$dirs as $dir => $map ) { |
|
99 | - if ( isset( $map[ $class_name ] ) ) { |
|
100 | - require_once( $dir . $map[ $class_name ] ); |
|
98 | + foreach (self::$dirs as $dir => $map) { |
|
99 | + if (isset($map[$class_name])) { |
|
100 | + require_once($dir . $map[$class_name]); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return object[] The child objects, indexed by slug. |
30 | 30 | */ |
31 | - public function get_children( array $parent_slugs = array() ); |
|
31 | + public function get_children(array $parent_slugs = array()); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Get the slugs of all of the direct children of a certain parent. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string[] The child slugs. |
41 | 41 | */ |
42 | - public function get_children_slugs( array $parent_slugs = array() ); |
|
42 | + public function get_children_slugs(array $parent_slugs = array()); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get an object by its slug. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return false|object The object or false on failure. |
54 | 54 | */ |
55 | - public function get( $slug, array $parent_slugs = array() ); |
|
55 | + public function get($slug, array $parent_slugs = array()); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Register a type of object. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return bool Whether the class was registered successfully. |
68 | 68 | */ |
69 | - public function register( $slug, array $parent_slugs, $class, array $args = array() ); |
|
69 | + public function register($slug, array $parent_slugs, $class, array $args = array()); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Deregister a type of object. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param string[] $parent_slugs The slug(s) of the class's parent(s) in the |
78 | 78 | * hierarchy. |
79 | 79 | */ |
80 | - public function deregister( $slug, array $parent_slugs = array() ); |
|
80 | + public function deregister($slug, array $parent_slugs = array()); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Deregister all children of a particular parent in the hierarchy. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param string[] $parent_slugs The hierarchy of the parent. |
88 | 88 | */ |
89 | - public function deregister_children( array $parent_slugs = array() ); |
|
89 | + public function deregister_children(array $parent_slugs = array()); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Check if a type of object is registered by its slug. |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool Whether the class is registered. |
103 | 103 | */ |
104 | - public function is_registered( $slug, array $parent_slugs = array() ); |
|
104 | + public function is_registered($slug, array $parent_slugs = array()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // EOF |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return object[] The child objects, indexed by slug. |
48 | 48 | */ |
49 | - public function get_children( $parent_slug ); |
|
49 | + public function get_children($parent_slug); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Get the slugs of all of the classes that are children of a certain parent. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string[] The child slugs. |
59 | 59 | */ |
60 | - public function get_children_slugs( $parent_slug ); |
|
60 | + public function get_children_slugs($parent_slug); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get an object by its slug. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return object|false The object or false on failure. |
71 | 71 | */ |
72 | - public function get( $parent_slug, $slug ); |
|
72 | + public function get($parent_slug, $slug); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Register a type of object. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool Whether the class was registered successfully. |
85 | 85 | */ |
86 | - public function register( $parent_slug, $slug, $class, array $args = array() ); |
|
86 | + public function register($parent_slug, $slug, $class, array $args = array()); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Deregister a type of object. |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $parent_slug The group slug. |
94 | 94 | * @param string $slug The slug of the class to deregister. |
95 | 95 | */ |
96 | - public function deregister( $parent_slug, $slug ); |
|
96 | + public function deregister($parent_slug, $slug); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Deregister all children of a particular parent. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param string $parent_slug The group slug. |
104 | 104 | */ |
105 | - public function deregister_children( $parent_slug ); |
|
105 | + public function deregister_children($parent_slug); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Check if a type of object is registered by its slug. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether the class is registered. |
119 | 119 | */ |
120 | - public function is_registered( $parent_slug, $slug = null ); |
|
120 | + public function is_registered($parent_slug, $slug = null); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // EOF |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @since 2.1.0 |
52 | 52 | */ |
53 | - public function get_all( array $args = array() ) { |
|
53 | + public function get_all(array $args = array()) { |
|
54 | 54 | |
55 | 55 | $items = array(); |
56 | 56 | |
57 | - if ( $this->settings['pass_slugs'] ) { |
|
58 | - array_unshift( $args, null ); |
|
57 | + if ($this->settings['pass_slugs']) { |
|
58 | + array_unshift($args, null); |
|
59 | 59 | } |
60 | 60 | |
61 | - foreach ( $this->classes as $parent_slug => $classes ) { |
|
62 | - $items[ $parent_slug ] = WordPoints_Class_Registry::construct_with_args( |
|
61 | + foreach ($this->classes as $parent_slug => $classes) { |
|
62 | + $items[$parent_slug] = WordPoints_Class_Registry::construct_with_args( |
|
63 | 63 | $classes |
64 | - , $this->settings['pass_slugs'] ? array( $parent_slug ) + $args : $args |
|
64 | + , $this->settings['pass_slugs'] ? array($parent_slug) + $args : $args |
|
65 | 65 | , $this->settings |
66 | 66 | ); |
67 | 67 | } |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | * @since 2.1.0 |
74 | 74 | */ |
75 | 75 | public function get_all_slugs() { |
76 | - return array_map( 'array_keys', $this->classes ); |
|
76 | + return array_map('array_keys', $this->classes); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @since 2.1.0 |
81 | 81 | */ |
82 | - public function get_children( $parent_slug, array $args = array() ) { |
|
82 | + public function get_children($parent_slug, array $args = array()) { |
|
83 | 83 | |
84 | 84 | $items = array(); |
85 | 85 | |
86 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
86 | + if (isset($this->classes[$parent_slug])) { |
|
87 | 87 | |
88 | - if ( $this->settings['pass_slugs'] ) { |
|
89 | - array_unshift( $args, $parent_slug ); |
|
88 | + if ($this->settings['pass_slugs']) { |
|
89 | + array_unshift($args, $parent_slug); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $items = WordPoints_Class_Registry::construct_with_args( |
93 | - $this->classes[ $parent_slug ] |
|
93 | + $this->classes[$parent_slug] |
|
94 | 94 | , $args |
95 | 95 | , $this->settings |
96 | 96 | ); |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * @since 2.1.0 |
104 | 104 | */ |
105 | - public function get_children_slugs( $parent_slug ) { |
|
105 | + public function get_children_slugs($parent_slug) { |
|
106 | 106 | |
107 | 107 | $slugs = array(); |
108 | 108 | |
109 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
110 | - $slugs = array_keys( $this->classes[ $parent_slug ] ); |
|
109 | + if (isset($this->classes[$parent_slug])) { |
|
110 | + $slugs = array_keys($this->classes[$parent_slug]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $slugs; |
@@ -116,38 +116,38 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @since 2.1.0 |
118 | 118 | */ |
119 | - public function get( $parent_slug, $slug, array $args = array() ) { |
|
119 | + public function get($parent_slug, $slug, array $args = array()) { |
|
120 | 120 | |
121 | - if ( ! isset( $this->classes[ $parent_slug ][ $slug ] ) ) { |
|
121 | + if ( ! isset($this->classes[$parent_slug][$slug])) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
125 | - $class = $this->classes[ $parent_slug ][ $slug ]; |
|
125 | + $class = $this->classes[$parent_slug][$slug]; |
|
126 | 126 | |
127 | - if ( empty( $args ) ) { |
|
127 | + if (empty($args)) { |
|
128 | 128 | |
129 | - if ( $this->settings['pass_slugs'] ) { |
|
130 | - return new $class( $slug, $parent_slug ); |
|
129 | + if ($this->settings['pass_slugs']) { |
|
130 | + return new $class($slug, $parent_slug); |
|
131 | 131 | } else { |
132 | 132 | return new $class(); |
133 | 133 | } |
134 | 134 | |
135 | 135 | } else { |
136 | 136 | |
137 | - if ( $this->settings['pass_slugs'] ) { |
|
138 | - array_unshift( $args, $slug, $parent_slug ); |
|
137 | + if ($this->settings['pass_slugs']) { |
|
138 | + array_unshift($args, $slug, $parent_slug); |
|
139 | 139 | } |
140 | 140 | |
141 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
141 | + return wordpoints_construct_class_with_args($class, $args); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @since 2.1.0 |
147 | 147 | */ |
148 | - public function register( $parent_slug, $slug, $class, array $args = array() ) { |
|
148 | + public function register($parent_slug, $slug, $class, array $args = array()) { |
|
149 | 149 | |
150 | - $this->classes[ $parent_slug ][ $slug ] = $class; |
|
150 | + $this->classes[$parent_slug][$slug] = $class; |
|
151 | 151 | |
152 | 152 | return true; |
153 | 153 | } |
@@ -155,26 +155,26 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @since 2.1.0 |
157 | 157 | */ |
158 | - public function deregister( $parent_slug, $slug ) { |
|
159 | - unset( $this->classes[ $parent_slug ][ $slug ] ); |
|
158 | + public function deregister($parent_slug, $slug) { |
|
159 | + unset($this->classes[$parent_slug][$slug]); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @since 2.1.0 |
164 | 164 | */ |
165 | - public function deregister_children( $parent_slug ) { |
|
166 | - unset( $this->classes[ $parent_slug ] ); |
|
165 | + public function deregister_children($parent_slug) { |
|
166 | + unset($this->classes[$parent_slug]); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @since 2.1.0 |
171 | 171 | */ |
172 | - public function is_registered( $parent_slug, $slug = null ) { |
|
172 | + public function is_registered($parent_slug, $slug = null) { |
|
173 | 173 | |
174 | - if ( isset( $slug ) ) { |
|
175 | - return isset( $this->classes[ $parent_slug ][ $slug ] ); |
|
174 | + if (isset($slug)) { |
|
175 | + return isset($this->classes[$parent_slug][$slug]); |
|
176 | 176 | } else { |
177 | - return isset( $this->classes[ $parent_slug ] ); |
|
177 | + return isset($this->classes[$parent_slug]); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |