Passed
Push — master ( fe5b90...baa8e1 )
by Paul
05:38
created
plugin/Modules/Html/Partials/SiteReviews.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 				'navigation' => $navigation,
57 57
 				'reviews' => $this->buildReviews(),
58 58
 			],
59
-		]);
59
+		] );
60 60
 	}
61 61
 
62 62
 	/**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		$reviews = '';
68 68
 		foreach( $this->reviews->results as $index => $result ) {
69 69
 			$this->current = $index;
70
-			$reviews.= glsr( Template::class )->build( 'templates/review', [
70
+			$reviews .= glsr( Template::class )->build( 'templates/review', [
71 71
 				'context' => $this->buildReview( $result )->values,
72
-			]);
72
+			] );
73 73
 		}
74 74
 		return $reviews;
75 75
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$reviewValues = [];
85 85
 		foreach( $review as $key => $value ) {
86 86
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' );
87
-			if( !method_exists( $this, $method ))continue;
87
+			if( !method_exists( $this, $method ) )continue;
88 88
 			$reviewValues[$key] = $this->$method( $key, $value );
89 89
 		}
90 90
 		$reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues );
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	protected function buildOptionAssignedTo( $key, $value )
100 100
 	{
101
-		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return;
102
-		$post = get_post( intval( $value ));
103
-		if( !( $post instanceof WP_Post ))return;
101
+		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return;
102
+		$post = get_post( intval( $value ) );
103
+		if( !($post instanceof WP_Post) )return;
104 104
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
105 105
 			'href' => get_the_permalink( $post->ID ),
106
-		]);
106
+		] );
107 107
 		$assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
108 108
 		return $this->wrap( $key, '<span>'.$assignedTo.'</span>' );
109 109
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	protected function buildOptionAuthor( $key, $value )
117 117
 	{
118
-		if( $this->isHidden( $key ))return;
118
+		if( $this->isHidden( $key ) )return;
119 119
 		return $this->wrap( $key, '<span>'.$value.'</span>' );
120 120
 	}
121 121
 
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function buildOptionAvatar( $key, $value )
128 128
 	{
129
-		if( $this->isHidden( $key, 'settings.reviews.avatars' ))return;
129
+		if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return;
130 130
 		$size = $this->getOption( 'settings.reviews.avatars_size', 40 );
131
-		return $this->wrap( $key, glsr( Builder::class )->img([
131
+		return $this->wrap( $key, glsr( Builder::class )->img( [
132 132
 			'src' => $this->generateAvatar( $value ),
133 133
 			'height' => $size,
134 134
 			'width' => $size,
135
-		]));
135
+		] ) );
136 136
 	}
137 137
 
138 138
 	/**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	protected function buildOptionContent( $key, $value )
144 144
 	{
145 145
 		$text = $this->normalizeText( $value );
146
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
146
+		if( $this->isHiddenOrEmpty( $key, $text ) )return;
147 147
 		return $this->wrap( $key, '<p>'.$text.'</p>' );
148 148
 	}
149 149
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected function buildOptionDate( $key, $value )
156 156
 	{
157
-		if( $this->isHidden( $key ))return;
157
+		if( $this->isHidden( $key ) )return;
158 158
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
159 159
 		if( $dateFormat == 'relative' ) {
160 160
 			$date = glsr( Date::class )->relative( $value );
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			$format = $dateFormat == 'custom'
164 164
 				? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
165 165
 				: (string)get_option( 'date_format' );
166
-			$date = date_i18n( $format, strtotime( $value ));
166
+			$date = date_i18n( $format, strtotime( $value ) );
167 167
 		}
168 168
 		return $this->wrap( $key, '<span>'.$date.'</span>' );
169 169
 	}
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function buildOptionRating( $key, $value )
177 177
 	{
178
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
178
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
179 179
 		$rating = glsr( Partial::class )->build( 'star-rating', [
180 180
 			'rating' => $value,
181
-		]);
181
+		] );
182 182
 		return $this->wrap( $key, $rating );
183 183
 	}
184 184
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	protected function buildOptionResponse( $key, $value )
191 191
 	{
192
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
193
-		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
192
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
193
+		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
194 194
 		$text = $this->normalizeText( $value );
195 195
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
196 196
 		return $this->wrap( $key,
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	protected function buildOptionTitle( $key, $value )
208 208
 	{
209
-		if( $this->isHidden( $key ))return;
210
-		if( empty( $value )) {
209
+		if( $this->isHidden( $key ) )return;
210
+		if( empty($value) ) {
211 211
 			$value = __( 'No Title', 'site-reviews' );
212 212
 		}
213 213
 		return $this->wrap( $key, '<h3>'.$value.'</h3>' );
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 			return $avatarUrl;
225 225
 		}
226 226
 		$authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id );
227
-		if( empty( $authorIdOrEmail )) {
227
+		if( empty($authorIdOrEmail) ) {
228 228
 			$authorIdOrEmail = $review->email;
229 229
 		}
230
-		if( $newAvatar = get_avatar_url( $authorIdOrEmail )) {
230
+		if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) {
231 231
 			return $newAvatar;
232 232
 		}
233 233
 		return $avatarUrl;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	protected function generateSchema()
240 240
 	{
241
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
241
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
242 242
 		glsr( Schema::class )->store(
243 243
 			glsr( Schema::class )->build( $this->args )
244 244
 		);
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	protected function getExcerpt( $text )
263 263
 	{
264
-		$limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ));
264
+		$limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) );
265 265
 		$split = extension_loaded( 'intl' )
266 266
 			? $this->getExcerptIntlSplit( $text, $limit )
267 267
 			: $this->getExcerptSplit( $text, $limit );
268 268
 		$hiddenText = substr( $text, $split );
269
-		if( !empty( $hiddenText )) {
269
+		if( !empty($hiddenText) ) {
270 270
 			$showMore = glsr( Builder::class )->span( $hiddenText, [
271 271
 				'class' => 'glsr-hidden glsr-hidden-text',
272 272
 				'data-show-less' => __( 'Show less', 'site-reviews' ),
273 273
 				'data-show-more' => __( 'Show more', 'site-reviews' ),
274
-			]);
275
-			$text = ltrim( substr( $text, 0, $split )).$showMore;
274
+			] );
275
+			$text = ltrim( substr( $text, 0, $split ) ).$showMore;
276 276
 		}
277 277
 		return nl2br( $text );
278 278
 	}
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		$words = IntlRuleBasedBreakIterator::createWordInstance( '' );
288 288
 		$words->setText( $text );
289 289
 		$count = 0;
290
-		foreach( $words as $offset ){
290
+		foreach( $words as $offset ) {
291 291
 			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue;
292 292
 			$count++;
293 293
 			if( $count != $limit )continue;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	protected function getExcerptSplit( $text, $limit )
305 305
 	{
306 306
 		if( str_word_count( $text, 0 ) > $limit ) {
307
-			$words = array_keys( str_word_count( $text, 2 ));
307
+			$words = array_keys( str_word_count( $text, 2 ) );
308 308
 			return $words[$limit];
309 309
 		}
310 310
 		return strlen( $text );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	protected function getOption( $path, $fallback = '' )
319 319
 	{
320
-		if( array_key_exists( $path, $this->options )) {
320
+		if( array_key_exists( $path, $this->options ) ) {
321 321
 			return $this->options[$path];
322 322
 		}
323 323
 		return $fallback;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	protected function isHidden( $key, $path = '' )
332 332
 	{
333
-		$isOptionEnabled = !empty( $path )
333
+		$isOptionEnabled = !empty($path)
334 334
 			? $this->isOptionEnabled( $path )
335 335
 			: true;
336 336
 		return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	protected function isHiddenOrEmpty( $key, $value )
345 345
 	{
346
-		return $this->isHidden( $key ) || empty( $value );
346
+		return $this->isHidden( $key ) || empty($value);
347 347
 	}
348 348
 
349 349
 	/**
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 	protected function normalizeText( $text )
363 363
 	{
364 364
 		$text = wp_kses( $text, wp_kses_allowed_html() );
365
-		$text = convert_smilies( strip_shortcodes( $text ));
365
+		$text = convert_smilies( strip_shortcodes( $text ) );
366 366
 		$text = str_replace( ']]>', ']]&gt;', $text );
367 367
 		$text = preg_replace( '/(\R){2,}/', '$1', $text );
368
-		if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) {
368
+		if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) {
369 369
 			$text = $this->getExcerpt( $text );
370 370
 		}
371 371
 		return wptexturize( $text );
@@ -380,6 +380,6 @@  discard block
 block discarded – undo
380 380
 	{
381 381
 		return glsr( Builder::class )->div( $value, [
382 382
 			'class' => 'glsr-review-'.$key,
383
-		]);
383
+		] );
384 384
 	}
385 385
 }
Please login to merge, or discard this patch.
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
 		$reviewValues = [];
85 85
 		foreach( $review as $key => $value ) {
86 86
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' );
87
-			if( !method_exists( $this, $method ))continue;
87
+			if( !method_exists( $this, $method )) {
88
+				continue;
89
+			}
88 90
 			$reviewValues[$key] = $this->$method( $key, $value );
89 91
 		}
90 92
 		$reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues );
@@ -98,9 +100,13 @@  discard block
 block discarded – undo
98 100
 	 */
