@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | * @since 2.1.0 |
19 | 19 | */ |
20 | 20 | protected $columns = array( |
21 | - 'id' => array( 'format' => '%d', 'unsigned' => true ), |
|
22 | - 'action_type' => array( 'format' => '%s' ), |
|
23 | - 'signature_arg_guids' => array( 'format' => '%s' ), |
|
24 | - 'event' => array( 'format' => '%s' ), |
|
25 | - 'reactor' => array( 'format' => '%s' ), |
|
26 | - 'reaction_mode' => array( 'format' => '%s' ), |
|
27 | - 'reaction_store' => array( 'format' => '%s' ), |
|
28 | - 'reaction_context_id' => array( 'format' => '%s' ), |
|
29 | - 'reaction_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
30 | - 'date' => array( 'format' => '%s', 'is_date' => true ), |
|
21 | + 'id' => array('format' => '%d', 'unsigned' => true), |
|
22 | + 'action_type' => array('format' => '%s'), |
|
23 | + 'signature_arg_guids' => array('format' => '%s'), |
|
24 | + 'event' => array('format' => '%s'), |
|
25 | + 'reactor' => array('format' => '%s'), |
|
26 | + 'reaction_mode' => array('format' => '%s'), |
|
27 | + 'reaction_store' => array('format' => '%s'), |
|
28 | + 'reaction_context_id' => array('format' => '%s'), |
|
29 | + 'reaction_id' => array('format' => '%d', 'unsigned' => true), |
|
30 | + 'date' => array('format' => '%s', 'is_date' => true), |
|
31 | 31 | ); |
32 | 32 | |
33 | 33 | /** |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | * @since 2.3.0 |
40 | 40 | */ |
41 | 41 | protected $deprecated_args = array( |
42 | - 'primary_arg_guid' => array( 'replacement' => 'signature_arg_guids', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
43 | - 'primary_arg_guid__compare' => array( 'replacement' => 'signature_arg_guids__compare', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
44 | - 'primary_arg_guid__in' => array( 'replacement' => 'signature_arg_guids__in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
45 | - 'primary_arg_guid__not_in' => array( 'replacement' => 'signature_arg_guids__not_in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
42 | + 'primary_arg_guid' => array('replacement' => 'signature_arg_guids', 'version' => '2.3.0', 'class' => __CLASS__), |
|
43 | + 'primary_arg_guid__compare' => array('replacement' => 'signature_arg_guids__compare', 'version' => '2.3.0', 'class' => __CLASS__), |
|
44 | + 'primary_arg_guid__in' => array('replacement' => 'signature_arg_guids__in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
45 | + 'primary_arg_guid__not_in' => array('replacement' => 'signature_arg_guids__not_in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | // |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @type array $meta_query See WP_Meta_Query. |
122 | 122 | * } |
123 | 123 | */ |
124 | - public function __construct( $args = array() ) { |
|
124 | + public function __construct($args = array()) { |
|
125 | 125 | |
126 | 126 | global $wpdb; |
127 | 127 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $this->defaults['order_by'] = 'date'; |
131 | 131 | |
132 | - parent::__construct( $args ); |
|
132 | + parent::__construct($args); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 |
@@ -231,24 +231,24 @@ discard block |
||
231 | 231 | * @type array $meta_query See WP_Meta_Query. |
232 | 232 | * } |
233 | 233 | */ |
234 | - public function __construct( $args = array() ) { |
|
234 | + public function __construct($args = array()) { |
|
235 | 235 | |
236 | - foreach ( $this->deprecated_args as $arg => $data ) { |
|
237 | - if ( isset( $args[ $arg ] ) ) { |
|
236 | + foreach ($this->deprecated_args as $arg => $data) { |
|
237 | + if (isset($args[$arg])) { |
|
238 | 238 | |
239 | 239 | _deprecated_argument( |
240 | - esc_html( "{$data['class']}::__construct" ) |
|
241 | - , esc_html( $data['version'] ) |
|
242 | - , esc_html( "{$arg} is deprecated, use {$data['replacement']} instead" ) |
|
240 | + esc_html("{$data['class']}::__construct") |
|
241 | + , esc_html($data['version']) |
|
242 | + , esc_html("{$arg} is deprecated, use {$data['replacement']} instead") |
|
243 | 243 | ); |
244 | 244 | |
245 | - $args[ $data['replacement'] ] = $args[ $arg ]; |
|
245 | + $args[$data['replacement']] = $args[$arg]; |
|
246 | 246 | |
247 | - unset( $args[ $arg ] ); |
|
247 | + unset($args[$arg]); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - $this->args = array_merge( $this->defaults, $args ); |
|
251 | + $this->args = array_merge($this->defaults, $args); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -260,21 +260,21 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return mixed|null The query arg's value, or null if it isn't set. |
262 | 262 | */ |
263 | - public function get_arg( $arg ) { |
|
263 | + public function get_arg($arg) { |
|
264 | 264 | |
265 | - if ( isset( $this->deprecated_args[ $arg ] ) ) { |
|
265 | + if (isset($this->deprecated_args[$arg])) { |
|
266 | 266 | |
267 | 267 | _deprecated_argument( |
268 | - esc_html( "{$this->deprecated_args[ $arg ]['class']}::get_arg" ) |
|
269 | - , esc_html( $this->deprecated_args[ $arg ]['version'] ) |
|
270 | - , esc_html( "{$arg} is deprecated, use {$this->deprecated_args[ $arg ]['replacement']} instead" ) |
|
268 | + esc_html("{$this->deprecated_args[$arg]['class']}::get_arg") |
|
269 | + , esc_html($this->deprecated_args[$arg]['version']) |
|
270 | + , esc_html("{$arg} is deprecated, use {$this->deprecated_args[$arg]['replacement']} instead") |
|
271 | 271 | ); |
272 | 272 | |
273 | - $arg = $this->deprecated_args[ $arg ]['replacement']; |
|
273 | + $arg = $this->deprecated_args[$arg]['replacement']; |
|
274 | 274 | } |
275 | 275 | |
276 | - if ( isset( $this->args[ $arg ] ) ) { |
|
277 | - return $this->args[ $arg ]; |
|
276 | + if (isset($this->args[$arg])) { |
|
277 | + return $this->args[$arg]; |
|
278 | 278 | } else { |
279 | 279 | return null; |
280 | 280 | } |
@@ -292,24 +292,24 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return WordPoints_DB_Query To allow for method chaining. |
294 | 294 | */ |
295 | - public function set_args( array $args ) { |
|
295 | + public function set_args(array $args) { |
|
296 | 296 | |
297 | - foreach ( $this->deprecated_args as $arg => $data ) { |
|
298 | - if ( isset( $args[ $arg ] ) ) { |
|
297 | + foreach ($this->deprecated_args as $arg => $data) { |
|
298 | + if (isset($args[$arg])) { |
|
299 | 299 | |
300 | 300 | _deprecated_argument( |
301 | - esc_html( "{$data['class']}::set_args" ) |
|
302 | - , esc_html( $data['version'] ) |
|
303 | - , esc_html( "{$arg} is deprecated, use {$data['replacement']} instead" ) |
|
301 | + esc_html("{$data['class']}::set_args") |
|
302 | + , esc_html($data['version']) |
|
303 | + , esc_html("{$arg} is deprecated, use {$data['replacement']} instead") |
|
304 | 304 | ); |
305 | 305 | |
306 | - $args[ $data['replacement'] ] = $args[ $arg ]; |
|
306 | + $args[$data['replacement']] = $args[$arg]; |
|
307 | 307 | |
308 | - unset( $args[ $arg ] ); |
|
308 | + unset($args[$arg]); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - $this->args = array_merge( $this->args, $args ); |
|
312 | + $this->args = array_merge($this->args, $args); |
|
313 | 313 | |
314 | 314 | $this->is_query_ready = false; |
315 | 315 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | global $wpdb; |
334 | 334 | |
335 | - $count = (int) $wpdb->get_var( $this->get_sql( 'SELECT COUNT' ) ); // WPCS: unprepared SQL, cache OK |
|
335 | + $count = (int) $wpdb->get_var($this->get_sql('SELECT COUNT')); // WPCS: unprepared SQL, cache OK |
|
336 | 336 | |
337 | 337 | return $count; |
338 | 338 | } |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @return mixed The results of the query, or false on failure. |
349 | 349 | */ |
350 | - public function get( $method = 'results' ) { |
|
350 | + public function get($method = 'results') { |
|
351 | 351 | |
352 | 352 | global $wpdb; |
353 | 353 | |
354 | - $methods = array( 'results', 'row', 'col', 'var' ); |
|
354 | + $methods = array('results', 'row', 'col', 'var'); |
|
355 | 355 | |
356 | - if ( ! in_array( $method, $methods ) ) { |
|
356 | + if ( ! in_array($method, $methods)) { |
|
357 | 357 | |
358 | - _doing_it_wrong( __METHOD__, esc_html( sprintf( 'WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode( ', ', $methods ) ) ), '1.0.0' ); |
|
358 | + _doing_it_wrong(__METHOD__, esc_html(sprintf('WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode(', ', $methods))), '1.0.0'); |
|
359 | 359 | |
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | - $result = $wpdb->{"get_{$method}"}( $this->get_sql() ); |
|
363 | + $result = $wpdb->{"get_{$method}"}($this->get_sql()); |
|
364 | 364 | |
365 | 365 | return $result; |
366 | 366 | } |
@@ -380,11 +380,11 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return string The SQL for the query. |
382 | 382 | */ |
383 | - public function get_sql( $select_type = 'SELECT' ) { |
|
383 | + public function get_sql($select_type = 'SELECT') { |
|
384 | 384 | |
385 | 385 | $this->prepare_query(); |
386 | 386 | |
387 | - $select = ( 'SELECT COUNT' === $select_type ) |
|
387 | + $select = ('SELECT COUNT' === $select_type) |
|
388 | 388 | ? $this->select_count |
389 | 389 | : $this->select; |
390 | 390 | |
@@ -412,12 +412,12 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return string[] The valid columns. |
414 | 414 | */ |
415 | - public function date_query_valid_columns_filter( $valid_columns ) { |
|
415 | + public function date_query_valid_columns_filter($valid_columns) { |
|
416 | 416 | |
417 | 417 | $valid_columns = array_merge( |
418 | 418 | $valid_columns |
419 | 419 | , array_keys( |
420 | - wp_list_filter( $this->columns, array( 'is_date' => true ) ) |
|
420 | + wp_list_filter($this->columns, array('is_date' => true)) |
|
421 | 421 | ) |
422 | 422 | ); |
423 | 423 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | protected function prepare_query() { |
437 | 437 | |
438 | - if ( ! $this->is_query_ready ) { |
|
438 | + if ( ! $this->is_query_ready) { |
|
439 | 439 | |
440 | 440 | $this->prepare_select(); |
441 | 441 | $this->prepare_where(); |
@@ -453,26 +453,26 @@ discard block |
||
453 | 453 | */ |
454 | 454 | protected function prepare_select() { |
455 | 455 | |
456 | - $all_fields = array_keys( $this->columns ); |
|
456 | + $all_fields = array_keys($this->columns); |
|
457 | 457 | $fields = array(); |
458 | 458 | |
459 | - if ( ! empty( $this->args['fields'] ) ) { |
|
459 | + if ( ! empty($this->args['fields'])) { |
|
460 | 460 | |
461 | 461 | $fields = (array) $this->args['fields']; |
462 | - $diff = array_diff( $fields, $all_fields ); |
|
463 | - $fields = array_intersect( $all_fields, $fields ); |
|
462 | + $diff = array_diff($fields, $all_fields); |
|
463 | + $fields = array_intersect($all_fields, $fields); |
|
464 | 464 | |
465 | - if ( ! empty( $diff ) ) { |
|
466 | - _doing_it_wrong( __METHOD__, esc_html( 'WordPoints Debug Error: invalid field(s) "' . implode( '", "', $diff ) . '" given' ), '1.0.0' ); |
|
465 | + if ( ! empty($diff)) { |
|
466 | + _doing_it_wrong(__METHOD__, esc_html('WordPoints Debug Error: invalid field(s) "' . implode('", "', $diff) . '" given'), '1.0.0'); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | 470 | // Pull all fields by default. |
471 | - if ( empty( $fields ) ) { |
|
471 | + if (empty($fields)) { |
|
472 | 472 | $fields = $all_fields; |
473 | 473 | } |
474 | 474 | |
475 | - $fields = implode( ', ', array_map( 'wordpoints_escape_mysql_identifier', $fields ) ); |
|
475 | + $fields = implode(', ', array_map('wordpoints_escape_mysql_identifier', $fields)); |
|
476 | 476 | |
477 | 477 | $this->select = "SELECT {$fields}"; |
478 | 478 | } |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return mixed The validated value, or false if invalid. |
489 | 489 | */ |
490 | - protected function validate_value( $value, $validators ) { |
|
490 | + protected function validate_value($value, $validators) { |
|
491 | 491 | |
492 | - foreach ( $validators as $validator ) { |
|
492 | + foreach ($validators as $validator) { |
|
493 | 493 | |
494 | - $value = call_user_func_array( $validator, array( &$value ) ); |
|
494 | + $value = call_user_func_array($validator, array(&$value)); |
|
495 | 495 | |
496 | - if ( false === $value ) { |
|
496 | + if (false === $value) { |
|
497 | 497 | break; |
498 | 498 | } |
499 | 499 | } |
@@ -511,14 +511,14 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return array The validated values, with any invalid ones removed. |
513 | 513 | */ |
514 | - protected function validate_values( $values, $validators ) { |
|
514 | + protected function validate_values($values, $validators) { |
|
515 | 515 | |
516 | - foreach ( $values as $index => $value ) { |
|
516 | + foreach ($values as $index => $value) { |
|
517 | 517 | |
518 | - $value = $this->validate_value( $value, $validators ); |
|
518 | + $value = $this->validate_value($value, $validators); |
|
519 | 519 | |
520 | - if ( false === $value ) { |
|
521 | - unset( $values[ $index ] ); |
|
520 | + if (false === $value) { |
|
521 | + unset($values[$index]); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return int|false The validated value or false. |
539 | 539 | */ |
540 | - protected function validate_unsigned_column( $value ) { |
|
540 | + protected function validate_unsigned_column($value) { |
|
541 | 541 | |
542 | - if ( false !== wordpoints_int( $value ) && $value >= 0 ) { |
|
542 | + if (false !== wordpoints_int($value) && $value >= 0) { |
|
543 | 543 | return $value; |
544 | 544 | } |
545 | 545 | |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | * |
556 | 556 | * @return callable[] The validation functions. |
557 | 557 | */ |
558 | - protected function get_validators_for_column( $data ) { |
|
558 | + protected function get_validators_for_column($data) { |
|
559 | 559 | |
560 | 560 | $validators = array(); |
561 | 561 | |
562 | 562 | // Default validators for integer columns. |
563 | - if ( '%d' === $data['format'] ) { |
|
564 | - if ( ! empty( $data['unsigned'] ) ) { |
|
565 | - $validators[] = array( $this, 'validate_unsigned_column' ); |
|
563 | + if ('%d' === $data['format']) { |
|
564 | + if ( ! empty($data['unsigned'])) { |
|
565 | + $validators[] = array($this, 'validate_unsigned_column'); |
|
566 | 566 | } else { |
567 | 567 | $validators[] = 'wordpoints_int'; |
568 | 568 | } |
@@ -579,15 +579,15 @@ discard block |
||
579 | 579 | * @param string $column The column name. |
580 | 580 | * @param array $data The column data. |
581 | 581 | */ |
582 | - protected function prepare_column_where( $column, $data ) { |
|
582 | + protected function prepare_column_where($column, $data) { |
|
583 | 583 | |
584 | 584 | // If a single value has been supplied for the column, it takes precedence. |
585 | - if ( isset( $this->args[ $column ] ) ) { |
|
586 | - $this->prepare_column( $column, $data ); |
|
587 | - } elseif ( isset( $this->args[ "{$column}__in" ] ) ) { |
|
588 | - $this->prepare_column__in( $column, $data ); |
|
589 | - } elseif ( isset( $this->args[ "{$column}__not_in" ] ) ) { |
|
590 | - $this->prepare_column__in( $column, $data, 'NOT IN' ); |
|
585 | + if (isset($this->args[$column])) { |
|
586 | + $this->prepare_column($column, $data); |
|
587 | + } elseif (isset($this->args["{$column}__in"])) { |
|
588 | + $this->prepare_column__in($column, $data); |
|
589 | + } elseif (isset($this->args["{$column}__not_in"])) { |
|
590 | + $this->prepare_column__in($column, $data, 'NOT IN'); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
@@ -599,29 +599,29 @@ discard block |
||
599 | 599 | * @param string $column The name of the column |
600 | 600 | * @param array $data The column data. |
601 | 601 | */ |
602 | - protected function prepare_column( $column, $data ) { |
|
602 | + protected function prepare_column($column, $data) { |
|
603 | 603 | |
604 | 604 | global $wpdb; |
605 | 605 | |
606 | 606 | if ( |
607 | - isset( $data['values'] ) |
|
608 | - && ! in_array( $this->args[ $column ], $data['values'], true ) |
|
607 | + isset($data['values']) |
|
608 | + && ! in_array($this->args[$column], $data['values'], true) |
|
609 | 609 | ) { |
610 | 610 | return; |
611 | 611 | } |
612 | 612 | |
613 | 613 | $value = $this->validate_value( |
614 | - $this->args[ $column ] |
|
615 | - , $this->get_validators_for_column( $data ) |
|
614 | + $this->args[$column] |
|
615 | + , $this->get_validators_for_column($data) |
|
616 | 616 | ); |
617 | 617 | |
618 | - if ( false === $value ) { |
|
618 | + if (false === $value) { |
|
619 | 619 | return; |
620 | 620 | } |
621 | 621 | |
622 | - $compare = $this->get_comparator_for_column( $column, $data ); |
|
622 | + $compare = $this->get_comparator_for_column($column, $data); |
|
623 | 623 | |
624 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
624 | + $column = wordpoints_escape_mysql_identifier($column); |
|
625 | 625 | |
626 | 626 | $this->wheres[] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
627 | 627 | "{$column} {$compare} {$data['format']}" |
@@ -639,23 +639,23 @@ discard block |
||
639 | 639 | * |
640 | 640 | * @return string The comparator for the column. |
641 | 641 | */ |
642 | - protected function get_comparator_for_column( $column, $data ) { |
|
642 | + protected function get_comparator_for_column($column, $data) { |
|
643 | 643 | |
644 | - $comparisons = array( '=', '<', '>', '<>', '!=', '<=', '>=' ); |
|
644 | + $comparisons = array('=', '<', '>', '<>', '!=', '<=', '>='); |
|
645 | 645 | |
646 | 646 | // MySQL doesn't support LIKE and NOT LIKE for int columns. |
647 | 647 | // See https://stackoverflow.com/q/8422455/1924128 |
648 | - if ( '%s' === $data['format'] ) { |
|
649 | - $comparisons = array_merge( $comparisons, array( 'LIKE', 'NOT LIKE' ) ); |
|
648 | + if ('%s' === $data['format']) { |
|
649 | + $comparisons = array_merge($comparisons, array('LIKE', 'NOT LIKE')); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | $comparator = '='; |
653 | 653 | |
654 | 654 | if ( |
655 | - isset( $this->args[ "{$column}__compare" ] ) |
|
656 | - && in_array( $this->args[ "{$column}__compare" ], $comparisons, true ) |
|
655 | + isset($this->args["{$column}__compare"]) |
|
656 | + && in_array($this->args["{$column}__compare"], $comparisons, true) |
|
657 | 657 | ) { |
658 | - $comparator = $this->args[ "{$column}__compare" ]; |
|
658 | + $comparator = $this->args["{$column}__compare"]; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | return $comparator; |
@@ -670,36 +670,36 @@ discard block |
||
670 | 670 | * @param array $data The column data. |
671 | 671 | * @param string $type The type of IN clause, IN or NOT IN. |
672 | 672 | */ |
673 | - protected function prepare_column__in( $column, $data, $type = 'IN' ) { |
|
673 | + protected function prepare_column__in($column, $data, $type = 'IN') { |
|
674 | 674 | |
675 | - $key = "{$column}__" . strtolower( str_replace( ' ', '_', $type ) ); |
|
675 | + $key = "{$column}__" . strtolower(str_replace(' ', '_', $type)); |
|
676 | 676 | |
677 | - if ( empty( $this->args[ $key ] ) || ! is_array( $this->args[ $key ] ) ) { |
|
677 | + if (empty($this->args[$key]) || ! is_array($this->args[$key])) { |
|
678 | 678 | return; |
679 | 679 | } |
680 | 680 | |
681 | - $values = $this->args[ $key ]; |
|
681 | + $values = $this->args[$key]; |
|
682 | 682 | |
683 | - if ( isset( $data['values'] ) ) { |
|
684 | - $values = array_intersect( $values, $data['values'] ); |
|
683 | + if (isset($data['values'])) { |
|
684 | + $values = array_intersect($values, $data['values']); |
|
685 | 685 | } else { |
686 | 686 | $values = $this->validate_values( |
687 | 687 | $values |
688 | - , $this->get_validators_for_column( $data ) |
|
688 | + , $this->get_validators_for_column($data) |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | |
692 | - if ( empty( $values ) ) { |
|
692 | + if (empty($values)) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | - $in = wordpoints_prepare__in( $values, $data['format'] ); |
|
696 | + $in = wordpoints_prepare__in($values, $data['format']); |
|
697 | 697 | |
698 | - if ( false === $in ) { |
|
698 | + if (false === $in) { |
|
699 | 699 | return; |
700 | 700 | } |
701 | 701 | |
702 | - $column = wordpoints_escape_mysql_identifier( $column ); |
|
702 | + $column = wordpoints_escape_mysql_identifier($column); |
|
703 | 703 | |
704 | 704 | $this->wheres[] = "{$column} {$type} ({$in})"; |
705 | 705 | } |
@@ -713,19 +713,19 @@ discard block |
||
713 | 713 | |
714 | 714 | $this->wheres = array(); |
715 | 715 | |
716 | - foreach ( $this->columns as $column => $data ) { |
|
716 | + foreach ($this->columns as $column => $data) { |
|
717 | 717 | |
718 | - if ( ! empty( $data['is_date'] ) ) { |
|
719 | - $this->prepare_date_where( $column ); |
|
718 | + if ( ! empty($data['is_date'])) { |
|
719 | + $this->prepare_date_where($column); |
|
720 | 720 | } else { |
721 | - $this->prepare_column_where( $column, $data ); |
|
721 | + $this->prepare_column_where($column, $data); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | $this->prepare_meta_where(); |
726 | 726 | |
727 | - if ( ! empty( $this->wheres ) ) { |
|
728 | - $this->where = 'WHERE ' . implode( ' AND ', $this->wheres ) . "\n"; |
|
727 | + if ( ! empty($this->wheres)) { |
|
728 | + $this->where = 'WHERE ' . implode(' AND ', $this->wheres) . "\n"; |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
@@ -738,32 +738,32 @@ discard block |
||
738 | 738 | |
739 | 739 | // MySQL doesn't allow for the offset without a limit, so if no limit is set |
740 | 740 | // we can ignore the start arg. See https://stackoverflow.com/a/271650/1924128 |
741 | - if ( ! isset( $this->args['limit'] ) ) { |
|
741 | + if ( ! isset($this->args['limit'])) { |
|
742 | 742 | return; |
743 | 743 | } |
744 | 744 | |
745 | - foreach ( array( 'limit', 'start' ) as $key ) { |
|
745 | + foreach (array('limit', 'start') as $key) { |
|
746 | 746 | |
747 | 747 | // Save a backup of the arg value since wordpoints_int() is by reference. |
748 | - $arg = $this->args[ $key ]; |
|
748 | + $arg = $this->args[$key]; |
|
749 | 749 | |
750 | - if ( false === wordpoints_int( $this->args[ $key ] ) ) { |
|
750 | + if (false === wordpoints_int($this->args[$key])) { |
|
751 | 751 | |
752 | 752 | _doing_it_wrong( |
753 | 753 | __METHOD__ |
754 | 754 | , sprintf( |
755 | 755 | "WordPoints Debug Error: '%s' must be a positive integer, %s given" |
756 | - , esc_html( $key ) |
|
757 | - , esc_html( strval( $arg ) ? $arg : gettype( $arg ) ) |
|
756 | + , esc_html($key) |
|
757 | + , esc_html(strval($arg) ? $arg : gettype($arg)) |
|
758 | 758 | ) |
759 | 759 | , '1.0.0' |
760 | 760 | ); |
761 | 761 | |
762 | - $this->args[ $key ] = 0; |
|
762 | + $this->args[$key] = 0; |
|
763 | 763 | } |
764 | 764 | } |
765 | 765 | |
766 | - if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
|
766 | + if ($this->args['limit'] > 0 && $this->args['start'] >= 0) { |
|
767 | 767 | $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
768 | 768 | } |
769 | 769 | } |
@@ -775,20 +775,20 @@ discard block |
||
775 | 775 | */ |
776 | 776 | protected function prepare_order_by() { |
777 | 777 | |
778 | - if ( empty( $this->args['order_by'] ) ) { |
|
778 | + if (empty($this->args['order_by'])) { |
|
779 | 779 | return; |
780 | 780 | } |
781 | 781 | |
782 | 782 | $order = $this->args['order']; |
783 | 783 | $order_by = $this->args['order_by']; |
784 | 784 | |
785 | - if ( ! in_array( $order, array( 'DESC', 'ASC' ) ) ) { |
|
785 | + if ( ! in_array($order, array('DESC', 'ASC'))) { |
|
786 | 786 | |
787 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC" ), '1.0.0' ); |
|
787 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC"), '1.0.0'); |
|
788 | 788 | $order = 'DESC'; |
789 | 789 | } |
790 | 790 | |
791 | - if ( 'meta_value' === $order_by ) { |
|
791 | + if ('meta_value' === $order_by) { |
|
792 | 792 | |
793 | 793 | global $wpdb; |
794 | 794 | |
@@ -796,9 +796,9 @@ discard block |
||
796 | 796 | $wpdb->{"{$this->meta_type}meta"} |
797 | 797 | ); |
798 | 798 | |
799 | - if ( isset( $this->args['meta_type'] ) ) { |
|
799 | + if (isset($this->args['meta_type'])) { |
|
800 | 800 | |
801 | - $meta_type = $this->meta_query->get_cast_for_type( $this->args['meta_type'] ); |
|
801 | + $meta_type = $this->meta_query->get_cast_for_type($this->args['meta_type']); |
|
802 | 802 | $order_by = "CAST({$meta_table_name}.meta_value AS {$meta_type})"; |
803 | 803 | |
804 | 804 | } else { |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | $order_by = "{$meta_table_name}.meta_value"; |
807 | 807 | } |
808 | 808 | |
809 | - } elseif ( isset( $this->columns[ $order_by ] ) ) { |
|
809 | + } elseif (isset($this->columns[$order_by])) { |
|
810 | 810 | |
811 | - $order_by = wordpoints_escape_mysql_identifier( $order_by ); |
|
811 | + $order_by = wordpoints_escape_mysql_identifier($order_by); |
|
812 | 812 | |
813 | 813 | } else { |
814 | 814 | |
815 | - _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' ); |
|
815 | + _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'); |
|
816 | 816 | return; |
817 | 817 | } |
818 | 818 | |
@@ -826,25 +826,25 @@ discard block |
||
826 | 826 | * |
827 | 827 | * @param string $column The name of the column. |
828 | 828 | */ |
829 | - protected function prepare_date_where( $column ) { |
|
829 | + protected function prepare_date_where($column) { |
|
830 | 830 | |
831 | 831 | if ( |
832 | - empty( $this->args[ "{$column}_query" ] ) |
|
833 | - || ! is_array( $this->args[ "{$column}_query" ] ) |
|
832 | + empty($this->args["{$column}_query"]) |
|
833 | + || ! is_array($this->args["{$column}_query"]) |
|
834 | 834 | ) { |
835 | 835 | return; |
836 | 836 | } |
837 | 837 | |
838 | - add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
838 | + add_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
839 | 839 | |
840 | - $date_query = new WP_Date_Query( $this->args[ "{$column}_query" ], $column ); |
|
840 | + $date_query = new WP_Date_Query($this->args["{$column}_query"], $column); |
|
841 | 841 | $date_query = $date_query->get_sql(); |
842 | 842 | |
843 | - if ( ! empty( $date_query ) ) { |
|
844 | - $this->wheres[] = ltrim( $date_query, ' AND' ); |
|
843 | + if ( ! empty($date_query)) { |
|
844 | + $this->wheres[] = ltrim($date_query, ' AND'); |
|
845 | 845 | } |
846 | 846 | |
847 | - remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
847 | + remove_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | */ |
855 | 855 | protected function prepare_meta_where() { |
856 | 856 | |
857 | - if ( empty( $this->meta_type ) ) { |
|
857 | + if (empty($this->meta_type)) { |
|
858 | 858 | return; |
859 | 859 | } |
860 | 860 | |
@@ -869,12 +869,12 @@ discard block |
||
869 | 869 | ) |
870 | 870 | ); |
871 | 871 | |
872 | - if ( empty( $meta_args ) ) { |
|
872 | + if (empty($meta_args)) { |
|
873 | 873 | return; |
874 | 874 | } |
875 | 875 | |
876 | 876 | $this->meta_query = new WP_Meta_Query(); |
877 | - $this->meta_query->parse_query_vars( $meta_args ); |
|
877 | + $this->meta_query->parse_query_vars($meta_args); |
|
878 | 878 | |
879 | 879 | $meta_query = $this->meta_query->get_sql( |
880 | 880 | $this->meta_type |
@@ -883,8 +883,8 @@ discard block |
||
883 | 883 | , $this |
884 | 884 | ); |
885 | 885 | |
886 | - if ( ! empty( $meta_query['where'] ) ) { |
|
887 | - $this->wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
886 | + if ( ! empty($meta_query['where'])) { |
|
887 | + $this->wheres[] = ltrim($meta_query['where'], ' AND'); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | $this->meta_join = $meta_query['join'] . "\n"; |
@@ -17,62 +17,62 @@ discard block |
||
17 | 17 | // Show messages and errors. |
18 | 18 | // |
19 | 19 | |
20 | -if ( isset( $_GET['wordpoints_component'], $_GET['_wpnonce'] ) && $wordpoints_components->is_registered( sanitize_key( $_GET['wordpoints_component'] ) ) ) { |
|
20 | +if (isset($_GET['wordpoints_component'], $_GET['_wpnonce']) && $wordpoints_components->is_registered(sanitize_key($_GET['wordpoints_component']))) { |
|
21 | 21 | |
22 | - $component = sanitize_key( $_GET['wordpoints_component'] ); |
|
22 | + $component = sanitize_key($_GET['wordpoints_component']); |
|
23 | 23 | |
24 | - if ( isset( $_GET['message'] ) && wordpoints_verify_nonce( '_wpnonce', "wordpoints_component_message-{$component}" ) ) { |
|
24 | + if (isset($_GET['message']) && wordpoints_verify_nonce('_wpnonce', "wordpoints_component_message-{$component}")) { |
|
25 | 25 | |
26 | - switch ( (int) $_GET['message'] ) { |
|
26 | + switch ((int) $_GET['message']) { |
|
27 | 27 | |
28 | 28 | case 1: |
29 | - if ( $wordpoints_components->is_active( $component ) ) { |
|
29 | + if ($wordpoints_components->is_active($component)) { |
|
30 | 30 | // translators: Component name. |
31 | - $message = __( 'Component “%s” activated!', 'wordpoints' ); |
|
31 | + $message = __('Component “%s” activated!', 'wordpoints'); |
|
32 | 32 | } |
33 | 33 | break; |
34 | 34 | |
35 | 35 | case 2: |
36 | - if ( ! $wordpoints_components->is_active( $component ) ) { |
|
36 | + if ( ! $wordpoints_components->is_active($component)) { |
|
37 | 37 | // translators: Component name. |
38 | - $message = __( 'Component “%s” deactivated!', 'wordpoints' ); |
|
38 | + $message = __('Component “%s” deactivated!', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | break; |
41 | 41 | } |
42 | 42 | |
43 | - if ( isset( $message ) ) { |
|
43 | + if (isset($message)) { |
|
44 | 44 | |
45 | 45 | wordpoints_show_admin_message( |
46 | - esc_html( sprintf( $message, $components[ $component ]['name'] ) ) |
|
46 | + esc_html(sprintf($message, $components[$component]['name'])) |
|
47 | 47 | , 'success' |
48 | - , array( 'dismissible' => true ) |
|
48 | + , array('dismissible' => true) |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - } elseif ( isset( $_GET['error'] ) && wordpoints_verify_nonce( '_wpnonce', "wordpoints_component_error-{$component}" ) ) { |
|
52 | + } elseif (isset($_GET['error']) && wordpoints_verify_nonce('_wpnonce', "wordpoints_component_error-{$component}")) { |
|
53 | 53 | |
54 | - switch ( (int) $_GET['error'] ) { |
|
54 | + switch ((int) $_GET['error']) { |
|
55 | 55 | |
56 | 56 | case 1: |
57 | - if ( ! $wordpoints_components->is_active( $component ) ) { |
|
57 | + if ( ! $wordpoints_components->is_active($component)) { |
|
58 | 58 | // translators: Component name. |
59 | - $error = __( 'The component “%s” could not be activated. Please try again.', 'wordpoints' ); |
|
59 | + $error = __('The component “%s” could not be activated. Please try again.', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | break; |
62 | 62 | |
63 | 63 | case 2: |
64 | - if ( $wordpoints_components->is_active( $component ) ) { |
|
64 | + if ($wordpoints_components->is_active($component)) { |
|
65 | 65 | // translators: Component name. |
66 | - $error = __( 'The component “%s” could not be deactivated. Please try again.', 'wordpoints' ); |
|
66 | + $error = __('The component “%s” could not be deactivated. Please try again.', 'wordpoints'); |
|
67 | 67 | } |
68 | 68 | break; |
69 | 69 | } |
70 | 70 | |
71 | - if ( isset( $error ) ) { |
|
71 | + if (isset($error)) { |
|
72 | 72 | |
73 | 73 | wordpoints_show_admin_error( |
74 | - esc_html( sprintf( $error, $components[ $component ]['name'] ) ) |
|
75 | - , array( 'dismissible' => true ) |
|
74 | + esc_html(sprintf($error, $components[$component]['name'])) |
|
75 | + , array('dismissible' => true) |
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | } // End if ( message ) elseif ( error ). |
@@ -88,74 +88,74 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @since 1.0.0 |
90 | 90 | */ |
91 | -do_action( 'wordpoints_admin_components_top' ); |
|
91 | +do_action('wordpoints_admin_components_top'); |
|
92 | 92 | |
93 | 93 | ?> |
94 | 94 | |
95 | 95 | <br /> |
96 | 96 | <table id="wordpoints_components_table" class="widefat"> |
97 | - <caption><?php esc_html_e( 'Installed WordPoints components.', 'wordpoints' ); ?></caption> |
|
97 | + <caption><?php esc_html_e('Installed WordPoints components.', 'wordpoints'); ?></caption> |
|
98 | 98 | <thead> |
99 | 99 | <tr> |
100 | - <th scope="col"><?php echo esc_html_x( 'Component', 'components table heading', 'wordpoints' ); ?></th> |
|
101 | - <th scope="col"><?php echo esc_html_x( 'Description', 'components table heading', 'wordpoints' ); ?></th> |
|
102 | - <th scope="col"><?php echo esc_html_x( 'Version', 'components table heading', 'wordpoints' ); ?></th> |
|
103 | - <th scope="col"><?php echo esc_html_x( 'Action', 'components table heading', 'wordpoints' ); ?></th> |
|
100 | + <th scope="col"><?php echo esc_html_x('Component', 'components table heading', 'wordpoints'); ?></th> |
|
101 | + <th scope="col"><?php echo esc_html_x('Description', 'components table heading', 'wordpoints'); ?></th> |
|
102 | + <th scope="col"><?php echo esc_html_x('Version', 'components table heading', 'wordpoints'); ?></th> |
|
103 | + <th scope="col"><?php echo esc_html_x('Action', 'components table heading', 'wordpoints'); ?></th> |
|
104 | 104 | </tr> |
105 | 105 | </thead> |
106 | 106 | |
107 | 107 | <tbody> |
108 | - <?php foreach ( $components as $component ) : ?> |
|
108 | + <?php foreach ($components as $component) : ?> |
|
109 | 109 | |
110 | 110 | <?php |
111 | 111 | |
112 | - if ( $wordpoints_components->is_active( $component['slug'] ) ) { |
|
112 | + if ($wordpoints_components->is_active($component['slug'])) { |
|
113 | 113 | |
114 | 114 | $action = 'deactivate'; |
115 | - $button = __( 'Deactivate', 'wordpoints' ); |
|
115 | + $button = __('Deactivate', 'wordpoints'); |
|
116 | 116 | |
117 | 117 | } else { |
118 | 118 | |
119 | 119 | $action = 'activate'; |
120 | - $button = __( 'Activate', 'wordpoints' ); |
|
120 | + $button = __('Activate', 'wordpoints'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | ?> |
124 | 124 | |
125 | 125 | <tr> |
126 | 126 | <td> |
127 | - <?php if ( '' !== $component['component_uri'] ) : ?> |
|
128 | - <a href="<?php echo esc_url( $component['component_uri'] ); ?>"> |
|
127 | + <?php if ('' !== $component['component_uri']) : ?> |
|
128 | + <a href="<?php echo esc_url($component['component_uri']); ?>"> |
|
129 | 129 | <?php endif; ?> |
130 | - <?php echo esc_html( $component['name'] ); ?> |
|
131 | - <?php if ( '' !== $component['component_uri'] ) : ?> |
|
130 | + <?php echo esc_html($component['name']); ?> |
|
131 | + <?php if ('' !== $component['component_uri']) : ?> |
|
132 | 132 | </a> |
133 | 133 | <?php endif; ?> |
134 | 134 | </td> |
135 | 135 | <td> |
136 | - <?php echo wp_kses( $component['description'], 'wordpoints_component_description' ); ?> |
|
137 | - <?php if ( '' !== $component['author'] ) : ?> |
|
136 | + <?php echo wp_kses($component['description'], 'wordpoints_component_description'); ?> |
|
137 | + <?php if ('' !== $component['author']) : ?> |
|
138 | 138 | | |
139 | 139 | <?php |
140 | 140 | // translators: Author name. |
141 | - echo esc_html( sprintf( __( 'By %s', 'wordpoints' ), '' /* This space intentionally left blank */ ) ); |
|
141 | + echo esc_html(sprintf(__('By %s', 'wordpoints'), '' /* This space intentionally left blank */)); |
|
142 | 142 | ?> |
143 | - <?php if ( '' !== $component['author_uri'] ) : ?> |
|
144 | - <a href="<?php echo esc_url( $component['author_uri'] ); ?>"> |
|
143 | + <?php if ('' !== $component['author_uri']) : ?> |
|
144 | + <a href="<?php echo esc_url($component['author_uri']); ?>"> |
|
145 | 145 | <?php endif; ?> |
146 | - <?php echo esc_html( $component['author'] ); ?> |
|
147 | - <?php if ( '' !== $component['author_uri'] ) : ?> |
|
146 | + <?php echo esc_html($component['author']); ?> |
|
147 | + <?php if ('' !== $component['author_uri']) : ?> |
|
148 | 148 | </a> |
149 | 149 | <?php endif; ?> |
150 | 150 | <?php endif; ?> |
151 | 151 | </td> |
152 | - <td><?php echo esc_html( $component['version'] ); ?></td> |
|
152 | + <td><?php echo esc_html($component['version']); ?></td> |
|
153 | 153 | <td> |
154 | - <form method="post" name="wordpoints_components_form_<?php echo esc_attr( $component['slug'] ); ?>"> |
|
155 | - <input type="hidden" name="wordpoints_component_action" value="<?php echo esc_attr( $action ); ?>" /> |
|
156 | - <input type="hidden" name="wordpoints_component" value="<?php echo esc_attr( $component['slug'] ); ?>" /> |
|
157 | - <?php wp_nonce_field( "wordpoints_{$action}_component-{$component['slug']}" ); ?> |
|
158 | - <?php submit_button( $button, "secondary wordpoints-component-{$action}", "wordpoints-component-{$action}_{$component['slug']}", false ); ?> |
|
154 | + <form method="post" name="wordpoints_components_form_<?php echo esc_attr($component['slug']); ?>"> |
|
155 | + <input type="hidden" name="wordpoints_component_action" value="<?php echo esc_attr($action); ?>" /> |
|
156 | + <input type="hidden" name="wordpoints_component" value="<?php echo esc_attr($component['slug']); ?>" /> |
|
157 | + <?php wp_nonce_field("wordpoints_{$action}_component-{$component['slug']}"); ?> |
|
158 | + <?php submit_button($button, "secondary wordpoints-component-{$action}", "wordpoints-component-{$action}_{$component['slug']}", false); ?> |
|
159 | 159 | </form> |
160 | 160 | </td> |
161 | 161 | </tr> |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | |
166 | 166 | <tfoot> |
167 | 167 | <tr> |
168 | - <th scope="col"><?php echo esc_html_x( 'Component', 'components table heading', 'wordpoints' ); ?></th> |
|
169 | - <th scope="col"><?php echo esc_html_x( 'Description', 'components table heading', 'wordpoints' ); ?></th> |
|
170 | - <th scope="col"><?php echo esc_html_x( 'Version', 'components table heading', 'wordpoints' ); ?></th> |
|
171 | - <th scope="col"><?php echo esc_html_x( 'Action', 'components table heading', 'wordpoints' ); ?></th> |
|
168 | + <th scope="col"><?php echo esc_html_x('Component', 'components table heading', 'wordpoints'); ?></th> |
|
169 | + <th scope="col"><?php echo esc_html_x('Description', 'components table heading', 'wordpoints'); ?></th> |
|
170 | + <th scope="col"><?php echo esc_html_x('Version', 'components table heading', 'wordpoints'); ?></th> |
|
171 | + <th scope="col"><?php echo esc_html_x('Action', 'components table heading', 'wordpoints'); ?></th> |
|
172 | 172 | </tr> |
173 | 173 | </tfoot> |
174 | 174 | </table> |
@@ -180,6 +180,6 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @since 1.0.0 |
182 | 182 | */ |
183 | -do_action( 'wordpoints_admin_components_bottom' ); |
|
183 | +do_action('wordpoints_admin_components_bottom'); |
|
184 | 184 | |
185 | 185 | // EOF |
@@ -9,56 +9,56 @@ discard block |
||
9 | 9 | |
10 | 10 | global $status, $wp_version; |
11 | 11 | |
12 | -if ( isset( $_POST['clear-recent-list'] ) ) { |
|
12 | +if (isset($_POST['clear-recent-list'])) { |
|
13 | 13 | $action = 'clear-recent-list'; |
14 | -} elseif ( isset( $_REQUEST['action'] ) && -1 !== (int) $_REQUEST['action'] ) { |
|
15 | - $action = sanitize_key( $_REQUEST['action'] ); |
|
16 | -} elseif ( isset( $_REQUEST['action2'] ) && -1 !== (int) $_REQUEST['action2'] ) { |
|
17 | - $action = sanitize_key( $_REQUEST['action2'] ); |
|
14 | +} elseif (isset($_REQUEST['action']) && -1 !== (int) $_REQUEST['action']) { |
|
15 | + $action = sanitize_key($_REQUEST['action']); |
|
16 | +} elseif (isset($_REQUEST['action2']) && -1 !== (int) $_REQUEST['action2']) { |
|
17 | + $action = sanitize_key($_REQUEST['action2']); |
|
18 | 18 | } else { |
19 | 19 | $action = ''; |
20 | 20 | } |
21 | 21 | |
22 | -$page = ( isset( $_REQUEST['paged'] ) ) ? max( 1, absint( $_REQUEST['paged'] ) ) : 1; |
|
23 | -$module = ( isset( $_REQUEST['module'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['module'] ) ) : ''; |
|
24 | -$s = ( isset( $_REQUEST['s'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
22 | +$page = (isset($_REQUEST['paged'])) ? max(1, absint($_REQUEST['paged'])) : 1; |
|
23 | +$module = (isset($_REQUEST['module'])) ? sanitize_text_field(wp_unslash($_REQUEST['module'])) : ''; |
|
24 | +$s = (isset($_REQUEST['s'])) ? sanitize_text_field(wp_unslash($_REQUEST['s'])) : ''; |
|
25 | 25 | |
26 | 26 | // Clean up request URI from temporary args for screen options/paging URI's to work as expected. |
27 | -$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce' ) ); |
|
27 | +$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce')); |
|
28 | 28 | |
29 | -$redirect_url = self_admin_url( "admin.php?page=wordpoints_modules&module_status={$status}&paged={$page}&s={$s}" ); |
|
29 | +$redirect_url = self_admin_url("admin.php?page=wordpoints_modules&module_status={$status}&paged={$page}&s={$s}"); |
|
30 | 30 | |
31 | -switch ( $action ) { |
|
31 | +switch ($action) { |
|
32 | 32 | |
33 | 33 | case '': break; |
34 | 34 | |
35 | 35 | // Activate a single module. |
36 | 36 | case 'activate': |
37 | - if ( ! current_user_can( 'activate_wordpoints_modules' ) ) { |
|
38 | - wp_die( esc_html__( 'Sorry, you are not allowed to activate modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
37 | + if ( ! current_user_can('activate_wordpoints_modules')) { |
|
38 | + wp_die(esc_html__('Sorry, you are not allowed to activate modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( is_multisite() && ! is_network_admin() && is_network_only_wordpoints_module( $module ) ) { |
|
41 | + if (is_multisite() && ! is_network_admin() && is_network_only_wordpoints_module($module)) { |
|
42 | 42 | |
43 | - wp_safe_redirect( $redirect_url ); |
|
43 | + wp_safe_redirect($redirect_url); |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | - check_admin_referer( 'activate-module_' . $module ); |
|
47 | + check_admin_referer('activate-module_' . $module); |
|
48 | 48 | |
49 | - $result = wordpoints_activate_module( $module, self_admin_url( 'admin.php?page=wordpoints_modules&error=true&module=' . $module ), is_network_admin() ); |
|
49 | + $result = wordpoints_activate_module($module, self_admin_url('admin.php?page=wordpoints_modules&error=true&module=' . $module), is_network_admin()); |
|
50 | 50 | |
51 | - if ( is_wp_error( $result ) ) { |
|
51 | + if (is_wp_error($result)) { |
|
52 | 52 | |
53 | - if ( 'unexpected_output' === $result->get_error_code() ) { |
|
53 | + if ('unexpected_output' === $result->get_error_code()) { |
|
54 | 54 | |
55 | 55 | wp_safe_redirect( |
56 | 56 | add_query_arg( |
57 | 57 | array( |
58 | - '_error_nonce' => wp_create_nonce( 'module-activation-error_' . $module ), |
|
58 | + '_error_nonce' => wp_create_nonce('module-activation-error_' . $module), |
|
59 | 59 | 'module' => $module, |
60 | 60 | 'error' => true, |
61 | - 'charsout' => strlen( $result->get_error_data() ), |
|
61 | + 'charsout' => strlen($result->get_error_data()), |
|
62 | 62 | ) |
63 | 63 | , $redirect_url |
64 | 64 | ) |
@@ -68,96 +68,96 @@ discard block |
||
68 | 68 | |
69 | 69 | } else { |
70 | 70 | |
71 | - wp_die( wordpoints_sanitize_wp_error( $result ) ); |
|
71 | + wp_die(wordpoints_sanitize_wp_error($result)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ( ! is_network_admin() ) { |
|
75 | + if ( ! is_network_admin()) { |
|
76 | 76 | |
77 | - $recent = wordpoints_get_array_option( 'wordpoints_recently_activated_modules' ); |
|
78 | - unset( $recent[ $module ] ); |
|
79 | - update_option( 'wordpoints_recently_activated_modules', $recent ); |
|
77 | + $recent = wordpoints_get_array_option('wordpoints_recently_activated_modules'); |
|
78 | + unset($recent[$module]); |
|
79 | + update_option('wordpoints_recently_activated_modules', $recent); |
|
80 | 80 | } |
81 | 81 | |
82 | - wp_safe_redirect( add_query_arg( 'activate', 'true', $redirect_url ) ); |
|
82 | + wp_safe_redirect(add_query_arg('activate', 'true', $redirect_url)); |
|
83 | 83 | exit; |
84 | 84 | |
85 | 85 | // Activate multiple modules. |
86 | 86 | case 'activate-selected': |
87 | - if ( ! current_user_can( 'activate_wordpoints_modules' ) ) { |
|
88 | - wp_die( esc_html__( 'Sorry, you are not allowed to activate modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
87 | + if ( ! current_user_can('activate_wordpoints_modules')) { |
|
88 | + wp_die(esc_html__('Sorry, you are not allowed to activate modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
89 | 89 | } |
90 | 90 | |
91 | - check_admin_referer( 'bulk-modules' ); |
|
91 | + check_admin_referer('bulk-modules'); |
|
92 | 92 | |
93 | - $modules = isset( $_POST['checked'] ) |
|
94 | - ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['checked'] ) ) |
|
93 | + $modules = isset($_POST['checked']) |
|
94 | + ? array_map('sanitize_text_field', (array) wp_unslash($_POST['checked'])) |
|
95 | 95 | : array(); |
96 | 96 | |
97 | 97 | // Only activate modules which are not already active. |
98 | - if ( is_network_admin() ) { |
|
98 | + if (is_network_admin()) { |
|
99 | 99 | |
100 | - foreach ( $modules as $i => $module ) { |
|
101 | - if ( is_wordpoints_module_active_for_network( $module ) ) { |
|
102 | - unset( $modules[ $i ] ); |
|
100 | + foreach ($modules as $i => $module) { |
|
101 | + if (is_wordpoints_module_active_for_network($module)) { |
|
102 | + unset($modules[$i]); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | } else { |
107 | 107 | |
108 | - foreach ( $modules as $i => $module ) { |
|
109 | - if ( is_wordpoints_module_active( $module ) || is_network_only_wordpoints_module( $module ) ) { |
|
110 | - unset( $modules[ $i ] ); |
|
108 | + foreach ($modules as $i => $module) { |
|
109 | + if (is_wordpoints_module_active($module) || is_network_only_wordpoints_module($module)) { |
|
110 | + unset($modules[$i]); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if ( empty( $modules ) ) { |
|
116 | - wp_safe_redirect( $redirect_url ); |
|
115 | + if (empty($modules)) { |
|
116 | + wp_safe_redirect($redirect_url); |
|
117 | 117 | exit; |
118 | 118 | } |
119 | 119 | |
120 | - $redirect = self_admin_url( 'admin.php?page=wordpoints_modules&error=true' ); |
|
120 | + $redirect = self_admin_url('admin.php?page=wordpoints_modules&error=true'); |
|
121 | 121 | |
122 | - foreach ( $modules as $module ) { |
|
122 | + foreach ($modules as $module) { |
|
123 | 123 | |
124 | - wordpoints_activate_module( $module, add_query_arg( 'module', $module, $redirect ), is_network_admin() ); |
|
124 | + wordpoints_activate_module($module, add_query_arg('module', $module, $redirect), is_network_admin()); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( ! is_network_admin() ) { |
|
127 | + if ( ! is_network_admin()) { |
|
128 | 128 | |
129 | - $recent = wordpoints_get_array_option( 'wordpoints_recently_activated_modules' ); |
|
129 | + $recent = wordpoints_get_array_option('wordpoints_recently_activated_modules'); |
|
130 | 130 | |
131 | - foreach ( $modules as $module ) { |
|
132 | - unset( $recent[ $module ] ); |
|
131 | + foreach ($modules as $module) { |
|
132 | + unset($recent[$module]); |
|
133 | 133 | } |
134 | 134 | |
135 | - update_option( 'wordpoints_recently_activated_modules', $recent ); |
|
135 | + update_option('wordpoints_recently_activated_modules', $recent); |
|
136 | 136 | } |
137 | 137 | |
138 | - wp_safe_redirect( add_query_arg( 'activate-multi', 'true', $redirect_url ) ); |
|
138 | + wp_safe_redirect(add_query_arg('activate-multi', 'true', $redirect_url)); |
|
139 | 139 | exit; |
140 | 140 | |
141 | 141 | // Get the fatal error from a module. |
142 | 142 | case 'error_scrape': |
143 | - if ( ! current_user_can( 'activate_wordpoints_modules' ) ) { |
|
144 | - wp_die( esc_html__( 'Sorry, you are not allowed to activate modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
143 | + if ( ! current_user_can('activate_wordpoints_modules')) { |
|
144 | + wp_die(esc_html__('Sorry, you are not allowed to activate modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
145 | 145 | } |
146 | 146 | |
147 | - check_admin_referer( 'module-activation-error_' . $module ); |
|
147 | + check_admin_referer('module-activation-error_' . $module); |
|
148 | 148 | |
149 | - $valid = wordpoints_validate_module( $module ); |
|
149 | + $valid = wordpoints_validate_module($module); |
|
150 | 150 | |
151 | - if ( is_wp_error( $valid ) ) { |
|
152 | - wp_die( wordpoints_sanitize_wp_error( $valid ), '', array( 'response' => 400 ) ); |
|
151 | + if (is_wp_error($valid)) { |
|
152 | + wp_die(wordpoints_sanitize_wp_error($valid), '', array('response' => 400)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // Ensure that Fatal errors are displayed. |
156 | - if ( ! WP_DEBUG ) { |
|
157 | - error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); // @codingStandardsIgnoreLine |
|
156 | + if ( ! WP_DEBUG) { |
|
157 | + error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); // @codingStandardsIgnoreLine |
|
158 | 158 | } |
159 | 159 | |
160 | - @ini_set( 'display_errors', true ); // @codingStandardsIgnoreLine |
|
160 | + @ini_set('display_errors', true); // @codingStandardsIgnoreLine |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Go back to "sandbox" scope so we get the same errors as before. |
@@ -167,119 +167,119 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param string $module The base path to the module to error scrape. |
169 | 169 | */ |
170 | - function wordpoints_module_sandbox_scrape( $module ) { |
|
170 | + function wordpoints_module_sandbox_scrape($module) { |
|
171 | 171 | |
172 | 172 | $modules_dir = wordpoints_modules_dir(); |
173 | - WordPoints_Module_Paths::register( $modules_dir . '/' . $module ); |
|
174 | - include( $modules_dir . '/' . $module ); |
|
173 | + WordPoints_Module_Paths::register($modules_dir . '/' . $module); |
|
174 | + include($modules_dir . '/' . $module); |
|
175 | 175 | } |
176 | 176 | |
177 | - wordpoints_module_sandbox_scrape( $module ); |
|
177 | + wordpoints_module_sandbox_scrape($module); |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @see wordpoints_activate_module() |
181 | 181 | */ |
182 | - do_action( "wordpoints_module_activate-{$module}" ); |
|
182 | + do_action("wordpoints_module_activate-{$module}"); |
|
183 | 183 | exit; |
184 | 184 | |
185 | 185 | // Deactivate a module. |
186 | 186 | case 'deactivate': |
187 | - if ( ! current_user_can( 'activate_wordpoints_modules' ) ) { |
|
188 | - wp_die( esc_html__( 'Sorry, you are not allowed to deactivate modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
187 | + if ( ! current_user_can('activate_wordpoints_modules')) { |
|
188 | + wp_die(esc_html__('Sorry, you are not allowed to deactivate modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
189 | 189 | } |
190 | 190 | |
191 | - check_admin_referer( 'deactivate-module_' . $module ); |
|
191 | + check_admin_referer('deactivate-module_' . $module); |
|
192 | 192 | |
193 | - if ( ! is_network_admin() && is_wordpoints_module_active_for_network( $module ) ) { |
|
194 | - wp_safe_redirect( $redirect_url ); |
|
193 | + if ( ! is_network_admin() && is_wordpoints_module_active_for_network($module)) { |
|
194 | + wp_safe_redirect($redirect_url); |
|
195 | 195 | exit; |
196 | 196 | } |
197 | 197 | |
198 | - wordpoints_deactivate_modules( $module, false, is_network_admin() ); |
|
198 | + wordpoints_deactivate_modules($module, false, is_network_admin()); |
|
199 | 199 | |
200 | - if ( ! is_network_admin() ) { |
|
201 | - update_option( 'wordpoints_recently_activated_modules', array( $module => time() ) + wordpoints_get_array_option( 'wordpoints_recently_activated_modules' ) ); |
|
200 | + if ( ! is_network_admin()) { |
|
201 | + update_option('wordpoints_recently_activated_modules', array($module => time()) + wordpoints_get_array_option('wordpoints_recently_activated_modules')); |
|
202 | 202 | } |
203 | 203 | |
204 | - $redirect_url = add_query_arg( 'deactivate', 'true', $redirect_url ); |
|
204 | + $redirect_url = add_query_arg('deactivate', 'true', $redirect_url); |
|
205 | 205 | |
206 | - if ( headers_sent() ) { |
|
207 | - echo '<meta http-equiv="refresh" content="0;url=' . esc_url( $redirect_url ) . '" />'; |
|
206 | + if (headers_sent()) { |
|
207 | + echo '<meta http-equiv="refresh" content="0;url=' . esc_url($redirect_url) . '" />'; |
|
208 | 208 | } else { |
209 | - wp_safe_redirect( $redirect_url ); |
|
209 | + wp_safe_redirect($redirect_url); |
|
210 | 210 | } |
211 | 211 | exit; |
212 | 212 | |
213 | 213 | // Deactivate multiple modules. |
214 | 214 | case 'deactivate-selected': |
215 | - if ( ! current_user_can( 'activate_wordpoints_modules' ) ) { |
|
216 | - wp_die( esc_html__( 'Sorry, you are not allowed to deactivate modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
215 | + if ( ! current_user_can('activate_wordpoints_modules')) { |
|
216 | + wp_die(esc_html__('Sorry, you are not allowed to deactivate modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
217 | 217 | } |
218 | 218 | |
219 | - check_admin_referer( 'bulk-modules' ); |
|
219 | + check_admin_referer('bulk-modules'); |
|
220 | 220 | |
221 | - $modules = isset( $_POST['checked'] ) |
|
222 | - ? array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['checked'] ) ) |
|
221 | + $modules = isset($_POST['checked']) |
|
222 | + ? array_map('sanitize_text_field', (array) wp_unslash($_POST['checked'])) |
|
223 | 223 | : array(); |
224 | 224 | |
225 | - $network_modules = array_filter( $modules, 'is_wordpoints_module_active_for_network' ); |
|
225 | + $network_modules = array_filter($modules, 'is_wordpoints_module_active_for_network'); |
|
226 | 226 | |
227 | 227 | // Do not deactivate modules which are already deactivated. |
228 | - if ( is_network_admin() ) { |
|
228 | + if (is_network_admin()) { |
|
229 | 229 | $modules = $network_modules; |
230 | 230 | } else { |
231 | - $modules = array_diff( array_filter( $modules, 'is_wordpoints_module_active' ), $network_modules ); |
|
231 | + $modules = array_diff(array_filter($modules, 'is_wordpoints_module_active'), $network_modules); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( empty( $modules ) ) { |
|
235 | - wp_safe_redirect( $redirect_url ); |
|
234 | + if (empty($modules)) { |
|
235 | + wp_safe_redirect($redirect_url); |
|
236 | 236 | exit; |
237 | 237 | } |
238 | 238 | |
239 | - wordpoints_deactivate_modules( $modules, false, is_network_admin() ); |
|
239 | + wordpoints_deactivate_modules($modules, false, is_network_admin()); |
|
240 | 240 | |
241 | - if ( ! is_network_admin() ) { |
|
241 | + if ( ! is_network_admin()) { |
|
242 | 242 | |
243 | 243 | $deactivated = array(); |
244 | 244 | |
245 | - foreach ( $modules as $module ) { |
|
246 | - $deactivated[ $module ] = time(); |
|
245 | + foreach ($modules as $module) { |
|
246 | + $deactivated[$module] = time(); |
|
247 | 247 | } |
248 | 248 | |
249 | - update_option( 'wordpoints_recently_activated_modules', $deactivated + wordpoints_get_array_option( 'wordpoints_recently_activated_modules' ) ); |
|
249 | + update_option('wordpoints_recently_activated_modules', $deactivated + wordpoints_get_array_option('wordpoints_recently_activated_modules')); |
|
250 | 250 | } |
251 | 251 | |
252 | - wp_safe_redirect( add_query_arg( 'deactivate-multi', 'true', $redirect_url ) ); |
|
252 | + wp_safe_redirect(add_query_arg('deactivate-multi', 'true', $redirect_url)); |
|
253 | 253 | exit; |
254 | 254 | |
255 | 255 | // Delete multiple modules. |
256 | 256 | case 'delete-selected': |
257 | - if ( ! current_user_can( 'delete_wordpoints_modules' ) ) { |
|
258 | - wp_die( esc_html__( 'Sorry, you are not allowed to delete modules for this site.', 'wordpoints' ), '', array( 'response' => 403 ) ); |
|
257 | + if ( ! current_user_can('delete_wordpoints_modules')) { |
|
258 | + wp_die(esc_html__('Sorry, you are not allowed to delete modules for this site.', 'wordpoints'), '', array('response' => 403)); |
|
259 | 259 | } |
260 | 260 | |
261 | - check_admin_referer( 'bulk-modules' ); |
|
261 | + check_admin_referer('bulk-modules'); |
|
262 | 262 | |
263 | 263 | // $_POST = from the module form; $_GET = from the FTP details screen. |
264 | - $modules = isset( $_REQUEST['checked'] ) |
|
265 | - ? array_map( 'sanitize_text_field', (array) wp_unslash( $_REQUEST['checked'] ) ) |
|
264 | + $modules = isset($_REQUEST['checked']) |
|
265 | + ? array_map('sanitize_text_field', (array) wp_unslash($_REQUEST['checked'])) |
|
266 | 266 | : array(); |
267 | 267 | |
268 | - if ( empty( $modules ) ) { |
|
269 | - wp_safe_redirect( $redirect_url ); |
|
268 | + if (empty($modules)) { |
|
269 | + wp_safe_redirect($redirect_url); |
|
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Do not allow to delete activated modules. |
274 | - foreach ( $modules as $key => $module ) { |
|
274 | + foreach ($modules as $key => $module) { |
|
275 | 275 | |
276 | - if ( is_wordpoints_module_active( $module ) ) { |
|
277 | - unset( $modules[ $key ] ); |
|
276 | + if (is_wordpoints_module_active($module)) { |
|
277 | + unset($modules[$key]); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if ( empty( $modules ) ) { |
|
282 | - wp_safe_redirect( add_query_arg( array( 'error' => 'true', 'main' => 'true' ), $redirect_url ) ); |
|
281 | + if (empty($modules)) { |
|
282 | + wp_safe_redirect(add_query_arg(array('error' => 'true', 'main' => 'true'), $redirect_url)); |
|
283 | 283 | exit; |
284 | 284 | } |
285 | 285 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | |
288 | 288 | $parent_file = 'admin.php'; |
289 | 289 | |
290 | - if ( ! isset( $_REQUEST['verify-delete'] ) ) { |
|
290 | + if ( ! isset($_REQUEST['verify-delete'])) { |
|
291 | 291 | |
292 | - wp_enqueue_script( 'jquery' ); |
|
292 | + wp_enqueue_script('jquery'); |
|
293 | 293 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
294 | 294 | |
295 | 295 | ?> |
@@ -303,19 +303,19 @@ discard block |
||
303 | 303 | $files_to_delete = array(); |
304 | 304 | $have_non_network_modules = false; |
305 | 305 | |
306 | - foreach ( $modules as $module ) { |
|
306 | + foreach ($modules as $module) { |
|
307 | 307 | |
308 | - if ( '.' === dirname( $module ) ) { |
|
308 | + if ('.' === dirname($module)) { |
|
309 | 309 | |
310 | 310 | $files_to_delete[] = $module_dir . '/' . $module; |
311 | - $data = wordpoints_get_module_data( $module_dir . '/' . $module ); |
|
311 | + $data = wordpoints_get_module_data($module_dir . '/' . $module); |
|
312 | 312 | |
313 | - if ( ! empty( $data ) ) { |
|
313 | + if ( ! empty($data)) { |
|
314 | 314 | |
315 | - $module_info[ $module ] = $data; |
|
316 | - $module_info[ $module ]['is_uninstallable'] = is_uninstallable_wordpoints_module( $module ); |
|
315 | + $module_info[$module] = $data; |
|
316 | + $module_info[$module]['is_uninstallable'] = is_uninstallable_wordpoints_module($module); |
|
317 | 317 | |
318 | - if ( ! $module_info[ $module ]['network'] ) { |
|
318 | + if ( ! $module_info[$module]['network']) { |
|
319 | 319 | $have_non_network_modules = true; |
320 | 320 | } |
321 | 321 | } |
@@ -323,21 +323,21 @@ discard block |
||
323 | 323 | } else { |
324 | 324 | |
325 | 325 | // Locate all the files in that folder. |
326 | - $files = list_files( $module_dir . '/' . dirname( $module ) ); |
|
326 | + $files = list_files($module_dir . '/' . dirname($module)); |
|
327 | 327 | |
328 | - if ( $files ) { |
|
329 | - $files_to_delete = array_merge( $files_to_delete, $files ); |
|
328 | + if ($files) { |
|
329 | + $files_to_delete = array_merge($files_to_delete, $files); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Get modules list from that folder. |
333 | - $folder_modules = wordpoints_get_modules( '/' . dirname( $module ) ); |
|
333 | + $folder_modules = wordpoints_get_modules('/' . dirname($module)); |
|
334 | 334 | |
335 | - foreach ( $folder_modules as $module_file => $data ) { |
|
335 | + foreach ($folder_modules as $module_file => $data) { |
|
336 | 336 | |
337 | - $module_info[ $module_file ] = $data; |
|
338 | - $module_info[ $module_file ]['is_uninstallable'] = is_uninstallable_wordpoints_module( $module ); |
|
337 | + $module_info[$module_file] = $data; |
|
338 | + $module_info[$module_file]['is_uninstallable'] = is_uninstallable_wordpoints_module($module); |
|
339 | 339 | |
340 | - if ( ! $module_info[ $module_file ]['network'] ) { |
|
340 | + if ( ! $module_info[$module_file]['network']) { |
|
341 | 341 | $have_non_network_modules = true; |
342 | 342 | } |
343 | 343 | } |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | |
347 | 347 | } // End foreach( $modules ). |
348 | 348 | |
349 | - $modules_to_delete = count( $module_info ); |
|
349 | + $modules_to_delete = count($module_info); |
|
350 | 350 | |
351 | - echo '<h1>' . esc_html( _n( 'Delete module', 'Delete modules', $modules_to_delete, 'wordpoints' ) ) . '</h1>'; |
|
351 | + echo '<h1>' . esc_html(_n('Delete module', 'Delete modules', $modules_to_delete, 'wordpoints')) . '</h1>'; |
|
352 | 352 | |
353 | - if ( $have_non_network_modules && is_network_admin() ) { |
|
353 | + if ($have_non_network_modules && is_network_admin()) { |
|
354 | 354 | wordpoints_show_admin_message( |
355 | - '<strong>' . esc_html__( 'Caution:', 'wordpoints' ) . '</strong>' |
|
355 | + '<strong>' . esc_html__('Caution:', 'wordpoints') . '</strong>' |
|
356 | 356 | . esc_html( |
357 | 357 | _n( |
358 | 358 | 'This module may be active on other sites in the network.' |
@@ -367,25 +367,25 @@ discard block |
||
367 | 367 | |
368 | 368 | ?> |
369 | 369 | |
370 | - <p><?php echo esc_html( _n( 'You are about to remove the following module:', 'You are about to remove the following modules:', $modules_to_delete, 'wordpoints' ) ); ?></p> |
|
370 | + <p><?php echo esc_html(_n('You are about to remove the following module:', 'You are about to remove the following modules:', $modules_to_delete, 'wordpoints')); ?></p> |
|
371 | 371 | <ul class="ul-disc"> |
372 | 372 | |
373 | 373 | <?php |
374 | 374 | |
375 | 375 | $data_to_delete = false; |
376 | 376 | |
377 | - foreach ( $module_info as $module ) { |
|
377 | + foreach ($module_info as $module) { |
|
378 | 378 | |
379 | - if ( $module['is_uninstallable'] ) { |
|
379 | + if ($module['is_uninstallable']) { |
|
380 | 380 | |
381 | 381 | // translators: 1. Module name; 2. Module author. |
382 | - echo '<li>', wp_kses( sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)', 'wordpoints' ), esc_html( $module['name'] ), esc_html( $module['author_name'] ) ), array( 'strong' => array(), 'em' => array() ) ), '</li>'; |
|
382 | + echo '<li>', wp_kses(sprintf(__('<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)', 'wordpoints'), esc_html($module['name']), esc_html($module['author_name'])), array('strong' => array(), 'em' => array())), '</li>'; |
|
383 | 383 | $data_to_delete = true; |
384 | 384 | |
385 | 385 | } else { |
386 | 386 | |
387 | 387 | // translators: 1. Module name; 2. Module author. |
388 | - echo '<li>', wp_kses( sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em>', 'wordpoints' ), esc_html( $module['name'] ), esc_html( $module['author_name'] ) ), array( 'strong' => array(), 'em' => array() ) ), '</li>'; |
|
388 | + echo '<li>', wp_kses(sprintf(__('<strong>%1$s</strong> by <em>%2$s</em>', 'wordpoints'), esc_html($module['name']), esc_html($module['author_name'])), array('strong' => array(), 'em' => array())), '</li>'; |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | <p> |
396 | 396 | <?php |
397 | 397 | |
398 | - if ( $data_to_delete ) { |
|
399 | - esc_html_e( 'Are you sure you wish to delete these files and data?', 'wordpoints' ); |
|
398 | + if ($data_to_delete) { |
|
399 | + esc_html_e('Are you sure you wish to delete these files and data?', 'wordpoints'); |
|
400 | 400 | } else { |
401 | - esc_html_e( 'Are you sure you wish to delete these files?', 'wordpoints' ); |
|
401 | + esc_html_e('Are you sure you wish to delete these files?', 'wordpoints'); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | ?> |
@@ -407,21 +407,21 @@ discard block |
||
407 | 407 | <form method="post" style="display:inline;"> |
408 | 408 | <input type="hidden" name="verify-delete" value="1" /> |
409 | 409 | <input type="hidden" name="action" value="delete-selected" /> |
410 | - <?php foreach ( (array) $modules as $module ) : ?> |
|
411 | - <input type="hidden" name="checked[]" value="<?php echo esc_attr( $module ); ?>" /> |
|
410 | + <?php foreach ((array) $modules as $module) : ?> |
|
411 | + <input type="hidden" name="checked[]" value="<?php echo esc_attr($module); ?>" /> |
|
412 | 412 | <?php endforeach; ?> |
413 | - <?php wp_nonce_field( 'bulk-modules' ) ?> |
|
414 | - <?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data', 'wordpoints' ) : __( 'Yes, Delete these files', 'wordpoints' ), 'button', 'submit', false ); ?> |
|
413 | + <?php wp_nonce_field('bulk-modules') ?> |
|
414 | + <?php submit_button($data_to_delete ? __('Yes, Delete these files and data', 'wordpoints') : __('Yes, Delete these files', 'wordpoints'), 'button', 'submit', false); ?> |
|
415 | 415 | </form> |
416 | - <form method="post" action="<?php echo esc_url( wp_get_referer() ); ?>" style="display:inline;"> |
|
417 | - <?php submit_button( __( 'No, Return me to the module list', 'wordpoints' ), 'button', 'submit', false ); ?> |
|
416 | + <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;"> |
|
417 | + <?php submit_button(__('No, Return me to the module list', 'wordpoints'), 'button', 'submit', false); ?> |
|
418 | 418 | </form> |
419 | 419 | |
420 | - <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php esc_html_e( 'Click to view entire list of files which will be deleted', 'wordpoints' ); ?></a></p> |
|
420 | + <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php esc_html_e('Click to view entire list of files which will be deleted', 'wordpoints'); ?></a></p> |
|
421 | 421 | <div id="files-list" class="hidden"> |
422 | 422 | <ul class="code"> |
423 | - <?php foreach ( (array) $files_to_delete as $file ) : ?> |
|
424 | - <li><?php echo esc_html( str_replace( $module_dir, '', $file ) ); ?></li> |
|
423 | + <?php foreach ((array) $files_to_delete as $file) : ?> |
|
424 | + <li><?php echo esc_html(str_replace($module_dir, '', $file)); ?></li> |
|
425 | 425 | <?php endforeach; ?> |
426 | 426 | </ul> |
427 | 427 | </div> |
@@ -434,17 +434,17 @@ discard block |
||
434 | 434 | |
435 | 435 | } // End if ( ! isset( $_REQUEST['verify-delete'] ) ). |
436 | 436 | |
437 | - $delete_result = wordpoints_delete_modules( $modules ); |
|
437 | + $delete_result = wordpoints_delete_modules($modules); |
|
438 | 438 | |
439 | 439 | // Store the result in a cache rather than a URL param due to object type & length |
440 | - set_transient( 'wordpoints_modules_delete_result_' . get_current_user_id(), $delete_result ); |
|
440 | + set_transient('wordpoints_modules_delete_result_' . get_current_user_id(), $delete_result); |
|
441 | 441 | |
442 | - wp_safe_redirect( add_query_arg( 'deleted', 'true', $redirect_url ) ); |
|
442 | + wp_safe_redirect(add_query_arg('deleted', 'true', $redirect_url)); |
|
443 | 443 | exit; |
444 | 444 | |
445 | 445 | case 'clear-recent-list': |
446 | - if ( ! is_network_admin() ) { |
|
447 | - update_option( 'wordpoints_recently_activated_modules', array() ); |
|
446 | + if ( ! is_network_admin()) { |
|
447 | + update_option('wordpoints_recently_activated_modules', array()); |
|
448 | 448 | } |
449 | 449 | break; |
450 | 450 | |
@@ -454,56 +454,56 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.1.0 |
456 | 456 | */ |
457 | - do_action( "wordpoints_modules_screen-{$action}" ); |
|
457 | + do_action("wordpoints_modules_screen-{$action}"); |
|
458 | 458 | |
459 | 459 | } // End switch ( $action ). |
460 | 460 | |
461 | -add_screen_option( 'per_page', array( 'default' => 999 ) ); |
|
461 | +add_screen_option('per_page', array('default' => 999)); |
|
462 | 462 | |
463 | 463 | $screen = get_current_screen(); |
464 | 464 | |
465 | 465 | $screen->add_help_tab( |
466 | 466 | array( |
467 | 467 | 'id' => 'overview', |
468 | - 'title' => __( 'Overview', 'wordpoints' ), |
|
468 | + 'title' => __('Overview', 'wordpoints'), |
|
469 | 469 | 'content' => |
470 | - '<p>' . esc_html__( 'Modules extend and expand the functionality of WordPoints. Once a module is installed, you may activate it or deactivate it here.', 'wordpoints' ) . '</p>' . |
|
470 | + '<p>' . esc_html__('Modules extend and expand the functionality of WordPoints. Once a module is installed, you may activate it or deactivate it here.', 'wordpoints') . '</p>' . |
|
471 | 471 | // translators: 1. URL of module directory on WordPoints.org; 2. URL of Install Module admin screen; 3. Directory name. |
472 | - '<p>' . wp_kses( sprintf( __( 'You can find modules for your site by by browsing the <a href="%1$s">WordPoints Module Directory</a>. To install a module you generally just need to <a href="%2$s">upload the module file</a> into your %3$s directory. Once a module has been installed, you can activate it here.', 'wordpoints' ), 'https://wordpoints.org/modules/', esc_url( self_admin_url( 'admin.php?page=wordpoints_install_modules' ) ), '<code>/wp-content/wordpoints-modules</code>' ), array( 'a' => array( 'href' => true, 'target' => true ), 'code' => array() ) ) . '</p>', |
|
472 | + '<p>' . wp_kses(sprintf(__('You can find modules for your site by by browsing the <a href="%1$s">WordPoints Module Directory</a>. To install a module you generally just need to <a href="%2$s">upload the module file</a> into your %3$s directory. Once a module has been installed, you can activate it here.', 'wordpoints'), 'https://wordpoints.org/modules/', esc_url(self_admin_url('admin.php?page=wordpoints_install_modules')), '<code>/wp-content/wordpoints-modules</code>'), array('a' => array('href' => true, 'target' => true), 'code' => array())) . '</p>', |
|
473 | 473 | ) |
474 | 474 | ); |
475 | 475 | |
476 | 476 | $screen->add_help_tab( |
477 | 477 | array( |
478 | 478 | 'id' => 'compatibility-problems', |
479 | - 'title' => __( 'Troubleshooting', 'wordpoints' ), |
|
479 | + 'title' => __('Troubleshooting', 'wordpoints'), |
|
480 | 480 | 'content' => |
481 | - '<p>' . esc_html__( 'Most of the time, modules play nicely with the core of WordPoints and with other modules. Sometimes, though, a module’s code will get in the way of another module, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your modules and re-activating them in various combinations until you isolate which one(s) caused the issue.', 'wordpoints' ) . '</p>' . |
|
481 | + '<p>' . esc_html__('Most of the time, modules play nicely with the core of WordPoints and with other modules. Sometimes, though, a module’s code will get in the way of another module, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your modules and re-activating them in various combinations until you isolate which one(s) caused the issue.', 'wordpoints') . '</p>' . |
|
482 | 482 | // translators: Directory name. |
483 | - '<p>' . sprintf( esc_html__( 'If something goes wrong with a module and you can’t use WordPoints, delete or rename that file in the %s directory and it will be automatically deactivated.', 'wordpoints' ), '<code>' . esc_html( wordpoints_modules_dir() ) . '</code>' ) . '</p>', // XSS OK WPCS |
|
483 | + '<p>' . sprintf(esc_html__('If something goes wrong with a module and you can’t use WordPoints, delete or rename that file in the %s directory and it will be automatically deactivated.', 'wordpoints'), '<code>' . esc_html(wordpoints_modules_dir()) . '</code>') . '</p>', // XSS OK WPCS |
|
484 | 484 | ) |
485 | 485 | ); |
486 | 486 | |
487 | 487 | $screen->set_help_sidebar( |
488 | - '<p><strong>' . esc_html__( 'For more information:', 'wordpoints' ) . '</strong></p> |
|
489 | - <p><a href="https://wordpoints.org/developer-guide/modules/">' . esc_html__( 'Developer Documentation', 'wordpoints' ) . '</a></p> |
|
490 | - <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__( 'Support Forums', 'wordpoints' ) . '</a></p>' |
|
488 | + '<p><strong>' . esc_html__('For more information:', 'wordpoints') . '</strong></p> |
|
489 | + <p><a href="https://wordpoints.org/developer-guide/modules/">' . esc_html__('Developer Documentation', 'wordpoints') . '</a></p> |
|
490 | + <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__('Support Forums', 'wordpoints') . '</a></p>' |
|
491 | 491 | ); |
492 | 492 | |
493 | 493 | register_column_headers( |
494 | 494 | $screen |
495 | 495 | , array( |
496 | 496 | 'cb' => '<input type="checkbox" />', |
497 | - 'name' => _x( 'Module', 'modules table heading', 'wordpoints' ), |
|
498 | - 'description' => _x( 'Description', 'modules table heading', 'wordpoints' ), |
|
497 | + 'name' => _x('Module', 'modules table heading', 'wordpoints'), |
|
498 | + 'description' => _x('Description', 'modules table heading', 'wordpoints'), |
|
499 | 499 | ) |
500 | 500 | ); |
501 | 501 | |
502 | 502 | $screen->set_screen_reader_content( |
503 | 503 | array( |
504 | - 'heading_views' => __( 'Filter modules list', 'wordpoints' ), |
|
505 | - 'heading_pagination' => __( 'Modules list navigation', 'wordpoints' ), |
|
506 | - 'heading_list' => __( 'Modules list', 'wordpoints' ), |
|
504 | + 'heading_views' => __('Filter modules list', 'wordpoints'), |
|
505 | + 'heading_pagination' => __('Modules list navigation', 'wordpoints'), |
|
506 | + 'heading_list' => __('Modules list', 'wordpoints'), |
|
507 | 507 | ) |
508 | 508 | ); |
509 | 509 |
@@ -11,62 +11,62 @@ discard block |
||
11 | 11 | |
12 | 12 | $invalid = wordpoints_validate_active_modules(); |
13 | 13 | |
14 | -if ( ! empty( $invalid ) ) { |
|
15 | - foreach ( $invalid as $module_file => $error ) { |
|
14 | +if ( ! empty($invalid)) { |
|
15 | + foreach ($invalid as $module_file => $error) { |
|
16 | 16 | wordpoints_show_admin_error( |
17 | 17 | sprintf( |
18 | 18 | // translators: 1. Module name; 2. Error message. |
19 | - __( 'The module %1$s has been <strong>deactivated</strong> due to an error: %2$s', 'wordpoints' ) |
|
20 | - , esc_html( $module_file ) |
|
21 | - , '<code>' . esc_html( $error->get_error_message() ) . '</code>' |
|
19 | + __('The module %1$s has been <strong>deactivated</strong> due to an error: %2$s', 'wordpoints') |
|
20 | + , esc_html($module_file) |
|
21 | + , '<code>' . esc_html($error->get_error_message()) . '</code>' |
|
22 | 22 | ) |
23 | - , array( 'dismissible' => true ) |
|
23 | + , array('dismissible' => true) |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | -if ( isset( $_GET['error'] ) ) { |
|
28 | +if (isset($_GET['error'])) { |
|
29 | 29 | |
30 | - if ( isset( $_GET['main'] ) ) { |
|
30 | + if (isset($_GET['main'])) { |
|
31 | 31 | |
32 | 32 | wordpoints_show_admin_error( |
33 | - esc_html__( 'You cannot delete a module while it is active on the main site.', 'wordpoints' ) |
|
34 | - , array( 'dismissible' => true ) |
|
33 | + esc_html__('You cannot delete a module while it is active on the main site.', 'wordpoints') |
|
34 | + , array('dismissible' => true) |
|
35 | 35 | ); |
36 | 36 | |
37 | - } elseif ( isset( $_GET['charsout'] ) ) { |
|
37 | + } elseif (isset($_GET['charsout'])) { |
|
38 | 38 | |
39 | 39 | wordpoints_show_admin_message( |
40 | 40 | sprintf( |
41 | 41 | // translators: Number of characters. |
42 | - __( 'The module generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this module.', 'wordpoints' ) |
|
42 | + __('The module generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this module.', 'wordpoints') |
|
43 | 43 | , (int) $_GET['charsout'] |
44 | 44 | ) |
45 | 45 | , 'warning' |
46 | - , array( 'dismissible' => true ) |
|
46 | + , array('dismissible' => true) |
|
47 | 47 | ); |
48 | 48 | |
49 | 49 | } else { |
50 | 50 | |
51 | - $error_message = __( 'Module could not be activated because it triggered a <strong>fatal error</strong>.', 'wordpoints' ); |
|
51 | + $error_message = __('Module could not be activated because it triggered a <strong>fatal error</strong>.', 'wordpoints'); |
|
52 | 52 | |
53 | 53 | if ( |
54 | - isset( $_GET['_error_nonce'], $_GET['module'] ) |
|
55 | - && wordpoints_verify_nonce( '_error_nonce', 'module-activation-error_%s', array( 'module' ) ) |
|
54 | + isset($_GET['_error_nonce'], $_GET['module']) |
|
55 | + && wordpoints_verify_nonce('_error_nonce', 'module-activation-error_%s', array('module')) |
|
56 | 56 | ) { |
57 | 57 | |
58 | 58 | $url = self_admin_url( |
59 | 59 | 'admin.php?page=wordpoints_modules&action=error_scrape&module=' |
60 | - . sanitize_text_field( wp_unslash( $_GET['module'] ) ) |
|
61 | - . '&_wpnonce=' . sanitize_key( $_GET['_error_nonce'] ) |
|
60 | + . sanitize_text_field(wp_unslash($_GET['module'])) |
|
61 | + . '&_wpnonce=' . sanitize_key($_GET['_error_nonce']) |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | ?> |
65 | 65 | |
66 | 66 | <div class="notice notice-error is-dismissible"> |
67 | 67 | <p> |
68 | - <?php echo wp_kses( $error_message, '' ); ?> |
|
69 | - <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $url ); ?>"></iframe> |
|
68 | + <?php echo wp_kses($error_message, ''); ?> |
|
69 | + <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url($url); ?>"></iframe> |
|
70 | 70 | </p> |
71 | 71 | </div> |
72 | 72 | |
@@ -76,78 +76,78 @@ discard block |
||
76 | 76 | |
77 | 77 | wordpoints_show_admin_error( |
78 | 78 | $error_message |
79 | - , array( 'dismissible' => true ) |
|
79 | + , array('dismissible' => true) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
83 | 83 | } // End if ( main error ) elseif ( unexpected output error ) else. |
84 | 84 | |
85 | -} elseif ( isset( $_GET['deleted'] ) ) { |
|
85 | +} elseif (isset($_GET['deleted'])) { |
|
86 | 86 | |
87 | 87 | $user_id = get_current_user_id(); |
88 | - $delete_result = get_transient( 'wordpoints_modules_delete_result_' . $user_id ); |
|
88 | + $delete_result = get_transient('wordpoints_modules_delete_result_' . $user_id); |
|
89 | 89 | |
90 | 90 | // Delete it once we're done. |
91 | - delete_transient( 'wordpoints_modules_delete_result_' . $user_id ); |
|
91 | + delete_transient('wordpoints_modules_delete_result_' . $user_id); |
|
92 | 92 | |
93 | - if ( is_wp_error( $delete_result ) ) { |
|
93 | + if (is_wp_error($delete_result)) { |
|
94 | 94 | |
95 | 95 | wordpoints_show_admin_error( |
96 | 96 | sprintf( |
97 | 97 | // translators: Error message. |
98 | - __( 'Module could not be deleted due to an error: %s', 'wordpoints' ) |
|
98 | + __('Module could not be deleted due to an error: %s', 'wordpoints') |
|
99 | 99 | , $delete_result->get_error_message() |
100 | 100 | ) |
101 | - , array( 'dismissible' => true ) |
|
101 | + , array('dismissible' => true) |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | } else { |
105 | 105 | |
106 | 106 | wordpoints_show_admin_message( |
107 | - __( 'The selected modules have been <strong>deleted</strong>.', 'wordpoints' ) |
|
107 | + __('The selected modules have been <strong>deleted</strong>.', 'wordpoints') |
|
108 | 108 | , 'success' |
109 | - , array( 'dismissible' => true ) |
|
109 | + , array('dismissible' => true) |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
113 | -} elseif ( isset( $_GET['activate'] ) ) { |
|
113 | +} elseif (isset($_GET['activate'])) { |
|
114 | 114 | |
115 | 115 | wordpoints_show_admin_message( |
116 | - __( 'Module <strong>activated</strong>.', 'wordpoints' ) |
|
116 | + __('Module <strong>activated</strong>.', 'wordpoints') |
|
117 | 117 | , 'success' |
118 | - , array( 'dismissible' => true ) |
|
118 | + , array('dismissible' => true) |
|
119 | 119 | ); |
120 | 120 | |
121 | -} elseif ( isset( $_GET['activate-multi'] ) ) { |
|
121 | +} elseif (isset($_GET['activate-multi'])) { |
|
122 | 122 | |
123 | 123 | wordpoints_show_admin_message( |
124 | - __( 'Selected modules <strong>activated</strong>.', 'wordpoints' ) |
|
124 | + __('Selected modules <strong>activated</strong>.', 'wordpoints') |
|
125 | 125 | , 'success' |
126 | - , array( 'dismissible' => true ) |
|
126 | + , array('dismissible' => true) |
|
127 | 127 | ); |
128 | 128 | |
129 | -} elseif ( isset( $_GET['deactivate'] ) ) { |
|
129 | +} elseif (isset($_GET['deactivate'])) { |
|
130 | 130 | |
131 | 131 | wordpoints_show_admin_message( |
132 | - __( 'Module <strong>deactivated</strong>.', 'wordpoints' ) |
|
132 | + __('Module <strong>deactivated</strong>.', 'wordpoints') |
|
133 | 133 | , 'success' |
134 | - , array( 'dismissible' => true ) |
|
134 | + , array('dismissible' => true) |
|
135 | 135 | ); |
136 | 136 | |
137 | -} elseif ( isset( $_GET['deactivate-multi'] ) ) { |
|
137 | +} elseif (isset($_GET['deactivate-multi'])) { |
|
138 | 138 | |
139 | 139 | wordpoints_show_admin_message( |
140 | - __( 'Selected modules <strong>deactivated</strong>.', 'wordpoints' ) |
|
140 | + __('Selected modules <strong>deactivated</strong>.', 'wordpoints') |
|
141 | 141 | , 'success' |
142 | - , array( 'dismissible' => true ) |
|
142 | + , array('dismissible' => true) |
|
143 | 143 | ); |
144 | 144 | |
145 | -} elseif ( isset( $_REQUEST['action'] ) && 'update-selected' === sanitize_key( $_REQUEST['action'] ) ) { |
|
145 | +} elseif (isset($_REQUEST['action']) && 'update-selected' === sanitize_key($_REQUEST['action'])) { |
|
146 | 146 | |
147 | 147 | wordpoints_show_admin_message( |
148 | - esc_html__( 'No out of date modules were selected.', 'wordpoints' ) |
|
148 | + esc_html__('No out of date modules were selected.', 'wordpoints') |
|
149 | 149 | , 'warning' |
150 | - , array( 'dismissible' => true ) |
|
150 | + , array('dismissible' => true) |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | } // End if ( error ) elseif ( other messages/errors ). |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | |
157 | 157 | <div class="wrap"> |
158 | 158 | <h1> |
159 | - <?php esc_html_e( 'WordPoints Modules', 'wordpoints' ); ?> |
|
159 | + <?php esc_html_e('WordPoints Modules', 'wordpoints'); ?> |
|
160 | 160 | |
161 | - <?php if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_wordpoints_modules' ) ) : ?> |
|
162 | - <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_install_modules' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'module', 'wordpoints' ); ?></a> |
|
161 | + <?php if (( ! is_multisite() || is_network_admin()) && current_user_can('install_wordpoints_modules')) : ?> |
|
162 | + <a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_install_modules')); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'module', 'wordpoints'); ?></a> |
|
163 | 163 | <?php endif; ?> |
164 | 164 | |
165 | - <?php if ( ! empty( $_REQUEST['s'] ) ) : ?> |
|
165 | + <?php if ( ! empty($_REQUEST['s'])) : ?> |
|
166 | 166 | <span class="subtitle"> |
167 | 167 | <?php |
168 | 168 | |
169 | 169 | echo esc_html( |
170 | 170 | sprintf( |
171 | 171 | // translators: Search term. |
172 | - __( 'Search results for “%s”', 'wordpoints' ) |
|
173 | - , sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) |
|
172 | + __('Search results for “%s”', 'wordpoints') |
|
173 | + , sanitize_text_field(wp_unslash($_REQUEST['s'])) |
|
174 | 174 | ) |
175 | 175 | ); |
176 | 176 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | |
189 | 189 | <?php $wp_list_table->views(); ?> |
190 | 190 | |
191 | - <form method="get" action="<?php echo esc_url( self_admin_url( 'admin.php' ) ); ?>"> |
|
191 | + <form method="get" action="<?php echo esc_url(self_admin_url('admin.php')); ?>"> |
|
192 | 192 | <input type="hidden" name="page" value="wordpoints_modules" /> |
193 | - <?php $wp_list_table->search_box( esc_html__( 'Search Installed Modules', 'wordpoints' ), 'module' ); ?> |
|
193 | + <?php $wp_list_table->search_box(esc_html__('Search Installed Modules', 'wordpoints'), 'module'); ?> |
|
194 | 194 | </form> |
195 | 195 | |
196 | - <form method="post" action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_modules' ) ); ?>"> |
|
197 | - <input type="hidden" name="module_status" value="<?php echo esc_attr( $status ) ?>" /> |
|
198 | - <input type="hidden" name="paged" value="<?php echo esc_attr( $page ) ?>" /> |
|
196 | + <form method="post" action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_modules')); ?>"> |
|
197 | + <input type="hidden" name="module_status" value="<?php echo esc_attr($status) ?>" /> |
|
198 | + <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" /> |
|
199 | 199 | <?php $wp_list_table->display(); ?> |
200 | 200 | </form> |
201 | 201 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0.0 |
207 | 207 | */ |
208 | - do_action( 'wordpoints_admin_modules' ); |
|
208 | + do_action('wordpoints_admin_modules'); |
|
209 | 209 | ?> |
210 | 210 | |
211 | 211 | </div> |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0.0 |
32 | 32 | */ |
33 | - do_action( 'wordpoints_admin_configure_head' ); |
|
33 | + do_action('wordpoints_admin_configure_head'); |
|
34 | 34 | |
35 | 35 | wordpoints_admin_show_tabs( |
36 | 36 | array( |
37 | - 'general' => __( 'General Settings', 'wordpoints' ), |
|
38 | - 'components' => __( 'Components', 'wordpoints' ), |
|
37 | + 'general' => __('General Settings', 'wordpoints'), |
|
38 | + 'components' => __('Components', 'wordpoints'), |
|
39 | 39 | ) |
40 | 40 | ); |
41 | 41 | |
42 | - if ( 'components' === wordpoints_admin_get_current_tab() ) { |
|
42 | + if ('components' === wordpoints_admin_get_current_tab()) { |
|
43 | 43 | /** |
44 | 44 | * The Components screen. |
45 | 45 | * |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.0.0 |
62 | 62 | */ |
63 | - do_action( 'wordpoints_admin_configure_foot' ); |
|
63 | + do_action('wordpoints_admin_configure_foot'); |
|
64 | 64 | |
65 | 65 | ?> |
66 | 66 |
@@ -7,37 +7,37 @@ |
||
7 | 7 | * @since 2.1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_init_app-apps', 'wordpoints_hooks_register_admin_apps' ); |
|
10 | +add_action('wordpoints_init_app-apps', 'wordpoints_hooks_register_admin_apps'); |
|
11 | 11 | |
12 | -add_action( 'admin_init', 'wordpoints_hooks_admin_ajax' ); |
|
13 | -add_action( 'admin_init', 'wordpoints_register_admin_scripts' ); |
|
12 | +add_action('admin_init', 'wordpoints_hooks_admin_ajax'); |
|
13 | +add_action('admin_init', 'wordpoints_register_admin_scripts'); |
|
14 | 14 | |
15 | -add_filter( 'script_loader_tag', 'wordpoints_script_templates_filter', 10, 2 ); |
|
15 | +add_filter('script_loader_tag', 'wordpoints_script_templates_filter', 10, 2); |
|
16 | 16 | |
17 | -add_action( 'admin_menu', 'wordpoints_admin_menu' ); |
|
18 | -add_action( 'network_admin_menu', 'wordpoints_admin_menu' ); |
|
17 | +add_action('admin_menu', 'wordpoints_admin_menu'); |
|
18 | +add_action('network_admin_menu', 'wordpoints_admin_menu'); |
|
19 | 19 | |
20 | -add_action( 'load-wordpoints_page_wordpoints_modules', 'wordpoints_admin_screen_modules_load' ); |
|
21 | -add_action( 'load-toplevel_page_wordpoints_modules', 'wordpoints_admin_screen_modules_load' ); |
|
20 | +add_action('load-wordpoints_page_wordpoints_modules', 'wordpoints_admin_screen_modules_load'); |
|
21 | +add_action('load-toplevel_page_wordpoints_modules', 'wordpoints_admin_screen_modules_load'); |
|
22 | 22 | |
23 | -add_action( 'load-toplevel_page_wordpoints_configure', 'wordpoints_admin_screen_configure_load' ); |
|
23 | +add_action('load-toplevel_page_wordpoints_configure', 'wordpoints_admin_screen_configure_load'); |
|
24 | 24 | |
25 | -add_action( 'load-toplevel_page_wordpoints_configure', 'wordpoints_admin_activate_components' ); |
|
25 | +add_action('load-toplevel_page_wordpoints_configure', 'wordpoints_admin_activate_components'); |
|
26 | 26 | |
27 | -add_action( 'wordpoints_install_modules-upload', 'wordpoints_install_modules_upload' ); |
|
27 | +add_action('wordpoints_install_modules-upload', 'wordpoints_install_modules_upload'); |
|
28 | 28 | |
29 | -add_action( 'update-custom_upload-wordpoints-module', 'wordpoints_upload_module_zip' ); |
|
29 | +add_action('update-custom_upload-wordpoints-module', 'wordpoints_upload_module_zip'); |
|
30 | 30 | |
31 | -add_action( 'upgrader_source_selection', 'wordpoints_plugin_upload_error_filter', 5 ); |
|
32 | -add_action( 'upgrader_source_selection', 'wordpoints_plugin_upload_error_filter', 20 ); |
|
31 | +add_action('upgrader_source_selection', 'wordpoints_plugin_upload_error_filter', 5); |
|
32 | +add_action('upgrader_source_selection', 'wordpoints_plugin_upload_error_filter', 20); |
|
33 | 33 | |
34 | -add_action( 'wordpoints_admin_configure_foot', 'wordpoints_admin_settings_screen_sidebar', 5 ); |
|
34 | +add_action('wordpoints_admin_configure_foot', 'wordpoints_admin_settings_screen_sidebar', 5); |
|
35 | 35 | |
36 | -add_action( 'admin_notices', 'wordpoints_admin_notices' ); |
|
36 | +add_action('admin_notices', 'wordpoints_admin_notices'); |
|
37 | 37 | |
38 | -add_action( 'set-screen-option', 'wordpoints_admin_set_screen_option', 10, 3 ); |
|
38 | +add_action('set-screen-option', 'wordpoints_admin_set_screen_option', 10, 3); |
|
39 | 39 | |
40 | -add_action( 'wp_ajax_nopriv_wordpoints_breaking_module_check', 'wordpoints_admin_ajax_breaking_module_check' ); |
|
41 | -add_action( 'wp_ajax_wordpoints-delete-admin-notice-option', 'wordpoints_delete_admin_notice_option' ); |
|
40 | +add_action('wp_ajax_nopriv_wordpoints_breaking_module_check', 'wordpoints_admin_ajax_breaking_module_check'); |
|
41 | +add_action('wp_ajax_wordpoints-delete-admin-notice-option', 'wordpoints_delete_admin_notice_option'); |
|
42 | 42 | |
43 | 43 | // EOF |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @type string $title Text for H2 title used by WP_Upgrader_Skin::header(). |
51 | 51 | * } |
52 | 52 | */ |
53 | - public function __construct( $args = array() ) { |
|
53 | + public function __construct($args = array()) { |
|
54 | 54 | |
55 | 55 | $defaults = array( |
56 | 56 | 'type' => 'upload', |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | 'title' => '', |
60 | 60 | ); |
61 | 61 | |
62 | - $args = array_merge( $defaults, $args ); |
|
62 | + $args = array_merge($defaults, $args); |
|
63 | 63 | |
64 | 64 | $this->type = $args['type']; |
65 | 65 | |
66 | - parent::__construct( $args ); |
|
66 | + parent::__construct($args); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function after() { |
75 | 75 | |
76 | - if ( ! $this->upgrader instanceof WordPoints_Module_Installer ) { |
|
76 | + if ( ! $this->upgrader instanceof WordPoints_Module_Installer) { |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | |
82 | 82 | $install_actions = array(); |
83 | 83 | |
84 | - if ( $this->result && ! is_wp_error( $this->result ) ) { |
|
84 | + if ($this->result && ! is_wp_error($this->result)) { |
|
85 | 85 | |
86 | - if ( is_multisite() && current_user_can( 'manage_network_wordpoints_modules' ) ) { |
|
86 | + if (is_multisite() && current_user_can('manage_network_wordpoints_modules')) { |
|
87 | 87 | |
88 | - $install_actions['network_activate'] = '<a class="button button-primary" href="' . wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=activate&networkwide=1&module=' . urlencode( $module_file ) ), "activate-module_{$module_file}" ) . '" target="_parent">' . esc_html__( 'Network Activate', 'wordpoints' ) . '</a>'; |
|
88 | + $install_actions['network_activate'] = '<a class="button button-primary" href="' . wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=activate&networkwide=1&module=' . urlencode($module_file)), "activate-module_{$module_file}") . '" target="_parent">' . esc_html__('Network Activate', 'wordpoints') . '</a>'; |
|
89 | 89 | |
90 | - } elseif ( current_user_can( 'activate_wordpoints_modules' ) ) { |
|
90 | + } elseif (current_user_can('activate_wordpoints_modules')) { |
|
91 | 91 | |
92 | - $install_actions['activate_module'] = '<a class="button button-primary" href="' . wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=activate&module=' . urlencode( $module_file ) ), "activate-module_{$module_file}" ) . '" target="_parent">' . esc_html__( 'Activate Module', 'wordpoints' ) . '</a>'; |
|
92 | + $install_actions['activate_module'] = '<a class="button button-primary" href="' . wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=activate&module=' . urlencode($module_file)), "activate-module_{$module_file}") . '" target="_parent">' . esc_html__('Activate Module', 'wordpoints') . '</a>'; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - $install_actions['modules_page'] = '<a href="' . esc_url( self_admin_url( 'admin.php?page=wordpoints_modules' ) ) . '" target="_parent">' . esc_html__( 'Return to Modules page', 'wordpoints' ) . '</a>'; |
|
97 | - $install_actions['install_page'] = '<a href="' . esc_url( self_admin_url( 'admin.php?page=wordpoints_install_modules' ) ) . '" target="_parent">' . esc_html__( 'Return to Module Installer', 'wordpoints' ) . '</a>'; |
|
96 | + $install_actions['modules_page'] = '<a href="' . esc_url(self_admin_url('admin.php?page=wordpoints_modules')) . '" target="_parent">' . esc_html__('Return to Modules page', 'wordpoints') . '</a>'; |
|
97 | + $install_actions['install_page'] = '<a href="' . esc_url(self_admin_url('admin.php?page=wordpoints_install_modules')) . '" target="_parent">' . esc_html__('Return to Module Installer', 'wordpoints') . '</a>'; |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * The install module action links. |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | * } |
113 | 113 | * @param string $module_file The main module file. |
114 | 114 | */ |
115 | - $install_actions = apply_filters( 'wordpoints_install_module_complete_actions', $install_actions, $module_file ); |
|
115 | + $install_actions = apply_filters('wordpoints_install_module_complete_actions', $install_actions, $module_file); |
|
116 | 116 | |
117 | - if ( ! empty( $install_actions ) ) { |
|
118 | - $this->feedback( implode( ' ', (array) $install_actions ) ); |
|
117 | + if ( ! empty($install_actions)) { |
|
118 | + $this->feedback(implode(' ', (array) $install_actions)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | } // function after() |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | private function install_strings() { |
50 | 50 | |
51 | 51 | $install_strings = array( |
52 | - 'no_package' => esc_html__( 'Install package not available.', 'wordpoints' ), |
|
53 | - 'unpack_package' => esc_html__( 'Unpacking the package…', 'wordpoints' ), |
|
54 | - 'installing_package' => esc_html__( 'Installing the module…', 'wordpoints' ), |
|
55 | - 'no_files' => esc_html__( 'The module contains no files.', 'wordpoints' ), |
|
56 | - 'process_failed' => esc_html__( 'Module install failed.', 'wordpoints' ), |
|
57 | - 'process_success' => esc_html__( 'Module installed successfully.', 'wordpoints' ), |
|
58 | - 'mkdir_failed_modules' => esc_html__( 'Could not create the modules directory.', 'wordpoints' ), |
|
52 | + 'no_package' => esc_html__('Install package not available.', 'wordpoints'), |
|
53 | + 'unpack_package' => esc_html__('Unpacking the package…', 'wordpoints'), |
|
54 | + 'installing_package' => esc_html__('Installing the module…', 'wordpoints'), |
|
55 | + 'no_files' => esc_html__('The module contains no files.', 'wordpoints'), |
|
56 | + 'process_failed' => esc_html__('Module install failed.', 'wordpoints'), |
|
57 | + 'process_success' => esc_html__('Module installed successfully.', 'wordpoints'), |
|
58 | + 'mkdir_failed_modules' => esc_html__('Could not create the modules directory.', 'wordpoints'), |
|
59 | 59 | ); |
60 | 60 | |
61 | - $this->strings = array_merge( $this->strings, $install_strings ); |
|
61 | + $this->strings = array_merge($this->strings, $install_strings); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // |
@@ -77,31 +77,31 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return array|WP_Error {@see WP_Upgrader::install_package()} |
79 | 79 | */ |
80 | - public function install_package( $args = array() ) { |
|
80 | + public function install_package($args = array()) { |
|
81 | 81 | |
82 | 82 | global $wp_filesystem, $wp_theme_directories; |
83 | 83 | |
84 | 84 | $modules_dir = wordpoints_modules_dir(); |
85 | 85 | |
86 | 86 | // Attempt to create the /wp-content/wordpoints-modules directory if needed. |
87 | - if ( ! $wp_filesystem->exists( $modules_dir ) ) { |
|
87 | + if ( ! $wp_filesystem->exists($modules_dir)) { |
|
88 | 88 | |
89 | - if ( $wp_filesystem->mkdir( $modules_dir, FS_CHMOD_DIR ) ) { |
|
90 | - $wp_filesystem->put_contents( $modules_dir . '/index.php', '<?php // Gold is silent.' ); |
|
89 | + if ($wp_filesystem->mkdir($modules_dir, FS_CHMOD_DIR)) { |
|
90 | + $wp_filesystem->put_contents($modules_dir . '/index.php', '<?php // Gold is silent.'); |
|
91 | 91 | } else { |
92 | - return new WP_Error( 'mkdir_failed_modules', $this->strings['mkdir_failed_modules'], $modules_dir ); |
|
92 | + return new WP_Error('mkdir_failed_modules', $this->strings['mkdir_failed_modules'], $modules_dir); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | $module_dir = wordpoints_modules_dir(); |
97 | 97 | $wp_theme_directories[] = $module_dir; |
98 | 98 | |
99 | - $result = parent::install_package( $args ); |
|
99 | + $result = parent::install_package($args); |
|
100 | 100 | |
101 | - $key = array_search( $module_dir, $wp_theme_directories ); |
|
101 | + $key = array_search($module_dir, $wp_theme_directories); |
|
102 | 102 | |
103 | - if ( false !== $key ) { |
|
104 | - unset( $wp_theme_directories[ $key ] ); |
|
103 | + if (false !== $key) { |
|
104 | + unset($wp_theme_directories[$key]); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $result; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return bool|WP_Error True on success, false or a WP_Error on failure. |
118 | 118 | */ |
119 | - public function install( $package ) { |
|
119 | + public function install($package) { |
|
120 | 120 | |
121 | 121 | $this->init(); |
122 | 122 | $this->install_strings(); |
123 | 123 | |
124 | - add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); |
|
124 | + add_filter('upgrader_source_selection', array($this, 'check_package')); |
|
125 | 125 | |
126 | 126 | $result = $this->run( |
127 | 127 | array( |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | ) |
134 | 134 | ); |
135 | 135 | |
136 | - remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); |
|
136 | + remove_filter('upgrader_source_selection', array($this, 'check_package')); |
|
137 | 137 | |
138 | - if ( ! $result || is_wp_error( $result ) ) { |
|
138 | + if ( ! $result || is_wp_error($result)) { |
|
139 | 139 | return $result; |
140 | 140 | } |
141 | 141 | |
142 | - if ( ! $this->result || is_wp_error( $this->result ) ) { |
|
142 | + if ( ! $this->result || is_wp_error($this->result)) { |
|
143 | 143 | return $this->result; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Force refresh of plugin update information. |
147 | - wp_cache_delete( 'wordpoints_modules', 'wordpoints_modules' ); |
|
147 | + wp_cache_delete('wordpoints_modules', 'wordpoints_modules'); |
|
148 | 148 | |
149 | 149 | return true; |
150 | 150 | } |
@@ -162,40 +162,40 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string|WP_Error The path to the source package or a WP_Error. |
164 | 164 | */ |
165 | - public function check_package( $source ) { |
|
165 | + public function check_package($source) { |
|
166 | 166 | |
167 | 167 | global $wp_filesystem; |
168 | 168 | |
169 | - if ( is_wp_error( $source ) ) { |
|
169 | + if (is_wp_error($source)) { |
|
170 | 170 | return $source; |
171 | 171 | } |
172 | 172 | |
173 | - $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); |
|
173 | + $working_directory = str_replace($wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); |
|
174 | 174 | |
175 | - if ( ! is_dir( $working_directory ) ) { |
|
175 | + if ( ! is_dir($working_directory)) { |
|
176 | 176 | return $source; |
177 | 177 | } |
178 | 178 | |
179 | 179 | $modules_found = false; |
180 | 180 | |
181 | - $files = glob( $working_directory . '*.php' ); |
|
181 | + $files = glob($working_directory . '*.php'); |
|
182 | 182 | |
183 | - if ( false === $files ) { |
|
183 | + if (false === $files) { |
|
184 | 184 | return $source; |
185 | 185 | } |
186 | 186 | |
187 | - foreach ( $files as $file ) { |
|
187 | + foreach ($files as $file) { |
|
188 | 188 | |
189 | - $module_data = wordpoints_get_module_data( $file, false, false ); |
|
189 | + $module_data = wordpoints_get_module_data($file, false, false); |
|
190 | 190 | |
191 | - if ( ! empty( $module_data['name'] ) ) { |
|
191 | + if ( ! empty($module_data['name'])) { |
|
192 | 192 | $modules_found = true; |
193 | 193 | break; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - if ( ! $modules_found ) { |
|
198 | - return new WP_Error( 'incompatible_archive_no_modules', $this->strings['incompatible_archive'], esc_html__( 'No valid modules were found.', 'wordpoints' ) ); |
|
197 | + if ( ! $modules_found) { |
|
198 | + return new WP_Error('incompatible_archive_no_modules', $this->strings['incompatible_archive'], esc_html__('No valid modules were found.', 'wordpoints')); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return $source; |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function module_info() { |
214 | 214 | |
215 | - if ( ! is_array( $this->result ) || empty( $this->result['destination_name'] ) ) { |
|
215 | + if ( ! is_array($this->result) || empty($this->result['destination_name'])) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | |
219 | - $module = wordpoints_get_modules( '/' . $this->result['destination_name'] ); |
|
219 | + $module = wordpoints_get_modules('/' . $this->result['destination_name']); |
|
220 | 220 | |
221 | - if ( empty( $module ) ) { |
|
221 | + if (empty($module)) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Assume the requested module is the first in the list. |
226 | - $module_files = array_keys( $module ); |
|
226 | + $module_files = array_keys($module); |
|
227 | 227 | |
228 | 228 | return $this->result['destination_name'] . '/' . $module_files[0]; |
229 | 229 | } |