Passed
Push — master ( a42385...9b46a7 )
by Paul
04:14
created
plugin/Controllers/PublicController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	public function filterEnqueuedScripts( $tag, $handle )
33 33
 	{
34 34
 		$scripts = [Application::ID.'/google-recaptcha'];
35
-		if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) {
35
+		if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) {
36 36
 			$tag = str_replace( ' src=', ' async src=', $tag );
37 37
 		}
38
-		if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) {
38
+		if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) {
39 39
 			$tag = str_replace( ' src=', ' defer src=', $tag );
40 40
 		}
41 41
 		return $tag;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function routerSubmitReview( array $request )
86 86
 	{
87 87
 		$validated = glsr( ValidateReview::class )->validate( $request );
88
-		if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return;
89
-		$this->execute( new CreateReview( $validated->request ));
88
+		if( !empty($validated->error) || $validated->recaptchaIsUnset )return;
89
+		$this->execute( new CreateReview( $validated->request ) );
90 90
 	}
91 91
 }
Please login to merge, or discard this patch.
plugin/Database/QueryBuilder.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	{
18 18
 		$queries = [];
19 19
 		foreach( $keys as $key ) {
20
-			if( !array_key_exists( $key, $values ))continue;
20
+			if( !array_key_exists( $key, $values ) )continue;
21 21
 			$methodName = glsr( Helper::class )->buildMethodName( $key, __FUNCTION__ );
22
-			if( !method_exists( $this, $methodName ))continue;
22
+			if( !method_exists( $this, $methodName ) )continue;
23 23
 			$query = call_user_func( [$this, $methodName], $values[$key] );
24
-			if( is_array( $query )) {
24
+			if( is_array( $query ) ) {
25 25
 				$queries[] = $query;
26 26
 			}
27 27
 		}
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 		$string = '';
37 37
 		$values = array_filter( $values );
38 38
 		foreach( $conditions as $key => $value ) {
39
-			if( !isset( $values[$key] ))continue;
39
+			if( !isset($values[$key]) )continue;
40 40
 			$values[$key] = implode( ',', (array)$values[$key] );
41 41
 			$string .= strpos( $value, '%s' ) !== false
42
-				? sprintf( $value, strval( $values[$key] ))
42
+				? sprintf( $value, strval( $values[$key] ) )
43 43
 				: $value;
44 44
 		}
45 45
 		return $string;
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function buildSqlOr( $values, $sprintfFormat )
55 55
 	{
56
-		if( !is_array( $values )) {
56
+		if( !is_array( $values ) ) {
57 57
 			$values = explode( ',', $values );
58 58
 		}
59
-		$values = array_filter( array_map( 'trim', (array)$values ));
60
-		$values = array_map( function( $value ) use( $sprintfFormat ) {
59
+		$values = array_filter( array_map( 'trim', (array)$values ) );
60
+		$values = array_map( function( $value ) use($sprintfFormat) {
61 61
 			return sprintf( $sprintfFormat, $value );
62 62
 		}, $values );
63 63
 		return implode( ' OR ', $values );
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function filterSearchByTitle( $search, WP_Query $query )
74 74
 	{
75
-		if( empty( $search ) || empty( $query->get( 'search_terms' ))) {
75
+		if( empty($search) || empty($query->get( 'search_terms' )) ) {
76 76
 			return $search;
77 77
 		}
78 78
 		global $wpdb;
79
-		$n = empty( $query->get( 'exact' ))
79
+		$n = empty($query->get( 'exact' ))
80 80
 			? '%'
81 81
 			: '';
82 82
 		$search = [];
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			? Application::PAGED_QUERY_VAR
101 101
 			: 'page';
102 102
 		return $isEnabled
103
-			? max( 1, intval( get_query_var( $pagedQuery )))
103
+			? max( 1, intval( get_query_var( $pagedQuery ) ) )
104 104
 			: 1;
105 105
 	}
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function buildQueryAssignedTo( $value )
112 112
 	{
113
-		if( empty( $value ))return;
113
+		if( empty($value) )return;
114 114
 		$postIds = glsr( Helper::class )->convertStringToArray( $value, 'is_numeric' );
115 115
 		return [
116 116
 			'compare' => 'IN',
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	protected function buildQueryCategory( $value )
127 127
 	{
128
-		if( empty( $value ))return;
128
+		if( empty($value) )return;
129 129
 		return [
130 130
 			'field' => 'term_id',
131 131
 			'taxonomy' => Application::TAXONOMY,
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function buildQueryRating( $value )
141 141
 	{
142
-		if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return;
142
+		if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return;
143 143
 		return [
144 144
 			'compare' => '>=',
145 145
 			'key' => 'rating',
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function buildQueryType( $value )
155 155
 	{
156
-		if( in_array( $value, ['','all'] ))return;
156
+		if( in_array( $value, ['', 'all'] ) )return;
157 157
 		return [
158 158
 			'key' => 'review_type',
159 159
 			'value' => $value,
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			$this->getCounts(),
67 67
 			$review->review_type,
68 68
 			$review->rating
69
-		));
69
+		) );
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function decreasePostCounts( Review $review )
76 76
 	{
77
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
77
+		if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return;
78 78
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
79 79
 		$this->setPostCounts( $review->assigned_to, $counts );
80 80
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function decreaseTermCounts( Review $review )
86 86
 	{
87 87
 		foreach( $review->term_ids as $termId ) {
88
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
88
+			if( empty($counts = $this->getTermCounts( $termId )) )continue;
89 89
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
90 90
 			$this->setTermCounts( $termId, $counts );
91 91
 		}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	public function flatten( array $reviewCounts, array $args = [] )
98 98
 	{
99 99
 		$counts = [];
100
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
101
-			$counts[$index] = isset( $counts[$index] )
100
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
101
+			$counts[$index] = isset($counts[$index])
102 102
 				? $num + $counts[$index]
103 103
 				: $num;
104 104
 		});
105 105
 		$args = wp_parse_args( $args, [
106 106
 			'max' => Rating::MAX_RATING,
107 107
 			'min' => Rating::MIN_RATING,
108
-		]);
108
+		] );
109 109
 		foreach( $counts as $index => &$num ) {
110
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
110
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue;
111 111
 			$num = 0;
112 112
 		}
113 113
 		return $counts;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			'post_ids' => [],
123 123
 			'term_ids' => [],
124 124
 			'type' => 'local',
125
-		]);
125
+		] );
126 126
 		$counts = [];
127 127
 		foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) {
128 128
 			$counts[] = $this->getPostCounts( $postId );
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 		foreach( $args['term_ids'] as $termId ) {
131 131
 			$counts[] = $this->getTermCounts( $termId );
132 132
 		}
133
-		if( empty( $counts )) {
133
+		if( empty($counts) ) {
134 134
 			$counts[] = $this->getCounts();
135 135
 		}
136
-		return $this->normalize( array_column( $counts, $args['type'] ));
136
+		return $this->normalize( array_column( $counts, $args['type'] ) );
137 137
 	}
138 138
 
139 139
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function getPostCounts( $postId )
152 152
 	{
153
-		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ));
153
+		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
154 154
 	}
155 155
 
156 156
 	/**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function getTermCounts( $termId )
161 161
 	{
162
-		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ));
162
+		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
163 163
 	}
164 164
 
165 165
 	/**
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function increaseCounts( Review $review )
179 179
 	{
180
-		if( empty( $counts = $this->getCounts() )) {
180
+		if( empty($counts = $this->getCounts()) ) {
181 181
 			$counts = $this->buildCounts();
182 182
 		}
183 183
 		$this->setCounts( $this->increaseRating(
184 184
 			$counts,
185 185
 			$review->review_type,
186 186
 			$review->rating
187
-		));
187
+		) );
188 188
 	}
189 189
 
190 190
 	/**
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function increasePostCounts( Review $review )
194 194
 	{
195
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
195
+		if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return;
196 196
 		$counts = $this->getPostCounts( $review->assigned_to );
197
-		$counts = empty( $counts )
197
+		$counts = empty($counts)
198 198
 			? $this->buildPostCounts( $review->assigned_to )
199 199
 			: $this->increaseRating( $counts, $review->review_type, $review->rating );
200 200
 		$this->setPostCounts( $review->assigned_to, $counts );
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	public function increaseTermCounts( Review $review )
207 207
 	{
208
-		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ));
208
+		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
209 209
 		foreach( $termIds as $termId ) {
210 210
 			$counts = $this->getTermCounts( $termId );
211
-			$counts = empty( $counts )
211
+			$counts = empty($counts)
212 212
 				? $this->buildTermCounts( $termId )
213 213
 				: $this->increaseRating( $counts, $review->review_type, $review->rating );
214 214
 			$this->setTermCounts( $termId, $counts );
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	{
232 232
 		$ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts );
233 233
 		update_post_meta( $postId, static::META_COUNT, $reviewCounts );
234
-		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
235
-		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
234
+		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
235
+		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function setTermCounts( $termId, array $reviewCounts )
243 243
 	{
244
-		if( !term_exists( $termId ))return;
244
+		if( !term_exists( $termId ) )return;
245 245
 		$ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts );
246 246
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
247
-		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
248
-		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
247
+		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
248
+		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
249 249
 	}
250 250
 
251 251
 	/**
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 	{
257 257
 		$counts = [];
258 258
 		$lastPostId = 0;
259
-		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
260
-			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
259
+		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) {
260
+			$types = array_keys( array_flip( array_column( $reviews, 'type' ) ) );
261 261
 			foreach( $types as $type ) {
262
-				if( isset( $counts[$type] ))continue;
262
+				if( isset($counts[$type]) )continue;
263 263
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
264 264
 			}
265 265
 			foreach( $reviews as $review ) {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	protected function decreaseRating( array $reviewCounts, $type, $rating )
279 279
 	{
280
-		if( isset( $reviewCounts[$type][$rating] )) {
280
+		if( isset($reviewCounts[$type][$rating]) ) {
281 281
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
282 282
 		}
283 283
 		return $reviewCounts;
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	protected function increaseRating( array $reviewCounts, $type, $rating )
292 292
 	{
293
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
293
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
294 294
 			return $reviewCounts;
295 295
 		}
296
-		if( !array_key_exists( $type, $reviewCounts )) {
296
+		if( !array_key_exists( $type, $reviewCounts ) ) {
297 297
 			$reviewCounts[$type] = [];
298 298
 		}
299 299
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	protected function normalize( array $reviewCounts )
308 308
 	{
309
-		if( empty( $reviewCounts )) {
309
+		if( empty($reviewCounts) ) {
310 310
 			$reviewCounts = [[]];
311 311
 		}
312 312
 		foreach( $reviewCounts as &$counts ) {
313 313
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
314
-				if( isset( $counts[$index] ))continue;
314
+				if( isset($counts[$index]) )continue;
315 315
 				$counts[$index] = 0;
316 316
 			}
317 317
 			ksort( $counts );
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	protected function queryReviews( array $args = [], $lastPostId, $limit )
328 328
 	{
329
-		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ));
330
-		if( empty( array_filter( $args ))) {
329
+		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) );
330
+		if( empty(array_filter( $args )) ) {
331 331
 			return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit );
332 332
 		}
333
-		if( !empty( $args['post_id'] )) {
333
+		if( !empty($args['post_id']) ) {
334 334
 			return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit );
335 335
 		}
336
-		if( !empty( $args['term_id'] )) {
336
+		if( !empty($args['term_id']) ) {
337 337
 			return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit );
338 338
 		}
339 339
 	}
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 	public function __construct( $input )
29 29
 	{
30 30
 		$this->request = $input;
31
-		$this->ajax_request = isset( $input['ajax_request'] );
31
+		$this->ajax_request = isset($input['ajax_request']);
32 32
 		$this->assigned_to = $this->getNumeric( 'assign_to' );
33
-		$this->author = sanitize_text_field( $this->get( 'name' ));
34
-		$this->avatar = get_avatar_url( $this->get( 'email' ));
35
-		$this->blacklisted = isset( $input['blacklisted'] );
36
-		$this->category = sanitize_key( $this->get( 'category' ));
37
-		$this->content = sanitize_textarea_field( $this->get( 'content' ));
33
+		$this->author = sanitize_text_field( $this->get( 'name' ) );
34
+		$this->avatar = get_avatar_url( $this->get( 'email' ) );
35
+		$this->blacklisted = isset($input['blacklisted']);
36
+		$this->category = sanitize_key( $this->get( 'category' ) );
37
+		$this->content = sanitize_textarea_field( $this->get( 'content' ) );
38 38
 		$this->custom = $this->getCustom();
39
-		$this->email = sanitize_email( $this->get( 'email' ));
40
-		$this->form_id = sanitize_key( $this->get( 'form_id' ));
39
+		$this->email = sanitize_email( $this->get( 'email' ) );
40
+		$this->form_id = sanitize_key( $this->get( 'form_id' ) );
41 41
 		$this->ip_address = $this->get( 'ip_address' );
42
-		$this->post_id = intval( $this->get( 'post_id' ));
43
-		$this->rating = intval( $this->get( 'rating' ));
42
+		$this->post_id = intval( $this->get( 'post_id' ) );
43
+		$this->rating = intval( $this->get( 'rating' ) );
44 44
 		$this->referer = $this->get( 'referer' );
45
-		$this->terms = !empty( $input['terms'] );
46
-		$this->title = sanitize_text_field( $this->get( 'title' ));
45
+		$this->terms = !empty($input['terms']);
46
+		$this->title = sanitize_text_field( $this->get( 'title' ) );
47 47
 	}
48 48
 
49 49
 	/**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	protected function get( $key )
54 54
 	{
55
-		return isset( $this->request[$key] )
55
+		return isset($this->request[$key])
56 56
 			? (string)$this->request[$key]
57 57
 			: '';
58 58
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		];
70 70
 		$custom = $this->request;
71 71
 		foreach( $unset as $value ) {
72
-			unset( $custom[$value] );
72
+			unset($custom[$value]);
73 73
 		}
74 74
 		return $custom;
75 75
 	}
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	public function file( $view )
82 82
 	{
83 83
 		$file = '';
84
-		if( glsr( Helper::class )->startsWith( 'templates/', $view )) {
84
+		if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) {
85 85
 			$file = str_replace( 'templates/', 'site-reviews/', $view ).'.php';
86 86
 			$file = get_stylesheet_directory().'/'.$file;
87
-			if( !file_exists( $file )) {
87
+			if( !file_exists( $file ) ) {
88 88
 				$file = $this->path( $view.'.php' );
89 89
 			}
90 90
 		}
91
-		if( !file_exists( $file )) {
91
+		if( !file_exists( $file ) ) {
92 92
 			$file = $this->path( 'views/'.$view.'.php' );
93 93
 		}
94 94
 		return $file;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function getDefaults()
101 101
 	{
102
-		if( empty( $this->defaults )) {
102
+		if( empty($this->defaults) ) {
103 103
 			$this->defaults = $this->make( DefaultsManager::class )->get();
104 104
 			$this->upgrade();
105 105
 		}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	public function hasPermission()
113 113
 	{
114 114
 		$isAdmin = $this->isAdmin();
115
-		return !$isAdmin || ( $isAdmin && current_user_can( static::CAPABILITY ));
115
+		return !$isAdmin || ($isAdmin && current_user_can( static::CAPABILITY ));
116 116
 	}
117 117
 
118 118
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$types = apply_filters( 'site-reviews/addon/types', [] );
169 169
 		$this->reviewTypes = wp_parse_args( $types, [
170 170
 			'local' => __( 'Local', 'site-reviews' ),
171
-		]);
171
+		] );
172 172
 	}
173 173
 
174 174
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	{
180 180
 		$view = apply_filters( 'site-reviews/render/view', $view, $data );
181 181
 		$file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
182
-		if( !file_exists( $file )) {
182
+		if( !file_exists( $file ) ) {
183 183
 			glsr_log()->error( 'File not found: '.$file );
184 184
 			return;
185 185
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function scheduleCronJob()
195 195
 	{
196
-		if( wp_next_scheduled( static::CRON_EVENT ))return;
196
+		if( wp_next_scheduled( static::CRON_EVENT ) )return;
197 197
 		wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
198 198
 	}
199 199
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function unscheduleCronJob()
204 204
 	{
205
-		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT );
205
+		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
206 206
 	}
207 207
 
208 208
 	/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	public function url( $path = '' )
236 236
 	{
237
-		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ));
237
+		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
238 238
 		return apply_filters( 'site-reviews/url', $url, $path );
239 239
 	}
240 240
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute ) )break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function validateAttribute( $attribute, $rule )
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
92
+		list($rule, $parameters) = $this->parseRule( $rule );
93 93
 		if( $rule == '' )return;
94 94
 		$value = $this->getValue( $attribute );
95
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
95
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
96 96
 			throw new BadMethodCallException( "Method [$method] does not exist." );
97 97
 		}
98
-		if( !$this->$method( $value, $attribute, $parameters )) {
98
+		if( !$this->$method( $value, $attribute, $parameters ) ) {
99 99
 			$this->addFailure( $attribute, $rule, $parameters );
100 100
 		}
101 101
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function getMessage( $attribute, $rule, array $parameters )
146 146
 	{
147
-		if( in_array( $rule, $this->sizeRules )) {
147
+		if( in_array( $rule, $this->sizeRules ) ) {
148 148
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
149 149
 		}
150 150
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function getRule( $attribute, $rules )
161 161
 	{
162
-		if( !array_key_exists( $attribute, $this->rules ))return;
162
+		if( !array_key_exists( $attribute, $this->rules ) )return;
163 163
 		$rules = (array)$rules;
164 164
 		foreach( $this->rules[$attribute] as $rule ) {
165
-			list( $rule, $parameters ) = $this->parseRule( $rule );
166
-			if( in_array( $rule, $rules )) {
165
+			list($rule, $parameters) = $this->parseRule( $rule );
166
+			if( in_array( $rule, $rules ) ) {
167 167
 				return [$rule, $parameters];
168 168
 			}
169 169
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		if( is_numeric( $value ) && $hasNumeric ) {
182 182
 			return $value;
183 183
 		}
184
-		elseif( is_array( $value )) {
184
+		elseif( is_array( $value ) ) {
185 185
 			return count( $value );
186 186
 		}
187 187
 		return mb_strlen( $value );
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function getValue( $attribute )
209 209
 	{
210
-		if( isset( $this->data[$attribute] )) {
210
+		if( isset($this->data[$attribute]) ) {
211 211
 			return $this->data[$attribute];
212 212
 		}
213 213
 	}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	protected function hasRule( $attribute, $rules )
222 222
 	{
223
-		return !is_null( $this->getRule( $attribute, $rules ));
223
+		return !is_null( $this->getRule( $attribute, $rules ) );
224 224
 	}
225 225
 
226 226
 	/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	{
259 259
 		$parameters = [];
260 260
 		if( strpos( $rule, ':' ) !== false ) {
261
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
261
+			list($rule, $parameter) = explode( ':', $rule, 2 );
262 262
 			$parameters = $this->parseParameters( $rule, $parameter );
263 263
 		}
264 264
 		$rule = glsr( Helper::class )->camelCase( $rule );
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	protected function shouldStopValidating( $attribute )
288 288
 	{
289 289
 		return $this->hasRule( $attribute, $this->implicitRules )
290
-			&& isset( $this->failedRules[$attribute] )
290
+			&& isset($this->failedRules[$attribute])
291 291
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
292 292
 	}
293 293
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	protected function translator( $key, array $parameters )
301 301
 	{
302 302
 		$strings = glsr( ValidationStringsDefaults::class )->defaults();
303
-		if( isset( $strings[$key] )) {
303
+		if( isset($strings[$key]) ) {
304 304
 			return $this->replace( $strings[$key], $parameters );
305 305
 		}
306 306
 		return "error";
Please login to merge, or discard this patch.
plugin/Modules/Polylang.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
 	public function getPost( $postId )
14 14
 	{
15 15
 		if( $this->isEnabled() ) {
16
-			$polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() ));
16
+			$polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() ) );
17 17
 		}
18
-		if( !empty( $polylangPostId )) {
18
+		if( !empty($polylangPostId) ) {
19 19
 			$postId = $polylangPostId;
20 20
 		}
21
-		return get_post( intval( $postId ));
21
+		return get_post( intval( $postId ) );
22 22
 	}
23 23
 
24 24
 	/**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		foreach( $this->cleanIds( $postIds ) as $postId ) {
34 34
 			$newPostIds = array_merge(
35 35
 				$newPostIds,
36
-				array_values( pll_get_post_translations( $postId ))
36
+				array_values( pll_get_post_translations( $postId ) )
37 37
 			);
38 38
 		}
39 39
 		return $this->cleanIds( $newPostIds );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	protected function cleanIds( array $postIds )
75 75
 	{
76
-		return array_filter( array_unique( $postIds ));
76
+		return array_filter( array_unique( $postIds ) );
77 77
 	}
78 78
 }
79 79
 
Please login to merge, or discard this patch.
plugin/Modules/Style.php 1 patch
Spacing   +6 added lines, -6 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()->path( $possibleView.'.php' )))continue;
58
+			if( !file_exists( glsr()->path( $possibleView.'.php' ) ) )continue;
59 59
 			return $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,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function customize( Builder $instance )
107 107
 	{
108
-		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ));
108
+		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
109 109
 		$key = $instance->tag.'_'.$args['type'];
110
-		$classes = !isset( $this->fields[$key] )
110
+		$classes = !isset($this->fields[$key])
111 111
 			? $this->fields[$instance->tag]
112 112
 			: $this->fields[$key];
113 113
 		$instance->args['class'] = trim( $args['class'].' '.$classes );
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$args = wp_parse_args( $instance->args, [
142 142
 			'is_public' => false,
143 143
 			'is_raw' => false,
144
-		]);
144
+		] );
145 145
 		if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
146 146
 			return false;
147 147
 		}
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 			if( $review->review_type != 'local' )continue;
39 39
 			$reviews[] = $this->buildReview( $review );
40 40
 		}
41
-		if( !empty( $reviews )) {
41
+		if( !empty($reviews) ) {
42 42
 			array_walk( $reviews, function( &$review ) {
43
-				unset( $review['@context'] );
44
-				unset( $review['itemReviewed'] );
43
+				unset($review['@context']);
44
+				unset($review['itemReviewed']);
45 45
 			});
46 46
 			$schema['review'] = $reviews;
47 47
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function buildSummary( $args = null )
56 56
 	{
57
-		if( is_array( $args )) {
57
+		if( is_array( $args ) ) {
58 58
 			$this->args = $args;
59 59
 		}
60 60
 		$buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$schema = method_exists( $this, $buildSummary )
63 63
 			? $this->$buildSummary()
64 64
 			: $this->buildSummaryForCustom();
65
-		if( !empty( $count )) {
65
+		if( !empty($count) ) {
66 66
 			$schema->aggregateRating(
67 67
 				$this->getSchemaType( 'AggregateRating' )
68 68
 					->ratingValue( $this->getRatingValue() )
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function render()
82 82
 	{
83
-		if( is_null( glsr()->schemas ))return;
83
+		if( is_null( glsr()->schemas ) )return;
84 84
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
85 85
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
86 86
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
87
-		));
87
+		) );
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$schemas = glsr()->schemas;
96 96
 		$schemas[] = $schema;
97
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
97
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 	protected function buildReview( $review )
105 105
 	{
106 106
 		$schema = $this->getSchemaType( 'Review' )
107
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) {
107
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) {
108 108
 				$schema->name( $review->title );
109 109
 			})
110
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) {
110
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) {
111 111
 				$schema->reviewBody( $review->content );
112 112
 			})
113
-			->datePublished(( new DateTime( $review->date )))
114
-			->author( $this->getSchemaType( 'Person' )->name( $review->author ))
115
-			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' )));
116
-		if( !empty( $review->rating )) {
113
+			->datePublished( (new DateTime( $review->date )) )
114
+			->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
115
+			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
116
+		if( !empty($review->rating) ) {
117 117
 			$schema->reviewRating(
118 118
 				$this->getSchemaType( 'Rating' )
119 119
 					->ratingValue( $review->rating )
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		foreach( $values as $value ) {
134 134
 			$option = $this->getSchemaOptionValue( $value );
135
-			if( empty( $option ))continue;
135
+			if( empty($option) )continue;
136 136
 			$schema->$value( $option );
137 137
 		}
138 138
 		return $schema;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		return $this->buildSchemaValues( $this->getSchemaType(), [
147 147
 			'description', 'image', 'name', 'url',
148
-		]);
148
+		] );
149 149
 	}
150 150
 
151 151
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
157 157
 			'address', 'priceRange', 'telephone',
158
-		]);
158
+		] );
159 159
 	}
160 160
 
161 161
 	/**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	{
166 166
 		$offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [
167 167
 			'highPrice', 'lowPrice', 'priceCurrency',
168
-		]);
168
+		] );
169 169
 		return $this->buildSummaryForCustom()
170 170
 			->offers( $offers )
171
-			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ));
171
+			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) );
172 172
 	}
173 173
 
174 174
 	/**
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	protected function getRatingCounts()
178 178
 	{
179
-		if( !isset( $this->ratingCounts )) {
180
-			$counts = glsr( CountsManager::class )->get([
179
+		if( !isset($this->ratingCounts) ) {
180
+			$counts = glsr( CountsManager::class )->get( [
181 181
 				'post_ids' => glsr( Helper::class )->convertStringToArray( $this->args['assigned_to'] ),
182 182
 				'term_ids' => glsr( ReviewManager::class )->normalizeTerms( $this->args['category'] ),
183
-			]);
183
+			] );
184 184
 			$this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [
185 185
 				'min' => $this->args['rating'],
186
-			]);
186
+			] );
187 187
 		}
188 188
 		return $this->ratingCounts;
189 189
 	}
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	protected function getSchemaOption( $option, $fallback )
205 205
 	{
206 206
 		$option = strtolower( $option );
207
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
207
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
208 208
 			return $schemaOption;
209 209
 		}
210 210
 		$setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
211
-		if( is_array( $setting )) {
211
+		if( is_array( $setting ) ) {
212 212
 			return $this->getSchemaOptionDefault( $setting, $fallback );
213 213
 		}
214
-		return !empty( $setting )
214
+		return !empty($setting)
215 215
 			? $setting
216 216
 			: $fallback;
217 217
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$setting = wp_parse_args( $setting, [
226 226
 			'custom' => '',
227 227
 			'default' => $fallback,
228
-		]);
228
+		] );
229 229
 		return $setting['default'] != 'custom'
230 230
 			? $setting['default']
231 231
 			: $setting['custom'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		}
245 245
 		if( !is_single() && !is_page() )return;
246 246
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
247
-		if( method_exists( $this, $method )) {
247
+		if( method_exists( $this, $method ) ) {
248 248
 			return $this->$method();
249 249
 		}
250 250
 	}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	protected function getSchemaType( $type = null )
257 257
 	{
258
-		if( !is_string( $type )) {
258
+		if( !is_string( $type ) ) {
259 259
 			$type = $this->getSchemaOption( 'type', 'LocalBusiness' );
260 260
 		}
261 261
 		$className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	protected function getThingDescription()
271 271
 	{
272 272
 		$post = get_post();
273
-		if( !( $post instanceof WP_Post )) {
273
+		if( !($post instanceof WP_Post) ) {
274 274
 			return '';
275 275
 		}
276
-		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ));
277
-		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ));
276
+		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) );
277
+		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
278 278
 	}
279 279
 
280 280
 	/**
Please login to merge, or discard this patch.