99 101
 	protected function buildOptionAssignedTo( $key, $value )
100 102
 	{
101
-		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return;
103
+		if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) {
104
+			return;
105
+		}
102 106
 		$post = get_post( intval( $value ));
103
-		if( !( $post instanceof WP_Post ))return;
107
+		if( !( $post instanceof WP_Post )) {
108
+			return;
109
+		}
104 110
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
105 111
 			'href' => get_the_permalink( $post->ID ),
106 112
 		]);
@@ -115,7 +121,9 @@  discard block
 block discarded – undo
115 121
 	 */
116 122
 	protected function buildOptionAuthor( $key, $value )
117 123
 	{
118
-		if( $this->isHidden( $key ))return;
124
+		if( $this->isHidden( $key )) {
125
+			return;
126
+		}
119 127
 		return $this->wrap( $key, '<span>'.$value.'</span>' );
120 128
 	}
121 129
 
@@ -126,7 +134,9 @@  discard block
 block discarded – undo
126 134
 	 */
127 135
 	protected function buildOptionAvatar( $key, $value )
128 136
 	{
129
-		if( $this->isHidden( $key, 'settings.reviews.avatars' ))return;
137
+		if( $this->isHidden( $key, 'settings.reviews.avatars' )) {
138
+			return;
139
+		}
130 140
 		$size = $this->getOption( 'settings.reviews.avatars_size', 40 );
131 141
 		return $this->wrap( $key, glsr( Builder::class )->img([
132 142
 			'src' => $this->generateAvatar( $value ),
@@ -143,7 +153,9 @@  discard block
 block discarded – undo
143 153
 	protected function buildOptionContent( $key, $value )
144 154
 	{
145 155
 		$text = $this->normalizeText( $value );
146
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
156
+		if( $this->isHiddenOrEmpty( $key, $text )) {
157
+			return;
158
+		}
147 159
 		return $this->wrap( $key, '<p>'.$text.'</p>' );
148 160
 	}
149 161
 
@@ -154,7 +166,9 @@  discard block
 block discarded – undo
154 166
 	 */
155 167
 	protected function buildOptionDate( $key, $value )
156 168
 	{
157
-		if( $this->isHidden( $key ))return;
169
+		if( $this->isHidden( $key )) {
170
+			return;
171
+		}
158 172
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
159 173
 		if( $dateFormat == 'relative' ) {
160 174
 			$date = glsr( Date::class )->relative( $value );
@@ -175,7 +189,9 @@  discard block
 block discarded – undo
175 189
 	 */
176 190
 	protected function buildOptionRating( $key, $value )
177 191
 	{
178
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
192
+		if( $this->isHiddenOrEmpty( $key, $value )) {
193
+			return;
194
+		}
179 195
 		$rating = glsr( Partial::class )->build( 'star-rating', [
180 196
 			'rating' => $value,
181 197
 		]);
@@ -189,7 +205,9 @@  discard block
 block discarded – undo
189 205
 	 */
190 206
 	protected function buildOptionResponse( $key, $value )
191 207
 	{
192
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
208
+		if( $this->isHiddenOrEmpty( $key, $value )) {
209
+			return;
210
+		}
193 211
 		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
194 212
 		$text = $this->normalizeText( $value );
195 213
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
@@ -206,7 +224,9 @@  discard block
 block discarded – undo
206 224
 	 */
207 225
 	protected function buildOptionTitle( $key, $value )
208 226
 	{
209
-		if( $this->isHidden( $key ))return;
227
+		if( $this->isHidden( $key )) {
228
+			return;
229
+		}
210 230
 		if( empty( $value )) {
211 231
 			$value = __( 'No Title', 'site-reviews' );
212 232
 		}
@@ -238,7 +258,9 @@  discard block
 block discarded – undo
238 258
 	 */
239 259
 	protected function generateSchema()
240 260
 	{
241
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
261
+		if( !wp_validate_boolean( $this->args['schema'] )) {
262
+			return;
263
+		}
242 264
 		glsr( Schema::class )->store(
243 265
 			glsr( Schema::class )->build( $this->args )
244 266
 		);
@@ -288,9 +310,13 @@  discard block
 block discarded – undo
288 310
 		$words->setText( $text );
289 311
 		$count = 0;
290 312
 		foreach( $words as $offset ){
291
-			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue;
313
+			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) {
314
+				continue;
315
+			}
292 316
 			$count++;
293
-			if( $count != $limit )continue;
317
+			if( $count != $limit ) {
318
+				continue;
319
+			}
294 320
 			return $offset;
295 321
 		}
296 322
 		return strlen( $text );
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	public function callbackRegisterSettings( $input )
18 18
 	{
19
-		if( !is_array( $input )) {
19
+		if( !is_array( $input ) ) {
20 20
 			$input = ['settings' => []];
21 21
 		}
22 22
 		if( key( $input ) == 'settings' ) {
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 			$options = $this->sanitizeGeneral( $input, $options );
25 25
 			$options = $this->sanitizeSubmissions( $input, $options );
26 26
 			$options = $this->sanitizeTranslations( $input, $options );
27
-			glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ));
27
+			glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
28 28
 			return $options;
29 29
 		}
30 30
 		return $input;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	{
39 39
 		register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
40 40
 			'sanitize_callback' => [$this, 'callbackRegisterSettings'],
41
-		]);
41
+		] );
42 42
 	}
43 43
 
44 44
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	protected function sanitizeGeneral( array $input, array $options )
48 48
 	{
49 49
 		$inputForm = $input['settings']['general'];
50
-		if( !isset( $inputForm['notifications'] )) {
50
+		if( !isset($inputForm['notifications']) ) {
51 51
 			$options['settings']['general']['notifications'] = [];
52 52
 		}
53 53
 		if( trim( $inputForm['notification_message'] ) == '' ) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	protected function sanitizeSubmissions( array $input, array $options )
63 63
 	{
64 64
 		$inputForm = $input['settings']['submissions'];
65
-		if( !isset( $inputForm['required'] )) {
65
+		if( !isset($inputForm['required']) ) {
66 66
 			$options['settings']['submissions']['required'] = [];
67 67
 		}
68 68
 		return $options;
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	protected function sanitizeTranslations( array $input, array $options )
75 75
 	{
76
-		if( isset( $input['settings']['strings'] )) {
77
-			$options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ));
76
+		if( isset($input['settings']['strings']) ) {
77
+			$options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) );
78 78
 			$allowedTags = ['a' => ['class' => [], 'href' => [], 'target' => []]];
79
-			array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) {
80
-				if( isset( $string['s2'] )) {
79
+			array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) {
80
+				if( isset($string['s2']) ) {
81 81
 					$string['s2'] = wp_kses( $string['s2'], $allowedTags );
82 82
 				}
83
-				if( isset( $string['p2'] )) {
83
+				if( isset($string['p2']) ) {
84 84
 					$string['p2'] = wp_kses( $string['p2'], $allowedTags );
85 85
 				}
86 86
 			});
Please login to merge, or discard this patch.