Completed
Push — master ( 4d4020...9bbfca )
by J.D.
04:20
created
src/components/points/classes/widget.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,21 +21,21 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	protected function verify_settings( $instance ) {
23 23
 
24
-		if ( isset( $this->defaults['points_type'] ) ) {
24
+		if ( isset( $this->defaults[ 'points_type' ] ) ) {
25 25
 
26 26
 			// This happens when the widget is first created in the Customizer; the
27 27
 			// settings are completely empty.
28
-			if ( empty( $instance['points_type'] ) ) {
29
-				$default = $this->defaults['points_type'];
28
+			if ( empty( $instance[ 'points_type' ] ) ) {
29
+				$default = $this->defaults[ 'points_type' ];
30 30
 
31 31
 				if ( ! $default ) {
32 32
 					$this->make_a_points_type( $default );
33 33
 				}
34 34
 
35
-				$instance['points_type'] = $default;
35
+				$instance[ 'points_type' ] = $default;
36 36
 			}
37 37
 
38
-			if ( ! wordpoints_is_points_type( $instance['points_type'] ) ) {
38
+			if ( ! wordpoints_is_points_type( $instance[ 'points_type' ] ) ) {
39 39
 				return new WP_Error(
40 40
 					'wordpoints_widget_invalid_points_type'
41 41
 					, esc_html__( 'Please select a valid points type.', 'wordpoints' )
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 		parent::update( $new_instance, $old_instance );
81 81
 
82
-		$this->make_a_points_type( $this->instance['points_type'] );
82
+		$this->make_a_points_type( $this->instance[ 'points_type' ] );
83 83
 
84 84
 		return $this->instance;
85 85
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	public function form_points_type_field() {
105 105
 
106 106
 		$dropdown_args = array(
107
-			'selected' => $this->instance['points_type'],
107
+			'selected' => $this->instance[ 'points_type' ],
108 108
 			'id'       => $this->get_field_id( 'points_type' ),
109 109
 			'name'     => $this->get_field_name( 'points_type' ),
110 110
 			'class'    => 'widefat',
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		?>
114 114
 
115 115
 		<p>
116
-			<label for="<?php echo esc_attr( $dropdown_args['id'] ); ?>"><?php echo esc_html_x( 'Points type', 'form label', 'wordpoints' ); ?></label>
116
+			<label for="<?php echo esc_attr( $dropdown_args[ 'id' ] ); ?>"><?php echo esc_html_x( 'Points type', 'form label', 'wordpoints' ); ?></label>
117 117
 			<?php wordpoints_points_types_dropdown( $dropdown_args ); ?>
118 118
 		</p>
119 119
 
Please login to merge, or discard this patch.
src/components/points/classes/widget/logs.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	protected function verify_settings( $instance ) {
80 80
 
81
-		if ( ! wordpoints_posint( $instance['number_logs'] ) ) {
82
-			$instance['number_logs'] = $this->defaults['number_logs'];
81
+		if ( ! wordpoints_posint( $instance[ 'number_logs' ] ) ) {
82
+			$instance[ 'number_logs' ] = $this->defaults[ 'number_logs' ];
83 83
 		}
84 84
 
85 85
 		return parent::verify_settings( $instance );
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	protected function widget_body( $instance ) {
93 93
 
94 94
 		$query_args = wordpoints_get_points_logs_query_args(
95
-			$instance['points_type']
95
+			$instance[ 'points_type' ]
96 96
 			, $this->query_slug
97 97
 		);
98 98
 
99
-		$query_args['limit'] = $instance['number_logs'];
99
+		$query_args[ 'limit' ] = $instance[ 'number_logs' ];
100 100
 
101 101
 		$logs_query = new WordPoints_Points_Logs_Query( $query_args );
102 102
 		$logs_query->prime_cache( $this->cache_key );
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function add_points_logs_table_extra_classes( $classes ) {
129 129
 
130
-		if ( $this->instance && isset( $this->instance['columns'] ) ) {
131
-			foreach ( $this->defaults['columns'] as $column => $unused ) {
132
-				if ( empty( $this->instance['columns'][ $column ] ) ) {
133
-					$classes[] = "wordpoints-hide-{$column}-column";
130
+		if ( $this->instance && isset( $this->instance[ 'columns' ] ) ) {
131
+			foreach ( $this->defaults[ 'columns' ] as $column => $unused ) {
132
+				if ( empty( $this->instance[ 'columns' ][ $column ] ) ) {
133
+					$classes[ ] = "wordpoints-hide-{$column}-column";
134 134
 				}
135 135
 			}
136 136
 		}
137 137
 
138
-		if ( ! empty( $this->instance['hide_user_names'] ) ) {
139
-			$classes[] = 'wordpoints-hide-user-names';
138
+		if ( ! empty( $this->instance[ 'hide_user_names' ] ) ) {
139
+			$classes[ ] = 'wordpoints-hide-user-names';
140 140
 		}
141 141
 
142
-		if ( ! empty( $this->instance['horizontal_scrolling'] ) ) {
143
-			$classes[] = 'wordpoints-force-horizontal-scrolling';
142
+		if ( ! empty( $this->instance[ 'horizontal_scrolling' ] ) ) {
143
+			$classes[ ] = 'wordpoints-force-horizontal-scrolling';
144 144
 		}
145 145
 
146 146
 		return $classes;
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 
162 162
 		parent::update( $new_instance, $old_instance );
163 163
 
164
-		if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) {
165
-			$this->instance['number_logs'] = $this->defaults['number_logs'];
164
+		if ( ! wordpoints_posint( $this->instance[ 'number_logs' ] ) ) {
165
+			$this->instance[ 'number_logs' ] = $this->defaults[ 'number_logs' ];
166 166
 		}
167 167
 
168
-		foreach ( $this->instance['columns'] as $column => $value ) {
168
+		foreach ( $this->instance[ 'columns' ] as $column => $value ) {
169 169
 
170
-			if ( ! isset( $this->defaults['columns'][ $column ] ) ) {
171
-				unset( $this->instance['columns'][ $column ] );
170
+			if ( ! isset( $this->defaults[ 'columns' ][ $column ] ) ) {
171
+				unset( $this->instance[ 'columns' ][ $column ] );
172 172
 			} elseif ( $value ) {
173
-				$this->instance['columns'][ $column ] = '1';
173
+				$this->instance[ 'columns' ][ $column ] = '1';
174 174
 			}
175 175
 		}
176 176
 
177
-		if ( ! isset( $new_instance['hide_user_names'] ) ) {
178
-			unset( $this->instance['hide_user_names'] );
179
-		} elseif ( ! empty( $this->instance['hide_user_names'] ) ) {
180
-			$this->instance['hide_user_names'] = '1';
177
+		if ( ! isset( $new_instance[ 'hide_user_names' ] ) ) {
178
+			unset( $this->instance[ 'hide_user_names' ] );
179
+		} elseif ( ! empty( $this->instance[ 'hide_user_names' ] ) ) {
180
+			$this->instance[ 'hide_user_names' ] = '1';
181 181
 		}
182 182
 
183
-		if ( ! isset( $new_instance['horizontal_scrolling'] ) ) {
184
-			unset( $this->instance['horizontal_scrolling'] );
185
-		} elseif ( ! empty( $this->instance['horizontal_scrolling'] ) ) {
186
-			$this->instance['horizontal_scrolling'] = '1';
183
+		if ( ! isset( $new_instance[ 'horizontal_scrolling' ] ) ) {
184
+			unset( $this->instance[ 'horizontal_scrolling' ] );
185
+		} elseif ( ! empty( $this->instance[ 'horizontal_scrolling' ] ) ) {
186
+			$this->instance[ 'horizontal_scrolling' ] = '1';
187 187
 		}
188 188
 
189 189
 		return $this->instance;
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 
198 198
 		parent::form( $instance );
199 199
 
200
-		if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) {
201
-			$this->instance['number_logs'] = $this->defaults['number_logs'];
200
+		if ( ! wordpoints_posint( $this->instance[ 'number_logs' ] ) ) {
201
+			$this->instance[ 'number_logs' ] = $this->defaults[ 'number_logs' ];
202 202
 		}
203 203
 
204 204
 		?>
205 205
 
206 206
 		<p>
207 207
 			<label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of log entries to display', 'wordpoints' ); ?></label>
208
-			<input type="number" min="1" 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 absint( $this->instance['number_logs'] ); ?>" />
208
+			<input type="number" min="1" 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 absint( $this->instance[ 'number_logs' ] ); ?>" />
209 209
 		</p>
210 210
 
211 211
 		<?php
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 					id="<?php echo esc_attr( $this->get_field_id( 'columns[user]' ) ); ?>"
239 239
 					name="<?php echo esc_attr( $this->get_field_name( 'columns[user]' ) ); ?>"
240 240
 					value="1"
241
-					<?php checked( ! empty( $this->instance['columns']['user'] ) ); ?>
241
+					<?php checked( ! empty( $this->instance[ 'columns' ][ 'user' ] ) ); ?>
242 242
 				/>
243 243
 				<?php esc_html_e( 'User', 'wordpoints' ); ?>
244 244
 			</label>
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 					id="<?php echo esc_attr( $this->get_field_id( 'columns[points]' ) ); ?>"
251 251
 					name="<?php echo esc_attr( $this->get_field_name( 'columns[points]' ) ); ?>"
252 252
 					value="1"
253
-					<?php checked( ! empty( $this->instance['columns']['points'] ) ); ?>
253
+					<?php checked( ! empty( $this->instance[ 'columns' ][ 'points' ] ) ); ?>
254 254
 				/>
255 255
 				<?php esc_html_e( 'Points', 'wordpoints' ); ?>
256 256
 			</label>
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					id="<?php echo esc_attr( $this->get_field_id( 'columns[description]' ) ); ?>"
263 263
 					name="<?php echo esc_attr( $this->get_field_name( 'columns[description]' ) ); ?>"
264 264
 					value="1"
265
-					<?php checked( ! empty( $this->instance['columns']['description'] ) ); ?>
265
+					<?php checked( ! empty( $this->instance[ 'columns' ][ 'description' ] ) ); ?>
266 266
 				/>
267 267
 				<?php esc_html_e( 'Description', 'wordpoints' ); ?>
268 268
 			</label>
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 					id="<?php echo esc_attr( $this->get_field_id( 'columns[time]' ) ); ?>"
275 275
 					name="<?php echo esc_attr( $this->get_field_name( 'columns[time]' ) ); ?>"
276 276
 					value="1"
277
-					<?php checked( ! empty( $this->instance['columns']['time'] ) ); ?>
277
+					<?php checked( ! empty( $this->instance[ 'columns' ][ 'time' ] ) ); ?>
278 278
 				/>
279 279
 				<?php esc_html_e( 'Time', 'wordpoints' ); ?>
280 280
 			</label>
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 					id="<?php echo esc_attr( $this->get_field_id( 'hide_user_names' ) ); ?>"
302 302
 					name="<?php echo esc_attr( $this->get_field_name( 'hide_user_names' ) ); ?>"
303 303
 					value="1"
304
-					<?php checked( ! empty( $this->instance['hide_user_names'] ) ); ?>
304
+					<?php checked( ! empty( $this->instance[ 'hide_user_names' ] ) ); ?>
305 305
 				/>
306 306
 				<?php esc_html_e( 'Hide user names (but not avatars)', 'wordpoints' ); ?>
307 307
 			</label>
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 					id="<?php echo esc_attr( $this->get_field_id( 'horizontal_scrolling' ) ); ?>"
328 328
 					name="<?php echo esc_attr( $this->get_field_name( 'horizontal_scrolling' ) ); ?>"
329 329
 					value="1"
330
-					<?php checked( ! empty( $this->instance['horizontal_scrolling'] ) ); ?>
330
+					<?php checked( ! empty( $this->instance[ 'horizontal_scrolling' ] ) ); ?>
331 331
 				/>
332 332
 				<?php esc_html_e( 'Enable horizontal scrolling', 'wordpoints' ); ?>
333 333
 			</label>
Please login to merge, or discard this patch.
src/components/points/classes/widget/user/points.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.