Passed
Push — hotfix/fix-counts ( 0ee906...e9420b )
by Paul
03:57
created
plugin/Modules/System.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode(
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		$plugins = get_plugins();
62 62
 		$activePlugins = (array)get_option( 'active_plugins', [] );
63
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
64
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
63
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
64
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
65 65
 	}
66 66
 
67 67
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	public function getInactivePluginDetails()
96 96
 	{
97 97
 		$activePlugins = (array)get_option( 'active_plugins', [] );
98
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
98
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	{
106 106
 		$plugins = array_merge(
107 107
 			get_mu_plugins(),
108
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
108
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
109 109
 		);
110
-		if( empty( $plugins ))return;
110
+		if( empty($plugins) )return;
111 111
 		return $this->normalizePluginList( $plugins );
112 112
 	}
113 113
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function getMultisitePluginDetails()
118 118
 	{
119
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
119
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
120 120
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
121 121
 	}
122 122
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 			'Memory Limit' => ini_get( 'memory_limit' ),
145 145
 			'Post Max Size' => ini_get( 'post_max_size' ),
146 146
 			'Sendmail Path' => ini_get( 'sendmail_path' ),
147
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
148
-			'Session Name' => esc_html( ini_get( 'session.name' )),
149
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
150
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
151
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
147
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
148
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
149
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
150
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
151
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
152 152
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
153 153
 		];
