@@ -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 | <?php // translators: Placeholder name. ?> |
179 | 179 | <small><i><?php echo esc_html( sprintf( __( '%s will be replaced with the points of the logged in user', 'wordpoints' ), '%points%' ) ); ?></i></small> |
180 | 180 | <?php |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | </p> |
193 | 193 | <p> |
194 | 194 | <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> |
195 | - <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'] ); ?>" /> |
|
195 | + <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' ] ); ?>" /> |
|
196 | 196 | <small><i><?php esc_html_e( 'Leave this field blank to hide the widget if the user is not logged in', 'wordpoints' ); ?></i></small> |
197 | 197 | </p> |
198 | 198 | <p> |
199 | 199 | <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> |
200 | - <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'] ); ?>" /> |
|
200 | + <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' ] ); ?>" /> |
|
201 | 201 | <small><i><?php esc_html_e( 'Set this to 0 to keep from showing any logs', 'wordpoints' ); ?></i></small> |
202 | 202 | </p> |
203 | 203 |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | $parts = explode( '\\', $slug, 2 ); |
71 | 71 | |
72 | - if ( isset( $parts[1] ) ) { |
|
73 | - $parsed['dynamic'] = $parts[1]; |
|
74 | - $parsed['generic'] = $parts[0]; |
|
72 | + if ( isset( $parts[ 1 ] ) ) { |
|
73 | + $parsed[ 'dynamic' ] = $parts[ 1 ]; |
|
74 | + $parsed[ 'generic' ] = $parts[ 0 ]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $parsed; |
@@ -347,19 +347,19 @@ discard block |
||
347 | 347 | |
348 | 348 | $supports = get_all_post_type_supports( $slug ); |
349 | 349 | |
350 | - if ( isset( $supports['title'] ) ) { |
|
350 | + if ( isset( $supports[ 'title' ] ) ) { |
|
351 | 351 | $children->register( "post\\{$slug}", 'title', 'WordPoints_Entity_Post_Title' ); |
352 | 352 | } |
353 | 353 | |
354 | - if ( isset( $supports['editor'] ) ) { |
|
354 | + if ( isset( $supports[ 'editor' ] ) ) { |
|
355 | 355 | $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
356 | 356 | } |
357 | 357 | |
358 | - if ( isset( $supports['excerpt'] ) ) { |
|
358 | + if ( isset( $supports[ 'excerpt' ] ) ) { |
|
359 | 359 | $children->register( "post\\{$slug}", 'excerpt', 'WordPoints_Entity_Post_Excerpt' ); |
360 | 360 | } |
361 | 361 | |
362 | - if ( isset( $supports['comments'] ) ) { |
|
362 | + if ( isset( $supports[ 'comments' ] ) ) { |
|
363 | 363 | |
364 | 364 | $children->register( "post\\{$slug}", 'comment_count', 'WordPoints_Entity_Post_Comment_Count' ); |
365 | 365 | |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | if ( |
487 | 487 | defined( 'DOING_AJAX' ) |
488 | 488 | && DOING_AJAX |
489 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
489 | + && isset( $_SERVER[ 'HTTP_REFERER' ] ) |
|
490 | 490 | && preg_match( |
491 | 491 | '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
492 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
492 | + , esc_url_raw( wp_unslash( $_SERVER[ 'HTTP_REFERER' ] ) ) |
|
493 | 493 | ) |
494 | 494 | ) { |
495 | 495 | return true; |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | |
31 | 31 | $parts = wordpoints_parse_dynamic_slug( $dynamic_slug ); |
32 | 32 | |
33 | - if ( $parts['dynamic'] ) { |
|
33 | + if ( $parts[ 'dynamic' ] ) { |
|
34 | 34 | |
35 | 35 | $parsed = $this->parse_slug( $this->related_entity_slug ); |
36 | 36 | |
37 | - $this->primary_entity_slug = "{$this->primary_entity_slug}\\{$parts['dynamic']}"; |
|
38 | - $this->related_entity_slug = "{$parsed['slug']}\\{$parts['dynamic']}"; |
|
37 | + $this->primary_entity_slug = "{$this->primary_entity_slug}\\{$parts[ 'dynamic' ]}"; |
|
38 | + $this->related_entity_slug = "{$parsed[ 'slug' ]}\\{$parts[ 'dynamic' ]}"; |
|
39 | 39 | |
40 | - if ( $parsed['is_array'] ) { |
|
40 | + if ( $parsed[ 'is_array' ] ) { |
|
41 | 41 | $this->related_entity_slug .= '{}'; |
42 | 42 | } |
43 | 43 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | $parsed = $this->parse_slug( $this->related_entity_slug ); |
52 | 52 | |
53 | - $entity = wordpoints_entities()->get( $parsed['slug'] ); |
|
53 | + $entity = wordpoints_entities()->get( $parsed[ 'slug' ] ); |
|
54 | 54 | |
55 | 55 | if ( $entity instanceof WordPoints_Entity ) { |
56 | 56 | return $entity->get_title(); |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct( $slug, array $action_args, array $args = array() ) { |
41 | 41 | |
42 | - if ( isset( $args['comment_type'] ) ) { |
|
43 | - $this->comment_type = $args['comment_type']; |
|
42 | + if ( isset( $args[ 'comment_type' ] ) ) { |
|
43 | + $this->comment_type = $args[ 'comment_type' ]; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | parent::__construct( $slug, $action_args, $args ); |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | $parts = wordpoints_parse_dynamic_slug( $this->slug ); |
57 | 57 | |
58 | - if ( ! $parts['dynamic'] ) { |
|
58 | + if ( ! $parts[ 'dynamic' ] ) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $arg_slug = str_replace( |
63 | 63 | '\\post' |
64 | - , '\\' . $parts['dynamic'] |
|
64 | + , '\\' . $parts[ 'dynamic' ] |
|
65 | 65 | , 'comment\\post' |
66 | 66 | ); |
67 | 67 |