@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @since 1.7.0 |
370 | 370 | * |
371 | - * @return int|false The ID of the rank, or false if not found. |
|
371 | + * @return integer The ID of the rank, or false if not found. |
|
372 | 372 | */ |
373 | 373 | public function get_base_rank() { |
374 | 374 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @param int $rank_id The ID of the rank to get the position of. |
404 | 404 | * |
405 | - * @return int|false The rank's position, or false. |
|
405 | + * @return integer The rank's position, or false. |
|
406 | 406 | */ |
407 | 407 | public function get_rank_position( $rank_id ) { |
408 | 408 |
@@ -440,7 +440,7 @@ |
||
440 | 440 | |
441 | 441 | } elseif ( $count < $position ) { |
442 | 442 | |
443 | - $ranks[] = $rank_id; |
|
443 | + $ranks[ ] = $rank_id; |
|
444 | 444 | |
445 | 445 | } else { |
446 | 446 |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | type="text" |
303 | 303 | id="points-name-<?php echo esc_attr( $slug ); ?>" |
304 | 304 | name="points-name" |
305 | - value="<?php echo esc_attr( $points_type['name'] ); ?>" |
|
305 | + value="<?php echo esc_attr( $points_type[ 'name' ] ); ?>" |
|
306 | 306 | <?php if ( ! $slug ) : ?> |
307 | 307 | autofocus |
308 | 308 | <?php endif; ?> |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | type="text" |
316 | 316 | id="points-prefix-<?php echo esc_attr( $slug ); ?>" |
317 | 317 | name="points-prefix" |
318 | - value="<?php echo esc_attr( $points_type['prefix'] ); ?>" |
|
318 | + value="<?php echo esc_attr( $points_type[ 'prefix' ] ); ?>" |
|
319 | 319 | /> |
320 | 320 | </p> |
321 | 321 | <p> |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | type="text" |
326 | 326 | id="points-suffix-<?php echo esc_attr( $slug ); ?>" |
327 | 327 | name="points-suffix" |
328 | - value="<?php echo esc_attr( $points_type['suffix'] ); ?>" |
|
328 | + value="<?php echo esc_attr( $points_type[ 'suffix' ] ); ?>" |
|
329 | 329 | /> |
330 | 330 | </p> |
331 | 331 | |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function display_event_meta_box( $points_type, $meta_box ) { |
549 | 549 | |
550 | - $event_slug = $meta_box['args']['slug']; |
|
550 | + $event_slug = $meta_box[ 'args' ][ 'slug' ]; |
|
551 | 551 | |
552 | 552 | $data = array(); |
553 | 553 | |
554 | 554 | foreach ( $this->reaction_store->get_reactions_to_event( $event_slug ) as $id => $reaction ) { |
555 | 555 | if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) { |
556 | - $data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
|
556 | + $data[ ] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
|
557 | 557 | $reaction |
558 | 558 | ); |
559 | 559 | } |
@@ -567,13 +567,13 @@ discard block |
||
567 | 567 | |
568 | 568 | foreach ( $this->event_args->get_children( $event_slug ) as $slug => $arg ) { |
569 | 569 | |
570 | - $event_data['args'][ $slug ] = array( |
|
570 | + $event_data[ 'args' ][ $slug ] = array( |
|
571 | 571 | 'slug' => $slug, |
572 | 572 | ); |
573 | 573 | |
574 | 574 | if ( $arg instanceof WordPoints_Hook_ArgI ) { |
575 | - $event_data['args'][ $slug ]['title'] = $arg->get_title(); |
|
576 | - $event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful(); |
|
575 | + $event_data[ 'args' ][ $slug ][ 'title' ] = $arg->get_title(); |
|
576 | + $event_data[ 'args' ][ $slug ][ 'is_stateful' ] = $arg->is_stateful(); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | <div class="wordpoints-hook-reaction-group-container"> |
588 | 588 | <p class="description wordpoints-hook-reaction-group-description"> |
589 | - <?php echo esc_html( $meta_box['args']['event']->get_description() ); ?> |
|
589 | + <?php echo esc_html( $meta_box[ 'args' ][ 'event' ]->get_description() ); ?> |
|
590 | 590 | </p> |
591 | 591 | |
592 | 592 | <div class="wordpoints-hook-reaction-group" |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | $tabs = array(); |
629 | 629 | |
630 | 630 | foreach ( $points_types as $slug => $settings ) { |
631 | - $tabs[ $slug ] = $settings['name']; |
|
631 | + $tabs[ $slug ] = $settings[ 'name' ]; |
|
632 | 632 | } |
633 | 633 | |
634 | - $tabs['add-new'] = __( 'Add New', 'wordpoints' ); |
|
634 | + $tabs[ 'add-new' ] = __( 'Add New', 'wordpoints' ); |
|
635 | 635 | |
636 | 636 | $tab = wordpoints_admin_get_current_tab( $tabs ); |
637 | 637 | |
@@ -655,15 +655,15 @@ discard block |
||
655 | 655 | return; |
656 | 656 | } |
657 | 657 | |
658 | - if ( isset( $_POST['save-points-type'] ) ) { // WPCS: CSRF OK |
|
658 | + if ( isset( $_POST[ 'save-points-type' ] ) ) { // WPCS: CSRF OK |
|
659 | 659 | |
660 | - if ( ! empty( $_POST['add_new'] ) ) { // WPCS: CSRF OK |
|
660 | + if ( ! empty( $_POST[ 'add_new' ] ) ) { // WPCS: CSRF OK |
|
661 | 661 | $this->add_points_type(); |
662 | 662 | } else { |
663 | 663 | $this->update_points_type(); |
664 | 664 | } |
665 | 665 | |
666 | - } elseif ( ! empty( $_POST['delete-points-type'] ) ) { // WPCS: CSRF OK |
|
666 | + } elseif ( ! empty( $_POST[ 'delete-points-type' ] ) ) { // WPCS: CSRF OK |
|
667 | 667 | |
668 | 668 | $this->delete_points_type(); |
669 | 669 | } |
@@ -680,21 +680,21 @@ discard block |
||
680 | 680 | |
681 | 681 | $settings = array(); |
682 | 682 | |
683 | - if ( isset( $_POST['points-name'] ) ) { // WPCS: CSRF OK |
|
684 | - $settings['name'] = trim( |
|
685 | - sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) // WPCS: CSRF OK |
|
683 | + if ( isset( $_POST[ 'points-name' ] ) ) { // WPCS: CSRF OK |
|
684 | + $settings[ 'name' ] = trim( |
|
685 | + sanitize_text_field( wp_unslash( $_POST[ 'points-name' ] ) ) // WPCS: CSRF OK |
|
686 | 686 | ); |
687 | 687 | } |
688 | 688 | |
689 | - if ( isset( $_POST['points-prefix'] ) ) { // WPCS: CSRF OK |
|
690 | - $settings['prefix'] = ltrim( |
|
691 | - sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) // WPCS: CSRF OK |
|
689 | + if ( isset( $_POST[ 'points-prefix' ] ) ) { // WPCS: CSRF OK |
|
690 | + $settings[ 'prefix' ] = ltrim( |
|
691 | + sanitize_text_field( wp_unslash( $_POST[ 'points-prefix' ] ) ) // WPCS: CSRF OK |
|
692 | 692 | ); |
693 | 693 | } |
694 | 694 | |
695 | - if ( isset( $_POST['points-suffix'] ) ) { // WPCS: CSRF OK |
|
696 | - $settings['suffix'] = rtrim( |
|
697 | - sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) // WPCS: CSRF OK |
|
695 | + if ( isset( $_POST[ 'points-suffix' ] ) ) { // WPCS: CSRF OK |
|
696 | + $settings[ 'suffix' ] = rtrim( |
|
697 | + sanitize_text_field( wp_unslash( $_POST[ 'points-suffix' ] ) ) // WPCS: CSRF OK |
|
698 | 698 | ); |
699 | 699 | } |
700 | 700 | |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | , array( 'points-slug' ) |
716 | 716 | , 'post' |
717 | 717 | ) |
718 | - || ! isset( $_POST['points-slug'] ) |
|
718 | + || ! isset( $_POST[ 'points-slug' ] ) |
|
719 | 719 | ) { |
720 | 720 | return; |
721 | 721 | } |
722 | 722 | |
723 | 723 | $settings = $this->get_points_type_settings(); |
724 | 724 | |
725 | - if ( empty( $settings['name'] ) ) { |
|
725 | + if ( empty( $settings[ 'name' ] ) ) { |
|
726 | 726 | |
727 | 727 | add_settings_error( |
728 | 728 | 'points-name' |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | return; |
734 | 734 | } |
735 | 735 | |
736 | - $points_type = sanitize_key( $_POST['points-slug'] ); |
|
736 | + $points_type = sanitize_key( $_POST[ 'points-slug' ] ); |
|
737 | 737 | |
738 | 738 | $old_settings = wordpoints_get_points_type( $points_type ); |
739 | 739 | |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | } else { |
805 | 805 | |
806 | - $_GET['tab'] = $slug; |
|
806 | + $_GET[ 'tab' ] = $slug; |
|
807 | 807 | |
808 | 808 | add_settings_error( |
809 | 809 | '' |
@@ -828,12 +828,12 @@ discard block |
||
828 | 828 | , array( 'points-slug' ) |
829 | 829 | , 'post' |
830 | 830 | ) |
831 | - && isset( $_POST['points-slug'] ) |
|
831 | + && isset( $_POST[ 'points-slug' ] ) |
|
832 | 832 | ) { |
833 | 833 | |
834 | 834 | if ( |
835 | 835 | wordpoints_delete_points_type( |
836 | - sanitize_key( $_POST['points-slug'] ) |
|
836 | + sanitize_key( $_POST[ 'points-slug' ] ) |
|
837 | 837 | ) |
838 | 838 | ) { |
839 | 839 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | |
927 | 927 | if ( isset( $this->current_points_type ) ) { |
928 | 928 | $points_type = wordpoints_get_points_type( $this->current_points_type ); |
929 | - $points_type['slug'] = $this->current_points_type; |
|
929 | + $points_type[ 'slug' ] = $this->current_points_type; |
|
930 | 930 | } else { |
931 | 931 | $points_type = false; |
932 | 932 | } |
@@ -245,8 +245,11 @@ discard block |
||
245 | 245 | <p> |
246 | 246 | <?php if ( $slug ) : ?> |
247 | 247 | <?php esc_html_e( 'Changes to this points type’s settings will affect all sites on this network.', 'wordpoints' ); ?> |
248 | - <?php else : ?> |
|
249 | - <?php esc_html_e( 'The new points type will be global across all sites on this network.', 'wordpoints' ); ?> |
|
248 | + <?php else { |
|
249 | + : ?> |
|
250 | + <?php esc_html_e( 'The new points type will be global across all sites on this network.', 'wordpoints' ); |
|
251 | +} |
|
252 | +?> |
|
250 | 253 | <?php endif; ?> |
251 | 254 | </p> |
252 | 255 | </div> |
@@ -655,15 +658,18 @@ discard block |
||
655 | 658 | return; |
656 | 659 | } |
657 | 660 | |
658 | - if ( isset( $_POST['save-points-type'] ) ) { // WPCS: CSRF OK |
|
661 | + if ( isset( $_POST['save-points-type'] ) ) { |
|
662 | +// WPCS: CSRF OK |
|
659 | 663 | |
660 | - if ( ! empty( $_POST['add_new'] ) ) { // WPCS: CSRF OK |
|
664 | + if ( ! empty( $_POST['add_new'] ) ) { |
|
665 | +// WPCS: CSRF OK |
|
661 | 666 | $this->add_points_type(); |
662 | 667 | } else { |
663 | 668 | $this->update_points_type(); |
664 | 669 | } |
665 | 670 | |
666 | - } elseif ( ! empty( $_POST['delete-points-type'] ) ) { // WPCS: CSRF OK |
|
671 | + } elseif ( ! empty( $_POST['delete-points-type'] ) ) { |
|
672 | +// WPCS: CSRF OK |
|
667 | 673 | |
668 | 674 | $this->delete_points_type(); |
669 | 675 | } |
@@ -680,19 +686,22 @@ discard block |
||
680 | 686 | |
681 | 687 | $settings = array(); |
682 | 688 | |
683 | - if ( isset( $_POST['points-name'] ) ) { // WPCS: CSRF OK |
|
689 | + if ( isset( $_POST['points-name'] ) ) { |
|
690 | +// WPCS: CSRF OK |
|
684 | 691 | $settings['name'] = trim( |
685 | 692 | sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) // WPCS: CSRF OK |
686 | 693 | ); |
687 | 694 | } |
688 | 695 | |
689 | - if ( isset( $_POST['points-prefix'] ) ) { // WPCS: CSRF OK |
|
696 | + if ( isset( $_POST['points-prefix'] ) ) { |
|
697 | +// WPCS: CSRF OK |
|
690 | 698 | $settings['prefix'] = ltrim( |
691 | 699 | sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) // WPCS: CSRF OK |
692 | 700 | ); |
693 | 701 | } |
694 | 702 | |
695 | - if ( isset( $_POST['points-suffix'] ) ) { // WPCS: CSRF OK |
|
703 | + if ( isset( $_POST['points-suffix'] ) ) { |
|
704 | +// WPCS: CSRF OK |
|
696 | 705 | $settings['suffix'] = rtrim( |
697 | 706 | sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) // WPCS: CSRF OK |
698 | 707 | ); |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! isset( $_GET['edithook'] ) ) { // WPCS: CSRF OK. |
|
10 | +if ( ! isset( $_GET[ 'edithook' ] ) ) { // WPCS: CSRF OK. |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | -$hook_id = sanitize_key( $_GET['edithook'] ); |
|
14 | +$hook_id = sanitize_key( $_GET[ 'edithook' ] ); |
|
15 | 15 | |
16 | 16 | $points_types = wordpoints_get_points_types(); |
17 | 17 | |
18 | -if ( isset( $_GET['addnew'] ) ) { // WPCS: CSRF OK. |
|
18 | +if ( isset( $_GET[ 'addnew' ] ) ) { // WPCS: CSRF OK. |
|
19 | 19 | |
20 | 20 | // - We are adding a new points hook. |
21 | 21 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if ( isset( $_GET['base'], $_GET['num'] ) ) { // WPCS: CSRF OK. |
|
36 | + if ( isset( $_GET[ 'base' ], $_GET[ 'num' ] ) ) { // WPCS: CSRF OK. |
|
37 | 37 | |
38 | 38 | // Copy minimal info from an existing instance of this hook to a new instance. |
39 | 39 | $hook = WordPoints_Points_Hooks::get_handler_by_id_base( |
40 | - sanitize_key( $_GET['base'] ) // WPCS: CSRF OK. |
|
40 | + sanitize_key( $_GET[ 'base' ] ) // WPCS: CSRF OK. |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | if ( ! $hook ) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
53 | - $multi_number = (int) $_GET['num']; |
|
53 | + $multi_number = (int) $_GET[ 'num' ]; |
|
54 | 54 | $number = 0; |
55 | 55 | $hook_id = $hook->get_id( $multi_number ); |
56 | 56 | $_hook = $hook; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | // We are editing an existing points hook. |
72 | 72 | |
73 | - $points_type = isset( $_GET['points_type'] ) ? sanitize_key( $_GET['points_type'] ) : '_inactive_hooks'; // WPCS: CSRF OK. |
|
73 | + $points_type = isset( $_GET[ 'points_type' ] ) ? sanitize_key( $_GET[ 'points_type' ] ) : '_inactive_hooks'; // WPCS: CSRF OK. |
|
74 | 74 | |
75 | 75 | $hook = WordPoints_Points_Hooks::get_handler( $hook_id ); |
76 | 76 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | </div> |
131 | 131 | <br /> |
132 | 132 | <div class="hook-control-actions"> |
133 | - <?php if ( isset( $_GET['addnew'] ) ) : /* WPCS: CSRF OK. */ ?> |
|
133 | + <?php if ( isset( $_GET[ 'addnew' ] ) ) : /* WPCS: CSRF OK. */ ?> |
|
134 | 134 | <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" class="button alignleft"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></a> |
135 | 135 | <?php else : ?> |
136 | 136 | <?php submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false ); ?> |
@@ -7,7 +7,8 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! isset( $_GET['edithook'] ) ) { // WPCS: CSRF OK. |
|
10 | +if ( ! isset( $_GET['edithook'] ) ) { |
|
11 | +// WPCS: CSRF OK. |
|
11 | 12 | return; |
12 | 13 | } |
13 | 14 | |
@@ -15,7 +16,8 @@ discard block |
||
15 | 16 | |
16 | 17 | $points_types = wordpoints_get_points_types(); |
17 | 18 | |
18 | -if ( isset( $_GET['addnew'] ) ) { // WPCS: CSRF OK. |
|
19 | +if ( isset( $_GET['addnew'] ) ) { |
|
20 | +// WPCS: CSRF OK. |
|
19 | 21 | |
20 | 22 | // - We are adding a new points hook. |
21 | 23 | |
@@ -33,7 +35,8 @@ discard block |
||
33 | 35 | return; |
34 | 36 | } |
35 | 37 | |
36 | - if ( isset( $_GET['base'], $_GET['num'] ) ) { // WPCS: CSRF OK. |
|
38 | + if ( isset( $_GET['base'], $_GET['num'] ) ) { |
|
39 | +// WPCS: CSRF OK. |
|
37 | 40 | |
38 | 41 | // Copy minimal info from an existing instance of this hook to a new instance. |
39 | 42 | $hook = WordPoints_Points_Hooks::get_handler_by_id_base( |
@@ -132,8 +135,11 @@ discard block |
||
132 | 135 | <div class="hook-control-actions"> |
133 | 136 | <?php if ( isset( $_GET['addnew'] ) ) : /* WPCS: CSRF OK. */ ?> |
134 | 137 | <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" class="button alignleft"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></a> |
135 | - <?php else : ?> |
|
136 | - <?php submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false ); ?> |
|
138 | + <?php else { |
|
139 | + : ?> |
|
140 | + <?php submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false ); |
|
141 | +} |
|
142 | +?> |
|
137 | 143 | <?php endif; ?> |
138 | 144 | |
139 | 145 | <?php submit_button( __( 'Save Hook', 'wordpoints' ), 'button-primary alignright', 'savehook', false ); ?> |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function get_settings_fields() { |
60 | 60 | |
61 | - $this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
62 | - $this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
63 | - $this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' ); |
|
61 | + $this->settings_fields[ 'points' ][ 'label' ] = _x( 'Points', 'form label', 'wordpoints' ); |
|
62 | + $this->settings_fields[ 'log_text' ][ 'label' ] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
63 | + $this->settings_fields[ 'description' ][ 'label' ] = _x( 'Description', 'form label', 'wordpoints' ); |
|
64 | 64 | |
65 | 65 | return parent::get_settings_fields(); |
66 | 66 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | $data = parent::get_ui_script_data(); |
74 | 74 | |
75 | - $data['target_label'] = __( 'Award To', 'wordpoints' ); |
|
76 | - $data['periods_label'] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
75 | + $data[ 'target_label' ] = __( 'Award To', 'wordpoints' ); |
|
76 | + $data[ 'periods_label' ] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
77 | 77 | |
78 | 78 | return $data; |
79 | 79 | } |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | WordPoints_Hook_Event_Args $event_args |
88 | 88 | ) { |
89 | 89 | |
90 | - if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) { |
|
90 | + if ( ! isset( $settings[ 'points' ] ) || false === wordpoints_int( $settings[ 'points' ] ) ) { |
|
91 | 91 | $validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' ); |
92 | 92 | } |
93 | 93 | |
94 | - if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
94 | + if ( ! isset( $settings[ 'points_type' ] ) || ! wordpoints_is_points_type( $settings[ 'points_type' ] ) ) { |
|
95 | 95 | $validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' ); |
96 | 96 | } |
97 | 97 | |
98 | - if ( ! isset( $settings['description'] ) ) { |
|
98 | + if ( ! isset( $settings[ 'description' ] ) ) { |
|
99 | 99 | $validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' ); |
100 | 100 | } |
101 | 101 | |
102 | - if ( ! isset( $settings['log_text'] ) ) { |
|
102 | + if ( ! isset( $settings[ 'log_text' ] ) ) { |
|
103 | 103 | $validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' ); |
104 | 104 | } |
105 | 105 | |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | |
117 | 117 | parent::update_settings( $reaction, $settings ); |
118 | 118 | |
119 | - $reaction->update_meta( 'points', $settings['points'] ); |
|
120 | - $reaction->update_meta( 'points_type', $settings['points_type'] ); |
|
121 | - $reaction->update_meta( 'description', $settings['description'] ); |
|
122 | - $reaction->update_meta( 'log_text', $settings['log_text'] ); |
|
119 | + $reaction->update_meta( 'points', $settings[ 'points' ] ); |
|
120 | + $reaction->update_meta( 'points_type', $settings[ 'points_type' ] ); |
|
121 | + $reaction->update_meta( 'description', $settings[ 'description' ] ); |
|
122 | + $reaction->update_meta( 'log_text', $settings[ 'log_text' ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
204 | 204 | |
205 | 205 | // We closely integrate with the reversals extension to get the hit IDs. |
206 | - if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) { |
|
206 | + if ( ! isset( $fire->data[ 'reversals' ][ 'hit_ids' ] ) ) { |
|
207 | 207 | return array(); |
208 | 208 | } |
209 | 209 | |
210 | - return $fire->data['reversals']['hit_ids']; |
|
210 | + return $fire->data[ 'reversals' ][ 'hit_ids' ]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -102,7 +102,7 @@ |
||
102 | 102 | ); |
103 | 103 | |
104 | 104 | self::$queries[ $slug ] = array_merge( $defaults, $data ); |
105 | - self::$queries[ $slug ]['args'] = $args; |
|
105 | + self::$queries[ $slug ][ 'args' ] = $args; |
|
106 | 106 | |
107 | 107 | return true; |
108 | 108 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | ); |
274 | 274 | |
275 | 275 | $reaction_settings = array( |
276 | - 'points' => $legacy_instance['points'], |
|
276 | + 'points' => $legacy_instance[ 'points' ], |
|
277 | 277 | 'target' => $this->target, |
278 | 278 | 'reactor' => 'points_legacy', |
279 | 279 | 'event' => $this->event_slug, |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | $order |
295 | 295 | ); |
296 | 296 | |
297 | - if ( ! isset( $reaction_settings['log_text'] ) ) { |
|
298 | - $reaction_settings['log_text'] = $this->get_log_text_for_instance( |
|
297 | + if ( ! isset( $reaction_settings[ 'log_text' ] ) ) { |
|
298 | + $reaction_settings[ 'log_text' ] = $this->get_log_text_for_instance( |
|
299 | 299 | $points_type |
300 | 300 | ); |
301 | 301 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | |
334 | 334 | if ( |
335 | 335 | $this->skip_non_reversing_hooks |
336 | - && isset( $this->legacy_instance['auto_reverse'] ) |
|
337 | - && ! $this->legacy_instance['auto_reverse'] |
|
336 | + && isset( $this->legacy_instance[ 'auto_reverse' ] ) |
|
337 | + && ! $this->legacy_instance[ 'auto_reverse' ] |
|
338 | 338 | ) { |
339 | 339 | return false; |
340 | 340 | } |
@@ -359,17 +359,17 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | if ( |
362 | - ! isset( $meta['post_type'] ) |
|
363 | - && isset( $this->legacy_instance['post_type'] ) |
|
362 | + ! isset( $meta[ 'post_type' ] ) |
|
363 | + && isset( $this->legacy_instance[ 'post_type' ] ) |
|
364 | 364 | ) { |
365 | - $meta['post_type'] = $this->legacy_instance['post_type']; |
|
365 | + $meta[ 'post_type' ] = $this->legacy_instance[ 'post_type' ]; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | if ( |
369 | - ! isset( $meta['period'] ) |
|
370 | - && isset( $this->legacy_instance['period'] ) |
|
369 | + ! isset( $meta[ 'period' ] ) |
|
370 | + && isset( $this->legacy_instance[ 'period' ] ) |
|
371 | 371 | ) { |
372 | - $meta['period'] = $this->legacy_instance['period']; |
|
372 | + $meta[ 'period' ] = $this->legacy_instance[ 'period' ]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | return $this->legacy_handler->logs( |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | |
399 | 399 | if ( 'wordpoints_periodic_points_hook' === $this->legacy_id_base ) { |
400 | 400 | |
401 | - $settings['points_legacy_periods'] = array( |
|
401 | + $settings[ 'points_legacy_periods' ] = array( |
|
402 | 402 | 'fire' => array( |
403 | 403 | array( |
404 | - 'length' => $this->legacy_instance['period'], |
|
404 | + 'length' => $this->legacy_instance[ 'period' ], |
|
405 | 405 | 'args' => array( array( 'current:user' ) ), |
406 | 406 | ), |
407 | 407 | ), |
@@ -411,21 +411,21 @@ discard block |
||
411 | 411 | |
412 | 412 | // We do this even if reversals will be blocked, in case the blocking |
413 | 413 | // is ever removed for this reaction. |
414 | - $settings['points_legacy_reversals'] = array( |
|
414 | + $settings[ 'points_legacy_reversals' ] = array( |
|
415 | 415 | 'toggle_off' => 'toggle_on', |
416 | 416 | ); |
417 | 417 | } |
418 | 418 | |
419 | 419 | if ( |
420 | - isset( $this->legacy_instance['auto_reverse'] ) |
|
421 | - && ! $this->legacy_instance['auto_reverse'] |
|
420 | + isset( $this->legacy_instance[ 'auto_reverse' ] ) |
|
421 | + && ! $this->legacy_instance[ 'auto_reverse' ] |
|
422 | 422 | ) { |
423 | - $settings['blocker']['toggle_off'] = true; |
|
423 | + $settings[ 'blocker' ][ 'toggle_off' ] = true; |
|
424 | 424 | } |
425 | 425 | |
426 | - if ( isset( $this->legacy_instance['post_type'] ) ) { |
|
426 | + if ( isset( $this->legacy_instance[ 'post_type' ] ) ) { |
|
427 | 427 | |
428 | - $post_type = $this->legacy_instance['post_type']; |
|
428 | + $post_type = $this->legacy_instance[ 'post_type' ]; |
|
429 | 429 | |
430 | 430 | if ( 'ALL' === $post_type ) { |
431 | 431 | |
@@ -467,36 +467,36 @@ discard block |
||
467 | 467 | protected function format_settings_for_post_type( $post_type, $settings ) { |
468 | 468 | |
469 | 469 | if ( |
470 | - 'post_publish\post' === $settings['event'] |
|
471 | - || 'points_legacy_post_publish\post' === $settings['event'] |
|
470 | + 'post_publish\post' === $settings[ 'event' ] |
|
471 | + || 'points_legacy_post_publish\post' === $settings[ 'event' ] |
|
472 | 472 | ) { |
473 | 473 | |
474 | 474 | if ( 'attachment' === $post_type ) { |
475 | 475 | |
476 | - $settings['event'] = 'media_upload'; |
|
476 | + $settings[ 'event' ] = 'media_upload'; |
|
477 | 477 | |
478 | 478 | } else { |
479 | 479 | |
480 | - $settings['points_legacy_repeat_blocker'] = array( |
|
480 | + $settings[ 'points_legacy_repeat_blocker' ] = array( |
|
481 | 481 | 'toggle_on' => true, |
482 | 482 | ); |
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - $settings['event'] = str_replace( |
|
486 | + $settings[ 'event' ] = str_replace( |
|
487 | 487 | '\post' |
488 | 488 | , '\\' . $post_type |
489 | - , $settings['event'] |
|
489 | + , $settings[ 'event' ] |
|
490 | 490 | ); |
491 | 491 | |
492 | - $settings['target'] = str_replace( |
|
492 | + $settings[ 'target' ] = str_replace( |
|
493 | 493 | '\post' |
494 | 494 | , '\\' . $post_type |
495 | - , $settings['target'] |
|
495 | + , $settings[ 'target' ] |
|
496 | 496 | ); |
497 | 497 | |
498 | - $settings['log_text'] = $this->get_log_text_for_instance( |
|
499 | - $settings['points_type'] |
|
498 | + $settings[ 'log_text' ] = $this->get_log_text_for_instance( |
|
499 | + $settings[ 'points_type' ] |
|
500 | 500 | , array( 'post_type' => $post_type ) |
501 | 501 | ); |
502 | 502 | |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | return false; |
522 | 522 | } |
523 | 523 | |
524 | - $this->imported_hooks[] = array( |
|
524 | + $this->imported_hooks[ ] = array( |
|
525 | 525 | 'order' => $order, |
526 | 526 | 'id_base' => $this->legacy_id_base, |
527 | 527 | 'instance' => $this->legacy_instance, |
528 | - 'points_type' => $settings['points_type'], |
|
528 | + 'points_type' => $settings[ 'points_type' ], |
|
529 | 529 | 'reaction_id' => $reaction->get_id(), |
530 | 530 | ); |
531 | 531 |
@@ -72,22 +72,22 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function verify_settings( $instance ) { |
74 | 74 | |
75 | - if ( ! is_user_logged_in() && empty( $instance['alt_text'] ) ) { |
|
75 | + if ( ! is_user_logged_in() && empty( $instance[ 'alt_text' ] ) ) { |
|
76 | 76 | return new WP_Error(); |
77 | 77 | } |
78 | 78 | |
79 | 79 | if ( |
80 | - ! isset( $instance['number_logs'] ) |
|
81 | - || ! wordpoints_posint( $instance['number_logs'] ) |
|
80 | + ! isset( $instance[ 'number_logs' ] ) |
|
81 | + || ! wordpoints_posint( $instance[ 'number_logs' ] ) |
|
82 | 82 | ) { |
83 | - $instance['number_logs'] = 0; |
|
83 | + $instance[ 'number_logs' ] = 0; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // In case the points type isn't set, we do this first. |
87 | 87 | $instance = WordPoints_Points_Widget::verify_settings( $instance ); |
88 | 88 | |
89 | - if ( ! is_wp_error( $instance ) && is_user_logged_in() && empty( $instance['text'] ) ) { |
|
90 | - $instance['text'] = wordpoints_get_points_type_setting( $instance['points_type'], 'name' ) . ': %points%'; |
|
89 | + if ( ! is_wp_error( $instance ) && is_user_logged_in() && empty( $instance[ 'text' ] ) ) { |
|
90 | + $instance[ 'text' ] = wordpoints_get_points_type_setting( $instance[ 'points_type' ], 'name' ) . ': %points%'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $instance; |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | $text = str_replace( |
105 | 105 | '%points%', |
106 | 106 | wordpoints_format_points( |
107 | - wordpoints_get_points( get_current_user_id(), $instance['points_type'] ), |
|
108 | - $instance['points_type'], |
|
107 | + wordpoints_get_points( get_current_user_id(), $instance[ 'points_type' ] ), |
|
108 | + $instance[ 'points_type' ], |
|
109 | 109 | 'my_points_widget' |
110 | 110 | ), |
111 | - $instance['text'] |
|
111 | + $instance[ 'text' ] |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | } else { |
115 | 115 | |
116 | - $text = $instance['alt_text']; |
|
116 | + $text = $instance[ 'alt_text' ]; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | echo '<div class="wordpoints-points-widget-text">', $text, '</div><br />'; // XSS OK, WPCS |
136 | 136 | |
137 | - if ( is_user_logged_in() && 0 !== $instance['number_logs'] ) { |
|
137 | + if ( is_user_logged_in() && 0 !== $instance[ 'number_logs' ] ) { |
|
138 | 138 | parent::widget_body( $instance ); |
139 | 139 | } |
140 | 140 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function update( $new_instance, $old_instance ) { |
154 | 154 | |
155 | - $this->defaults['number_logs'] = 0; |
|
155 | + $this->defaults[ 'number_logs' ] = 0; |
|
156 | 156 | |
157 | 157 | parent::update( $new_instance, $old_instance ); |
158 | 158 | |
159 | - $this->instance['text'] = trim( $this->instance['text'] ); |
|
160 | - $this->instance['alt_text'] = trim( $this->instance['alt_text'] ); |
|
159 | + $this->instance[ 'text' ] = trim( $this->instance[ 'text' ] ); |
|
160 | + $this->instance[ 'alt_text' ] = trim( $this->instance[ 'alt_text' ] ); |
|
161 | 161 | |
162 | 162 | return $this->instance; |
163 | 163 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | <p> |
176 | 176 | <label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Widget text', 'wordpoints' ); ?></label> |
177 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" value="<?php echo esc_attr( $this->instance['text'] ); ?>" /> |
|
177 | + <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" value="<?php echo esc_attr( $this->instance[ 'text' ] ); ?>" /> |
|
178 | 178 | <small> |
179 | 179 | <i> |
180 | 180 | <?php |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | </p> |
201 | 201 | <p> |
202 | 202 | <label for="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>"><?php esc_html_e( 'Text if the user is not logged in', 'wordpoints' ); ?></label> |
203 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'alt_text' ) ); ?>" value="<?php echo esc_attr( $this->instance['alt_text'] ); ?>" /> |
|
203 | + <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'alt_text' ) ); ?>" value="<?php echo esc_attr( $this->instance[ 'alt_text' ] ); ?>" /> |
|
204 | 204 | <small><i><?php esc_html_e( 'Leave this field blank to hide the widget if the user is not logged in', 'wordpoints' ); ?></i></small> |
205 | 205 | </p> |
206 | 206 | <p> |
207 | 207 | <label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of latest log entries for this user to display', 'wordpoints' ); ?></label> |
208 | - <input type="number" min="0" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo esc_attr( $this->instance['number_logs'] ); ?>" /> |
|
208 | + <input type="number" min="0" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo esc_attr( $this->instance[ 'number_logs' ] ); ?>" /> |
|
209 | 209 | <small><i><?php esc_html_e( 'Set this to 0 to keep from showing any logs', 'wordpoints' ); ?></i></small> |
210 | 210 | </p> |
211 | 211 |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | |
83 | - if ( isset( $sub_args['_conditions'] ) && '}' === substr( $arg_slug, -1 ) ) { |
|
84 | - $sub_args['_conditions'] = $this->process_conditions( |
|
85 | - $sub_args['_conditions'] |
|
83 | + if ( isset( $sub_args[ '_conditions' ] ) && '}' === substr( $arg_slug, -1 ) ) { |
|
84 | + $sub_args[ '_conditions' ] = $this->process_conditions( |
|
85 | + $sub_args[ '_conditions' ] |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | |
106 | 106 | foreach ( $conditions as $index => $condition ) { |
107 | 107 | |
108 | - if ( 'contains' === $condition['type'] ) { |
|
109 | - $condition['settings'] = $this->process_condition( |
|
110 | - $condition['settings'] |
|
108 | + if ( 'contains' === $condition[ 'type' ] ) { |
|
109 | + $condition[ 'settings' ] = $this->process_condition( |
|
110 | + $condition[ 'settings' ] |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function process_condition( $settings ) { |
130 | 130 | |
131 | - if ( isset( $settings['max'] ) && empty( $settings['max'] ) ) { |
|
131 | + if ( isset( $settings[ 'max' ] ) && empty( $settings[ 'max' ] ) ) { |
|
132 | 132 | |
133 | - $settings['max'] = 0; |
|
133 | + $settings[ 'max' ] = 0; |
|
134 | 134 | |
135 | 135 | $this->changed = true; |
136 | 136 | } |
137 | 137 | |
138 | - if ( isset( $settings['conditions'] ) ) { |
|
139 | - $settings['conditions'] = $this->walk_args( $settings['conditions'] ); |
|
138 | + if ( isset( $settings[ 'conditions' ] ) ) { |
|
139 | + $settings[ 'conditions' ] = $this->walk_args( $settings[ 'conditions' ] ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $settings; |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | |
62 | 62 | foreach ( $this->hooks as $data ) { |
63 | 63 | $this->split_hooks( |
64 | - $data['hook'], |
|
65 | - $data['new_hook'], |
|
66 | - $data['key'], |
|
67 | - $data['split_key'] |
|
64 | + $data[ 'hook' ], |
|
65 | + $data[ 'new_hook' ], |
|
66 | + $data[ 'key' ], |
|
67 | + $data[ 'split_key' ] |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | |
110 | - if ( ! isset( $settings['post_type'] ) ) { |
|
111 | - $settings['post_type'] = 'ALL'; |
|
110 | + if ( ! isset( $settings[ 'post_type' ] ) ) { |
|
111 | + $settings[ 'post_type' ] = 'ALL'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // If the trash points are set, create a post delete points hook instead. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $new_hook->update_callback( |
118 | 118 | array( |
119 | 119 | 'points' => $settings[ $split_key ], |
120 | - 'post_type' => $settings['post_type'], |
|
120 | + 'post_type' => $settings[ 'post_type' ], |
|
121 | 121 | ) |
122 | 122 | , $new_hook->next_hook_id_number() |
123 | 123 | ); |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | $points_type = $hook->points_type( $network_ . $number ); |
127 | 127 | |
128 | 128 | // Add this instance to the points-types-hooks list. |
129 | - $points_types_hooks[ $points_type ][] = $new_hook->get_id( $number ); |
|
129 | + $points_types_hooks[ $points_type ][ ] = $new_hook->get_id( $number ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // If the publish points are set, update the settings of the hook. |
133 | 133 | if ( isset( $settings[ $key ] ) && wordpoints_posint( $settings[ $key ] ) ) { |
134 | 134 | |
135 | - $settings['points'] = $settings[ $key ]; |
|
135 | + $settings[ 'points' ] = $settings[ $key ]; |
|
136 | 136 | |
137 | 137 | $hook->update_callback( $settings, $number ); |
138 | 138 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | public function clean_hook_settings( $instance, $new_instance, $old_instance, $hook ) { |
167 | 167 | |
168 | 168 | if ( $hook instanceof WordPoints_Post_Points_Hook ) { |
169 | - unset( $instance['trash'], $instance['publish'] ); |
|
169 | + unset( $instance[ 'trash' ], $instance[ 'publish' ] ); |
|
170 | 170 | } elseif ( $hook instanceof WordPoints_Comment_Points_Hook ) { |
171 | - unset( $instance['approve'], $instance['disapprove'] ); |
|
171 | + unset( $instance[ 'approve' ], $instance[ 'disapprove' ] ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $instance; |