Passed
Push — master ( 71fe18...341f99 )
by Paul
05:12
created
deprecated.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,61 +3,61 @@
 block discarded – undo
3 3
 defined( 'WPINC' ) || die;
4 4
 
5 5
 add_action( 'site-reviews/local/review/submitted', function() {
6
-	if( has_filter( 'site-reviews/local/review/submitted/message' )) {
6
+	if( has_filter( 'site-reviews/local/review/submitted/message' ) ) {
7 7
 		glsr_log()->notice( 'The "site-reviews/local/review/submitted/message" hook has been deprecated.' );
8 8
 	}
9 9
 });
10 10
 
11 11
 add_filter( 'site-reviews/create/review-values', function( $values ) {
12
-	if( has_filter( 'site-reviews/local/review' )) {
12
+	if( has_filter( 'site-reviews/local/review' ) ) {
13 13
 		glsr_log()->notice( 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.' );
14 14
 	}
15 15
 	return $values;
16 16
 });
17 17
 
18 18
 add_filter( 'site-reviews/get/defaults', function( $defaults ) {
19
-	if( has_filter( 'site-reviews/addon/defaults' )) {
19
+	if( has_filter( 'site-reviews/addon/defaults' ) ) {
20 20
 		glsr_log()->notice( 'The "site-reviews/addon/defaults" hook has been deprecated. Please use the "site-reviews/get/defaults" hook instead.' );
21 21
 	}
22 22
 	return $defaults;
23 23
 });
24 24
 
25 25
 add_filter( 'site-reviews/rating/average', function( $average ) {
26
-	if( has_filter( 'site-reviews/average/rating' )) {
26
+	if( has_filter( 'site-reviews/average/rating' ) ) {
27 27
 		glsr_log()->notice( 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.' );
28 28
 	}
29 29
 	return $average;
30 30
 });
31 31
 
32 32
 add_filter( 'site-reviews/rating/ranking', function( $ranking ) {
33
-	if( has_filter( 'site-reviews/bayesian/ranking' )) {
33
+	if( has_filter( 'site-reviews/bayesian/ranking' ) ) {
34 34
 		glsr_log()->notice( 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.' );
35 35
 	}
36 36
 	return $ranking;
37 37
 });
38 38
 
39 39
 add_filter( 'site-reviews/review/build/before', function( $review ) {
40
-	if( has_filter( 'site-reviews/rendered/review/meta/order' )) {
40
+	if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) {
41 41
 		glsr_log()->notice( 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' );
42 42
 	}
43
-	if( has_filter( 'site-reviews/rendered/review/order' )) {
43
+	if( has_filter( 'site-reviews/rendered/review/order' ) ) {
44 44
 		glsr_log()->notice( 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' );
45 45
 	}
46 46
 	return $review;
47 47
 });
48 48
 
49 49
 add_filter( 'site-reviews/review/build/after', function( $review ) {
50
-	if( has_filter( 'site-reviews/reviews/review/text' )) {
50
+	if( has_filter( 'site-reviews/reviews/review/text' ) ) {
51 51
 		glsr_log()->notice( 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' );
52 52
 	}
53
-	if( has_filter( 'site-reviews/reviews/review/title' )) {
53
+	if( has_filter( 'site-reviews/reviews/review/title' ) ) {
54 54
 		glsr_log()->notice( 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' );
55 55
 	}
56 56
 	return $review;
57 57
 });
58 58
 
59 59
 add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) {
60
-	if( has_filter( 'site-reviews/enqueue/localize' )) {
60
+	if( has_filter( 'site-reviews/enqueue/localize' ) ) {
61 61
 		glsr_log()->notice( 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.' );
62 62
 	}
63 63
 	return $variables;
Please login to merge, or discard this patch.
site-reviews.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@
 block discarded – undo
21 21
 if( !class_exists( 'GL_Plugin_Check_v3' )) {
22 22
 	require_once __DIR__.'/activate.php';
23 23
 }
24
-if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return;
24
+if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() ) {
25
+	return;
26
+}
25 27
 require_once __DIR__.'/autoload.php';
26 28
 require_once __DIR__.'/compatibility.php';
27 29
 require_once __DIR__.'/deprecated.php';
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 				'navigation' => $navigation,
58 58
 			],
59 59
 			'reviews' => $this->buildReviews(),
60
-		]);
60
+		] );
61 61
 	}
62 62
 
63 63
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$reviewValues = [];
84 84
 		foreach( $review as $key => $value ) {
85 85
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' );
86
-			if( !method_exists( $this, $method ))continue;
86
+			if( !method_exists( $this, $method ) )continue;
87 87
 			$reviewValues[$key] = $this->$method( $key, $value );
88 88
 		}
89 89
 		$reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues );
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	protected function buildOptionAssignedTo( $key, $value )
99 99
 	{
100
-		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return;
101
-		$post = get_post( intval( $value ));
102
-		if( !( $post instanceof WP_Post ))return;
100
+		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return;
101
+		$post = get_post( intval( $value ) );
102
+		if( !($post instanceof WP_Post) )return;
103 103
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
104 104
 			'href' => get_the_permalink( $post->ID ),
105
-		]);
105
+		] );
106 106
 		$assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
107 107
 		return $this->wrap( $key, '<span>'.$assignedTo.'</span>' );
108 108
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function buildOptionAuthor( $key, $value )
116 116
 	{
117
-		if( $this->isHidden( $key ))return;
117
+		if( $this->isHidden( $key ) )return;
118 118
 		$prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' )
119 119
 			? apply_filters( 'site-reviews/review/author/prefix', '&mdash;' )
120 120
 			: '';
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function buildOptionAvatar( $key, $value )
130 130
 	{
131
-		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return;
131
+		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return;
132 132
 		$size = $this->getOption( 'settings.reviews.avatars.size', 40 );
133
-		return $this->wrap( $key, glsr( Builder::class )->img([
133
+		return $this->wrap( $key, glsr( Builder::class )->img( [
134 134
 			'src' => $this->generateAvatar( $value ),
135 135
 			'height' => $size,
136 136
 			'width' => $size,
137
-		]));
137
+		] ) );
138 138
 	}
139 139
 
140 140
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	protected function buildOptionContent( $key, $value )
146 146
 	{
147 147
 		$text = $this->normalizeText( $value );
148
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
148
+		if( $this->isHiddenOrEmpty( $key, $text ) )return;
149 149
 		return $this->wrap( $key, '<p>'.$text.'</p>' );
150 150
 	}
151 151
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	protected function buildOptionDate( $key, $value )
158 158
 	{
159
-		if( $this->isHidden( $key ))return;
159
+		if( $this->isHidden( $key ) )return;
160 160
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
161 161
 		if( $dateFormat == 'relative' ) {
162 162
 			$date = glsr( Date::class )->relative( $value );
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			$format = $dateFormat == 'custom'
166 166
 				? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
167 167
 				: (string)get_option( 'date_format' );
168
-			$date = date_i18n( $format, strtotime( $value ));
168
+			$date = date_i18n( $format, strtotime( $value ) );
169 169
 		}
170 170
 		return $this->wrap( $key, '<span>'.$date.'</span>' );
171 171
 	}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	protected function buildOptionRating( $key, $value )
179 179
 	{
180
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
180
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
181 181
 		$rating = glsr( Html::class )->buildPartial( 'star-rating', [
182 182
 			'rating' => $value,
183
-		]);
183
+		] );
184 184
 		return $this->wrap( $key, $rating );
185 185
 	}
186 186
 
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	protected function buildOptionResponse( $key, $value )
193 193
 	{
194
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
195
-		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
194
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
195
+		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
196 196
 		$text = $this->normalizeText( $value );
197 197
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
198 198
 		return $this->wrap( $key,
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	protected function buildOptionTitle( $key, $value )
210 210
 	{
211
-		if( $this->isHidden( $key ))return;
212
-		if( empty( $value )) {
211
+		if( $this->isHidden( $key ) )return;
212
+		if( empty($value) ) {
213 213
 			$value = __( 'No Title', 'site-reviews' );
214 214
 		}
215 215
 		return $this->wrap( $key, '<h3>'.$value.'</h3>' );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			return $avatarUrl;
228 228
 		}
229 229
 		$authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id );
230
-		if( empty( $authorIdOrEmail )) {
230
+		if( empty($authorIdOrEmail) ) {
231 231
 			$authorIdOrEmail = $review->email;
232 232
 		}
233 233
 		return (string)get_avatar_url( $authorIdOrEmail );
@@ -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.excerpt.length', 55 ));
264
+		$limit = intval( $this->getOption( 'settings.reviews.excerpt.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.excerpt.enabled' )) {
368
+		if( $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) ) {
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
@@ -83,7 +83,9 @@  discard block
 block discarded – undo
83 83
 		$reviewValues = [];
84 84
 		foreach( $review as $key => $value ) {
85 85
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' );
86
-			if( !method_exists( $this, $method ))continue;
86
+			if( !method_exists( $this, $method )) {
87
+				continue;
88
+			}
87 89
 			$reviewValues[$key] = $this->$method( $key, $value );
88 90
 		}
89 91
 		$reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues );
@@ -97,9 +99,13 @@  discard block
 block discarded – undo
97 99
 	 */
98 100
 	protected function buildOptionAssignedTo( $key, $value )
99 101
 	{
100
-		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return;
102
+		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) {
103
+			return;
104
+		}
101 105
 		$post = get_post( intval( $value ));
102
-		if( !( $post instanceof WP_Post ))return;
106
+		if( !( $post instanceof WP_Post )) {
107
+			return;
108
+		}
103 109
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
104 110
 			'href' => get_the_permalink( $post->ID ),
105 111
 		]);
@@ -114,7 +120,9 @@  discard block
 block discarded – undo
114 120
 	 */
115 121
 	protected function buildOptionAuthor( $key, $value )
116 122
 	{
117
-		if( $this->isHidden( $key ))return;
123
+		if( $this->isHidden( $key )) {
124
+			return;
125
+		}
118 126
 		$prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' )
119 127
 			? apply_filters( 'site-reviews/review/author/prefix', '&mdash;' )
120 128
 			: '';
@@ -128,7 +136,9 @@  discard block
 block discarded – undo
128 136
 	 */
129 137
 	protected function buildOptionAvatar( $key, $value )
130 138
 	{
131
-		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return;
139
+		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) {
140
+			return;
141
+		}
132 142
 		$size = $this->getOption( 'settings.reviews.avatars.size', 40 );
133 143
 		return $this->wrap( $key, glsr( Builder::class )->img([
134 144
 			'src' => $this->generateAvatar( $value ),
@@ -145,7 +155,9 @@  discard block
 block discarded – undo
145 155
 	protected function buildOptionContent( $key, $value )
146 156
 	{
147 157
 		$text = $this->normalizeText( $value );
148
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
158
+		if( $this->isHiddenOrEmpty( $key, $text )) {
159
+			return;
160
+		}
149 161
 		return $this->wrap( $key, '<p>'.$text.'</p>' );
150 162
 	}
151 163
 
@@ -156,7 +168,9 @@  discard block
 block discarded – undo
156 168
 	 */
157 169
 	protected function buildOptionDate( $key, $value )
158 170
 	{
159
-		if( $this->isHidden( $key ))return;
171
+		if( $this->isHidden( $key )) {
172
+			return;
173
+		}
160 174
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
161 175
 		if( $dateFormat == 'relative' ) {
162 176
 			$date = glsr( Date::class )->relative( $value );
@@ -177,7 +191,9 @@  discard block
 block discarded – undo
177 191
 	 */
178 192
 	protected function buildOptionRating( $key, $value )
179 193
 	{
180
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
194
+		if( $this->isHiddenOrEmpty( $key, $value )) {
195
+			return;
196
+		}
181 197
 		$rating = glsr( Html::class )->buildPartial( 'star-rating', [
182 198
 			'rating' => $value,
183 199
 		]);
@@ -191,7 +207,9 @@  discard block
 block discarded – undo
191 207
 	 */
192 208
 	protected function buildOptionResponse( $key, $value )
193 209
 	{
194
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
210
+		if( $this->isHiddenOrEmpty( $key, $value )) {
211
+			return;
212
+		}
195 213
 		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
196 214
 		$text = $this->normalizeText( $value );
197 215
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
@@ -208,7 +226,9 @@  discard block
 block discarded – undo
208 226
 	 */
209 227
 	protected function buildOptionTitle( $key, $value )
210 228
 	{
211
-		if( $this->isHidden( $key ))return;
229
+		if( $this->isHidden( $key )) {
230
+			return;
231
+		}
212 232
 		if( empty( $value )) {
213 233
 			$value = __( 'No Title', 'site-reviews' );
214 234
 		}
@@ -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/Modules/Slack.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function compose( Review $review, array $notification )
37 37
 	{
38
-		if( empty( $this->endpoint ))return;
38
+		if( empty($this->endpoint) )return;
39 39
 		$args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification );
40 40
 		$this->review = $review;
41 41
 		$notification = [
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function send()
60 60
 	{
61
-		if( empty( $this->endpoint )) {
61
+		if( empty($this->endpoint) ) {
62 62
 			return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' );
63 63
 		}
64 64
 		return wp_remote_post( $this->endpoint, [
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			'redirection' => 5,
71 71
 			'sslverify' => false,
72 72
 			'timeout' => 45,
73
-		]);
73
+		] );
74 74
 	}
75 75
 
76 76
 	/**
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	protected function buildAuthorField()
92 92
 	{
93
-		$email = !empty( $this->review->email )
93
+		$email = !empty($this->review->email)
94 94
 			? '<'.$this->review->email.'>'
95 95
 			: '';
96 96
 		$author = trim( rtrim( $this->review->author ).' '.$email );
97
-		return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))];
97
+		return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )];
98 98
 	}
99 99
 
100 100
 	/**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	protected function buildContentField()
104 104
 	{
105
-		return !empty( $this->review->content )
105
+		return !empty($this->review->content)
106 106
 			? ['value' => $this->review->content]
107 107
 			: [];
108 108
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	protected function buildStarsField()
128 128
 	{
129 129
 		$solidStars = str_repeat( '★', $this->review->rating );
130
-		$emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ));
130
+		$emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ) );
131 131
 		$stars = $solidStars.$emptyStars;
132 132
 		$stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, Rating::MAX_RATING );
133 133
 		return ['title' => $stars];
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	protected function buildTitleField()
140 140
 	{
141
-		return !empty( $this->review->title )
141
+		return !empty($this->review->title)
142 142
 			? ['title' => $this->review->title]
143 143
 			: [];
144 144
 	}
Please login to merge, or discard this patch.
plugin/Modules/Notification.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	public function __construct()
34 34
 	{
35 35
 		$types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] );
36
-		$this->email = count( array_intersect( ['admin', 'author', 'custom'], $types )) > 0;
36
+		$this->email = count( array_intersect( ['admin', 'author', 'custom'], $types ) ) > 0;
37 37
 		$this->slack = in_array( 'slack', $types );
38 38
 		$this->types = $types;
39 39
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function send( Review $review )
45 45
 	{
46
-		if( empty( $this->types ))return;
46
+		if( empty($this->types) )return;
47 47
 		$this->review = $review;
48 48
 		$args = [
49 49
 			'link' => $this->getLink(),
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	protected function buildEmail( array $args )
64 64
 	{
65
-		return glsr( Email::class )->compose([
65
+		return glsr( Email::class )->compose( [
66 66
 			'to' => $this->getEmailAddresses(),
67 67
 			'subject' => $args['title'],
68 68
 			'template' => 'email-notification',
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 				'review_rating' => $this->review->rating,
76 76
 				'review_title' => $this->review->title,
77 77
 			],
78
-		]);
78
+		] );
79 79
 	}
80 80
 
81 81
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			'button_url' => $args['link'],
88 88
 			'fallback' => $this->buildEmail( $args )->read( 'plaintext' ),
89 89
 			'pretext' => $args['title'],
90
-		]);
90
+		] );
91 91
 	}
92 92
 
93 93
 	/**
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
 	protected function getEmailAddresses()
97 97
 	{
98 98
 		$emails = [];
99
-		if( in_array( 'admin', $this->types )) {
99
+		if( in_array( 'admin', $this->types ) ) {
100 100
 			$emails[] = get_option( 'admin_email' );
101 101
 		}
102
-		if( in_array( 'author', $this->types )) {
103
-			$assignedPost = get_post( intval( $this->review->assigned_to ));
102
+		if( in_array( 'author', $this->types ) ) {
103
+			$assignedPost = get_post( intval( $this->review->assigned_to ) );
104 104
 			if( $assignedPost instanceof WP_Post ) {
105 105
 				$emails[] = get_the_author_meta( 'user_email', $assignedPost->post_author );
106 106
 			}
107 107
 		}
108
-		if( in_array( 'custom', $this->types )) {
108
+		if( in_array( 'custom', $this->types ) ) {
109 109
 			$customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' );
110 110
 			$customEmails = str_replace( [' ', ',', ';'], ',', $customEmails );
111 111
 			$customEmails = explode( ',', $customEmails );
112 112
 			$emails = array_merge( $emails, $customEmails );
113 113
 		}
114
-		$emails = array_filter( array_keys( array_flip( $emails )));
114
+		$emails = array_filter( array_keys( array_flip( $emails ) ) );
115 115
 		return apply_filters( 'site-reviews/notification/emails', $emails, $this->review );
116 116
 	}
117 117
 
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function getTitle()
130 130
 	{
131
-		$assignedTitle = get_the_title( intval( $this->review->assigned_to ));
131
+		$assignedTitle = get_the_title( intval( $this->review->assigned_to ) );
132 132
 		$title = _nx(
133 133
 			'New %s-star review',
134 134
 			'New %s-star review of: %s',
135
-			intval( empty( $assignedTitle )),
135
+			intval( empty($assignedTitle) ),
136 136
 			'This string differs depending on whether or not the review has been assigned to a post.',
137 137
 			'site-reviews'
138 138
 		);
139 139
 		$title = sprintf( '[%s] %s',
140
-			wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ),
140
+			wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ),
141 141
 			sprintf( $title, $this->review->rating, $assignedTitle )
142 142
 		);
143 143
 		return apply_filters( 'site-reviews/notification/title', $title, $this->review );
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	protected function sendToEmail( array $args )
150 150
 	{
151 151
 		$email = $this->buildEmail( $args );
152
-		if( empty( $email->to )) {
152
+		if( empty($email->to) ) {
153 153
 			glsr_log()->error( 'Email notification was not sent: missing email address' );
154 154
 			return;
155 155
 		}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	{
166 166
 		$notification = $this->buildSlackNotification( $args );
167 167
 		$result = $notification->send();
168
-		if( is_wp_error( $result )) {
168
+		if( is_wp_error( $result ) ) {
169 169
 			$notification->review = null;
170 170
 			glsr_log()->error( $result->get_error_message() )->debug( $notification );
171 171
 		}
Please login to merge, or discard this patch.
plugin/Router.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	public function routeAdminPostRequest()
18 18
 	{
19 19
 		$request = $this->getRequest();
20
-		if( !$this->isValidPostRequest( $request ))return;
20
+		if( !$this->isValidPostRequest( $request ) )return;
21 21
 		check_admin_referer( $request['action'] );
22 22
 		$this->routeRequest( 'admin', $request['action'], $request );
23 23
 	}
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	{
42 42
 		if( is_admin() )return;
43 43
 		$request = $this->getRequest();
44
-		if( !$this->isValidPostRequest( $request ))return;
45
-		if( !$this->isValidPublicNonce( $request ))return;
44
+		if( !$this->isValidPostRequest( $request ) )return;
45
+		if( !$this->isValidPublicNonce( $request ) )return;
46 46
 		$this->routeRequest( 'public', $request['action'], $request );
47 47
 	}
48 48
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	protected function checkAjaxNonce( array $request )
53 53
 	{
54 54
 		if( !is_user_logged_in() )return;
55
-		if( !isset( $request['nonce'] )) {
55
+		if( !isset($request['nonce']) ) {
56 56
 			$this->sendAjaxError( 'request is missing a nonce', $request );
57 57
 		}
58
-		if( !wp_verify_nonce( $request['nonce'], $request['action'] )) {
58
+		if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
59 59
 			$this->sendAjaxError( 'request failed the nonce check', $request, 403 );
60 60
 		}
61 61
 	}
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function checkAjaxRequest( array $request )
67 67
 	{
68
-		if( !isset( $request['action'] )) {
68
+		if( !isset($request['action']) ) {
69 69
 			$this->sendAjaxError( 'request must include an action', $request );
70 70
 		}
71
-		if( empty( $request['ajax_request'] )) {
71
+		if( empty($request['ajax_request']) ) {
72 72
 			$this->sendAjaxError( 'request is invalid', $request );
73 73
 		}
74 74
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	protected function isValidPostRequest( array $request = [] )
97 97
 	{
98
-		return !empty( $request['action'] ) && empty( $request['ajax_request'] );
98
+		return !empty($request['action']) && empty($request['ajax_request']);
99 99
 	}
100 100
 
101 101
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function isValidPublicNonce( array $request )
105 105
 	{
106
-		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) {
106
+		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
107 107
 			glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
108 108
 			return false;
109 109
 		}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	protected function routeRequest( $type, $action, array $request = [] )
119 119
 	{
120 120
 		$actionHook = 'site-reviews/route/'.$type.'/request';
121
-		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ));
121
+		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
122 122
 		$method = glsr( Helper::class )->buildMethodName( $action, 'router' );
123 123
 		$request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
124 124
 		do_action( $actionHook, $action, $request );
125
-		if( is_callable( [$controller, $method] )) {
125
+		if( is_callable( [$controller, $method] ) ) {
126 126
 			call_user_func( [$controller, $method], $request );
127 127
 			return;
128 128
 		}
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 		glsr_log()->error( $error )->debug( $request );
142 142
 		glsr_log( $_POST );
143 143
 		glsr( Notice::class )->addError( __( 'There was an error (try refreshing the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
144
-		wp_send_json_error([
144
+		wp_send_json_error( [
145 145
 			'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
146 146
 			'notices' => glsr( Notice::class )->get(),
147 147
 			'error' => $error,
148
-		]);
148
+		] );
149 149
 	}
150 150
 }
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 			'post_type' => Application::POST_TYPE,
36 36
 		];
37 37
 		$postId = wp_insert_post( $post, true );
38
-		if( is_wp_error( $postId )) {
38
+		if( is_wp_error( $postId ) ) {
39 39
 			glsr_log()->error( $postId->get_error_message() )->debug( $post );
40 40
 			return false;
41 41
 		}
42 42
 		$this->setTerms( $postId, $command->category );
43 43
 		do_action( 'site-reviews/create/review', $post, $review, $postId );
44
-		return $this->single( get_post( $postId ));
44
+		return $this->single( get_post( $postId ) );
45 45
 	}
46 46
 
47 47
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function delete( $metaReviewId )
52 52
 	{
53
-		if( $postId = $this->getPostId( $metaReviewId )) {
53
+		if( $postId = $this->getPostId( $metaReviewId ) ) {
54 54
 			wp_delete_post( $postId, true );
55 55
 		}
56 56
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$paged = glsr( QueryBuilder::class )->getPaged(
73 73
 			wp_validate_boolean( $args['pagination'] )
74 74
 		);
75
-		$reviews = new WP_Query([
75
+		$reviews = new WP_Query( [
76 76
 			'meta_key' => 'pinned',
77 77
 			'meta_query' => $metaQuery,
78 78
 			'offset' => $args['offset'],
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			'post_type' => Application::POST_TYPE,
86 86
 			'posts_per_page' => $args['count'],
87 87
 			'tax_query' => $taxQuery,
88
-		]);
88
+		] );
89 89
 		return (object)[
90 90
 			'results' => array_map( [$this, 'single'], $reviews->posts ),
91 91
 			'max_num_pages' => $reviews->max_num_pages,
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	public function normalizeTerms( $commaSeparatedTermIds )
109 109
 	{
110 110
 		$terms = [];
111
-		$termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds )));
111
+		$termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds ) ) );
112 112
 		foreach( $termIds as $termId ) {
113 113
 			$term = get_term( $termId, Application::TAXONOMY );
114
-			if( !isset( $term->term_id ))continue;
114
+			if( !isset($term->term_id) )continue;
115 115
 			$terms[] = $term->term_id;
116 116
 		}
117 117
 		return $terms;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	{
126 126
 		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
127 127
 		delete_post_meta( $postId, '_edit_last' );
128
-		$result = wp_update_post([
128
+		$result = wp_update_post( [
129 129
 			'ID' => $postId,
130 130
 			'post_content' => get_post_meta( $postId, 'content', true ),
131 131
 			'post_date' => get_post_meta( $postId, 'date', true ),
132 132
 			'post_title' => get_post_meta( $postId, 'title', true ),
133
-		]);
134
-		if( is_wp_error( $result )) {
133
+		] );
134
+		if( is_wp_error( $result ) ) {
135 135
 			glsr_log()->error( $result->get_error_message() );
136 136
 		}
137 137
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	protected function getNewPostStatus( array $review, $isBlacklisted )
154 154
 	{
155 155
 		$requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' );
156
-		return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted )
156
+		return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted)
157 157
 			? 'pending'
158 158
 			: 'publish';
159 159
 	}
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	protected function setTerms( $postId, $termIds )
167 167
 	{
168 168
 		$terms = $this->normalizeTerms( $termIds );
169
-		if( empty( $terms ))return;
169
+		if( empty($terms) )return;
170 170
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
171
-		if( is_wp_error( $result )) {
171
+		if( is_wp_error( $result ) ) {
172 172
 			glsr_log()->error( $result->get_error_message() );
173 173
 		}
174 174
 	}
Please login to merge, or discard this patch.