154 154
 	}
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	{
161 161
 		$counts = glsr( CountsManager::class )->getCounts();
162 162
 		$counts = glsr( Helper::class )->flattenArray( $counts );
163
- 		array_walk( $counts, function( &$ratings ) use( $counts ) {
164
-			if( !is_array( $ratings )) {
163
+ 		array_walk( $counts, function( &$ratings ) use($counts) {
164
+			if( !is_array( $ratings ) ) {
165 165
 				glsr_log()
166 166
 					->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
167 167
 					->debug( $ratings )
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 		ksort( $settings );
201 201
 		$details = [];
202 202
 		foreach( $settings as $key => $value ) {
203
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
204
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
203
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
204
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
205 205
 			$details[$key] = $value;
206 206
 		}
207 207
 		return $details;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		return [
216 216
 			'Console level' => glsr( Console::class )->humanLevel(),
217 217
 			'Console size' => glsr( Console::class )->humanSize( '0' ),
218
-			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )),
218
+			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
219 219
 			'Version (current)' => glsr()->version,
220 220
 			'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
221 221
 		];
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 			'WPE_APIKEY' => 'WP Engine',
276 276
 		];
277 277
 		foreach( $checks as $key => $value ) {
278
-			if( !$this->isWebhostCheckValid( $key ))continue;
278
+			if( !$this->isWebhostCheckValid( $key ) )continue;
279 279
 			return $value;
280 280
 		}
281
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
281
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
282 282
 	}
283 283
 
284 284
 	/**
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	{
300 300
 		$plugins = get_plugins();
301 301
 		$activePlugins = (array)get_option( 'active_plugins', [] );
302
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
303
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
302
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
303
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
304 304
 		return $active + $inactive;
305 305
 	}
306 306
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	protected function implode( $title, array $details )
312 312
 	{
313 313
 		$strings = ['['.$title.']'];
314
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
314
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
315 315
 		$padding = max( [$padding, static::PAD] );
316 316
 		foreach( $details as $key => $value ) {
317 317
 			$strings[] = is_string( $key )
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	protected function normalizePluginList( array $plugins )
341 341
 	{
342 342
 		$plugins = array_map( function( $plugin ) {
343
-			return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ));
343
+			return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
344 344
 		}, $plugins );
345 345
 		natcasesort( $plugins );
346 346
 		return array_flip( $plugins );
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 		$keys = [
355 355
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
356 356
 		];
357
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
357
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
358 358
 			foreach( $keys as $key ) {
359
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
359
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
360 360
 				$value = str_repeat( '•', 13 );
361 361
 				return;
362 362
 			}
Please login to merge, or discard this patch.
plugin/Modules/Html/Builder.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	{
67 67
 		$instance = new static;
68 68
 		$instance->setTagFromMethod( $method );
69
-		call_user_func_array( [$instance, 'normalize'], $args += ['',''] );
69
+		call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
70 70
 		$tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT );
71 71
 		do_action_ref_array( 'site-reviews/builder', [$instance] );
72 72
 		$generatedTag = in_array( $instance->tag, $tags )
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 			'render' => 'is_bool',
92 92
 			'tag' => 'is_string',
93 93
 		];
94
-		if( !isset( $properties[$property] )
95
-			|| empty( array_filter( [$value], $properties[$property] ))
94
+		if( !isset($properties[$property])
95
+			|| empty(array_filter( [$value], $properties[$property] ))
96 96
 		)return;
97 97
 		$this->$property = $value;
98 98
 	}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function getClosingTag()
104 104
 	{
105
-		if( empty( $this->tag ))return;
105
+		if( empty($this->tag) )return;
106 106
 		return '</'.$this->tag.'>';
107 107
 	}
108 108
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getOpeningTag()
113 113
 	{
114
-		if( empty( $this->tag ))return;
115
-		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
114
+		if( empty($this->tag) )return;
115
+		$attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
116 116
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
117 117
 	}
118 118
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function getTag()
123 123
 	{
124
-		if( in_array( $this->tag, static::TAGS_SINGLE )) {
124
+		if( in_array( $this->tag, static::TAGS_SINGLE ) ) {
125 125
 			return $this->getOpeningTag();
126 126
 		}
127
-		if( !in_array( $this->tag, static::TAGS_FORM )) {
127
+		if( !in_array( $this->tag, static::TAGS_FORM ) ) {
128 128
 			return $this->buildDefaultTag();
129 129
 		}
130 130
 		return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function raw( array $field )
137 137
 	{
138
-		unset( $field['label'] );
139
-		return $this->{$field['type']}( $field );
138
+		unset($field['label']);
139
+		return $this->{$field['type']}($field);
140 140
 	}
141 141
 
142 142
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	protected function buildCustomField()
146 146
 	{
147 147
 		$className = $this->getCustomFieldClassName();
148
-		if( class_exists( $className )) {
148
+		if( class_exists( $className ) ) {
149 149
 			return (new $className( $this ))->build();
150 150
 		}
151 151
 		glsr_log()->error( 'Field missing: '.$className );
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	protected function buildDefaultTag( $text = '' )
158 158
 	{
159
-		if( empty( $text )) {
159
+		if( empty($text) ) {
160 160
 			$text = $this->args['text'];
161 161
 		}
162 162
 		return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function buildFieldDescription()
169 169
 	{
170
-		if( empty( $this->args['description'] ))return;
170
+		if( empty($this->args['description']) )return;
171 171
 		if( $this->args['is_widget'] ) {
172 172
 			return $this->small( $this->args['description'] );
173 173
 		}
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	protected function buildFormInput()
181 181
 	{
182
-		if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) {
183
-			if( isset( $this->args['multiple'] )) {
184
-				$this->args['name'].= '[]';
182
+		if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
183
+			if( isset($this->args['multiple']) ) {
184
+				$this->args['name'] .= '[]';
185 185
 			}
186 186
 			return $this->buildFormLabel().$this->getOpeningTag();
187 187
 		}
188
-		return empty( $this->args['options'] )
188
+		return empty($this->args['options'])
189 189
 			? $this->buildFormInputChoice()
190 190
 			: $this->buildFormInputMultiChoice();
191 191
 	}
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	protected function buildFormInputChoice()
197 197
 	{
198
-		if( !empty( $this->args['text'] )) {
198
+		if( !empty($this->args['text']) ) {
199 199
 			$this->args['label'] = $this->args['text'];
200 200
 		}
201 201
 		if( !$this->args['is_public'] ) {
202
-			return $this->buildFormLabel([
202
+			return $this->buildFormLabel( [
203 203
 				'class' => 'glsr-'.$this->args['type'].'-label',
204 204
 				'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>',
205
-			]);
205
+			] );
206 206
 		}
207
-		return $this->getOpeningTag().$this->buildFormLabel([
207
+		return $this->getOpeningTag().$this->buildFormLabel( [
208 208
 			'class' => 'glsr-'.$this->args['type'].'-label',
209 209
 			'text' => $this->args['label'].'<span></span>',
210
-		]);
210
+		] );
211 211
 	}
212 212
 
213 213
 	/**
@@ -216,22 +216,22 @@  discard block
 block discarded – undo
216 216
 	protected function buildFormInputMultiChoice()
217 217
 	{
218 218
 		if( $this->args['type'] == 'checkbox' ) {
219
-			$this->args['name'].= '[]';
219
+			$this->args['name'] .= '[]';
220 220
 		}
221 221
 		$index = 0;
222
-		$options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use( &$index ) {
222
+		$options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use(&$index) {
223 223
 			return $carry.$this->li( $this->{$this->args['type']}([
224 224
 				'checked' => in_array( $key, (array)$this->args['value'] ),
225 225
 				'id' => $this->args['id'].'-'.$index++,
226 226
 				'name' => $this->args['name'],
227 227
 				'text' => $this->args['options'][$key],
228 228
 				'value' => $key,
229
-			]));
229
+			]) );
230 230
 		});
231 231
 		return $this->ul( $options, [
232 232
 			'class' => $this->args['class'],
233 233
 			'id' => $this->args['id'],
234
-		]);
234
+		] );
235 235
 	}
236 236
 
237 237
 	/**
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	protected function buildFormLabel( array $customArgs = [] )
241 241
 	{
242
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
242
+		if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return;
243 243
 		return $this->label( wp_parse_args( $customArgs, [
244 244
 			'for' => $this->args['id'],
245 245
 			'is_public' => $this->args['is_public'],
246 246
 			'text' => $this->args['label'],
247 247
 			'type' => $this->args['type'],
248
-		]));
248
+		] ) );
249 249
 	}
250 250
 
251 251
 	/**
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	protected function buildFormSelectOptions()
263 263
 	{
264 264
 		return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
265
-			return $carry.$this->option([
265
+			return $carry.$this->option( [
266 266
 				'selected' => $this->args['value'] == $key,
267 267
 				'text' => $this->args['options'][$key],
268 268
 				'value' => $key,
269
-			]);
269
+			] );
270 270
 		});
271 271
 	}
272 272
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	protected function mergeArgsWithRequiredDefaults()
303 303
 	{
304 304
 		$className = $this->getCustomFieldClassName();
305
-		if( class_exists( $className )) {
305
+		if( class_exists( $className ) ) {
306 306
 			$this->args = $className::merge( $this->args );
307 307
 		}
308 308
 		$this->args = glsr( BuilderDefaults::class )->merge( $this->args );
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	protected function normalize( ...$params )
316 316
 	{
317
-		if( is_string( $params[0] ) || is_numeric( $params[0] )) {
317
+		if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
318 318
 			$this->setNameOrTextAttributeForTag( $params[0] );
319 319
 		}
320
-		if( is_array( $params[0] )) {
320
+		if( is_array( $params[0] ) ) {
321 321
 			$this->args += $params[0];
322 322
 		}
323
-		else if( is_array( $params[1] )) {
323
+		else if( is_array( $params[1] ) ) {
324 324
 			$this->args += $params[1];
325 325
 		}
326
-		if( !isset( $this->args['is_public'] )) {
326
+		if( !isset($this->args['is_public']) ) {
327 327
 			$this->args['is_public'] = false;
328 328
 		}
329 329
 	}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	protected function setTagFromMethod( $method )
348 348
 	{
349 349
 		$this->tag = strtolower( $method );
350
-		if( in_array( $this->tag, static::INPUT_TYPES )) {
350
+		if( in_array( $this->tag, static::INPUT_TYPES ) ) {
351 351
 			$this->args['type'] = $this->tag;
352 352
 			$this->tag = 'input';
353 353
 		}
Please login to merge, or discard this patch.
plugin/Modules/Style.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 			'templates/form/submit-button',
51 51
 			'templates/reviews-form',
52 52
 		];
53
-		if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) {
53
+		if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) {
54 54
 			return $view;
55 55
 		}
56 56
 		$views = $this->generatePossibleViews( $view );
57 57
 		foreach( $views as $possibleView ) {
58
-			if( !file_exists( glsr()->file( $possibleView )))continue;
58
+			if( !file_exists( glsr()->file( $possibleView ) ) )continue;
59 59
 			return glsr( Helper::class )->removePrefix( 'views/', $possibleView );
60 60
 		}
61 61
 		return $view;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function modifyField( Builder $instance )
90 90
 	{
91
-		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return;
91
+		if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return;
92 92
 		call_user_func_array( [$this, 'customize'], [$instance] );
93 93
 	}
94 94
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function customize( Builder $instance )
107 107
 	{
108
-		if( !array_key_exists( $instance->tag, $this->fields ))return;
109
-		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ));
108
+		if( !array_key_exists( $instance->tag, $this->fields ) )return;
109
+		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
110 110
 		$key = $instance->tag.'_'.$args['type'];
111
-		$classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag ));
111
+		$classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag ) );
112 112
 		$instance->args['class'] = trim( $args['class'].' '.$classes );
113 113
 		do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] );
114 114
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$args = wp_parse_args( $instance->args, [
141 141
 			'is_public' => false,
142 142
 			'is_raw' => false,
143
-		]);
143
+		] );
144 144
 		if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
145 145
 			return false;
146 146
 		}
Please login to merge, or discard this patch.