Passed
Push — master ( e5c4f5...cb56ad )
by Paul
03:27
created
compatibility.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
  * @see https://wordpress.org/plugins/wp-super-cache/
21 21
  */
22 22
 add_action( 'site-reviews/review/created', function( $review, $request ) {
23
-	if( !function_exists( 'wp_cache_post_change' ))return;
23
+	if( !function_exists( 'wp_cache_post_change' ) )return;
24 24
 	wp_cache_post_change( $request->post_id );
25
-	if( empty( $review->assigned_to ) || $review->assigned_to == $request->post_id )return;
25
+	if( empty($review->assigned_to) || $review->assigned_to == $request->post_id )return;
26 26
 	wp_cache_post_change( $review->assigned_to );
27 27
 }, 10, 2 );
28 28
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) {
35 35
 	$scriptHandles[] = 'site-reviews/google-recaptcha';
36
-	return array_keys( array_flip( $scriptHandles ));
36
+	return array_keys( array_flip( $scriptHandles ) );
37 37
 });
38 38
 
39 39
 /**
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
  * @see https://searchandfilter.com/
44 44
  */
45 45
 add_filter( 'sf_edit_query_args', function( $query ) {
46
-	if( !empty( $query['meta_key'] ) && $query['meta_key'] == '_glsr_ranking' ) {
47
-		unset( $query['meta_key'] );
46
+	if( !empty($query['meta_key']) && $query['meta_key'] == '_glsr_ranking' ) {
47
+		unset($query['meta_key']);
48 48
 		$query['meta_query'] = [
49 49
 			'relation' => 'OR',
50 50
 			['key' => '_glsr_ranking', 'compare' => 'EXISTS'],
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 			$className = str_replace( '.php', '', $file );
25 25
 			$version = str_replace( ['Upgrade_', '_'], ['', '.'], $className );
26 26
 			$versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
27
-			if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return;
27
+			if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return;
28 28
 			glsr( 'Modules\\Upgrader\\'.$className );
29 29
 			glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix );
30 30
 		});
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			$this->setReviewCounts();
42 42
 			$this->updateVersionFrom( $version );
43 43
 		}
44
-		else if( !glsr( OptionManager::class )->get( 'last_review_count', false )) {
44
+		else if( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) {
45 45
 			$this->setReviewCounts();
46 46
 		}
47 47
 	}
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
-		else if( is_array( $value )) {
184
+		else if( is_array( $value ) ) {
185 185
 			return count( $value );
186 186
 		}
187 187
 		return function_exists( 'mb_strlen' )
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getValue( $attribute )
211 211
 	{
212
-		if( isset( $this->data[$attribute] )) {
212
+		if( isset($this->data[$attribute]) ) {
213 213
 			return $this->data[$attribute];
214 214
 		}
215 215
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function hasRule( $attribute, $rules )
224 224
 	{
225
-		return !is_null( $this->getRule( $attribute, $rules ));
225
+		return !is_null( $this->getRule( $attribute, $rules ) );
226 226
 	}
227 227
 
228 228
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	{
261 261
 		$parameters = [];
262 262
 		if( strpos( $rule, ':' ) !== false ) {
263
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
263
+			list($rule, $parameter) = explode( ':', $rule, 2 );
264 264
 			$parameters = $this->parseParameters( $rule, $parameter );
265 265
 		}
266 266
 		$rule = glsr( Helper::class )->camelCase( $rule );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	protected function shouldStopValidating( $attribute )
290 290
 	{
291 291
 		return $this->hasRule( $attribute, $this->implicitRules )
292
-			&& isset( $this->failedRules[$attribute] )
292
+			&& isset($this->failedRules[$attribute])
293 293
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
294 294
 	}
295 295
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	protected function translator( $key, array $parameters )
303 303
 	{
304 304
 		$strings = glsr( ValidationStringsDefaults::class )->defaults();
305
-		if( isset( $strings[$key] )) {
305
+		if( isset($strings[$key]) ) {
306 306
 			return $this->replace( $strings[$key], $parameters );
307 307
 		}
308 308
 		return "error";
Please login to merge, or discard this patch.
plugin/Database/DefaultsManager.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 	public function defaults()
14 14
 	{
15 15
 		$settings = $this->settings();
16
-		$defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ));
16
+		$defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) );
17 17
 		return wp_parse_args( $defaults, [
18 18
 			'version' => '',
19 19
 			'version_upgraded_from' => '',
20
-		]);
20
+		] );
21 21
 	}
22 22
 
23 23
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function settings()
48 48
 	{
49
-		$settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ));
49
+		$settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) );
50 50
 		return $this->normalize( $settings );
51 51
 	}
52 52
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	protected function normalize( array $settings )
57 57
 	{
58 58
 		array_walk( $settings, function( &$setting ) {
59
-			if( isset( $setting['default'] ))return;
59
+			if( isset($setting['default']) )return;
60 60
 			$setting['default'] = '';
61 61
 		});
62 62
 		return $settings;
Please login to merge, or discard this patch.
plugin/Modules/Rating.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		$average = array_sum( $ratingCounts );
51 51
 		if( $average > 0 ) {
52
-			$average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ));
52
+			$average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ) );
53 53
 		}
54
-		return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ));
54
+		return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ) );
55 55
 	}
56 56
 
57 57
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 		$z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
74 74
 		$phat = 1 * $upDownCounts[1] / $numRatings;
75
-		return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings );
75
+		return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings);
76 76
 	}
77 77
 
78 78
 	/**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	{
91 91
 		$total = array_sum( $ratingCounts );
92 92
 		foreach( $ratingCounts as $index => $count ) {
93
-			if( empty( $count ))continue;
93
+			if( empty($count) )continue;
94 94
 			$ratingCounts[$index] = $count / $total * 100;
95 95
 		}
96 96
 		return $this->getRoundedPercentages( $ratingCounts );
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			$this->getRankingUsingImdb( $ratingCounts ),
106 106
 			$ratingCounts,
107 107
 			$this
108
-		));
108
+		) );
109 109
 	}
110 110
 
111 111
 	/**
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		$avgRating = $this->getAverage( $ratingCounts );
124 124
 		// Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error.
125 125
 		// This could also be the average score of all items instead of a fixed value.
126
-		$bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5
126
+		$bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5
127 127
 		// Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
128 128
 		$bayesMinimal = 10; // confidence
129 129
 		$numOfReviews = array_sum( $ratingCounts );
130 130
 		return $avgRating > 0
131
-			? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews )
131
+			? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
132 132
 			: 0;
133 133
 	}
134 134
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$weight = $this->getWeight( $ratingCounts, $ratingCountsSum );
149 149
 		$weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true );
150 150
 		$zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
151
-		return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 ));
151
+		return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) );
152 152
 	}
153 153
 
154 154
 	/**
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
 		$remainders = glsr_array_column( $percentages, 'remainder' );
169 169
 		array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages );
170 170
 		$i = 0;
171
-		if( array_sum( glsr_array_column( $percentages, 'percent' )) > 0 ) {
172
-			while( array_sum( glsr_array_column( $percentages, 'percent' )) < $totalPercent ) {
171
+		if( array_sum( glsr_array_column( $percentages, 'percent' ) ) > 0 ) {
172
+			while( array_sum( glsr_array_column( $percentages, 'percent' ) ) < $totalPercent ) {
173 173
 				$percentages[$i]['percent']++;
174 174
 				$i++;
175 175
 			}
176 176
 		}
177 177
 		array_multisort( $indexes, SORT_DESC, $percentages );
178
-		return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ));
178
+		return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ) );
179 179
 	}
180 180
 
181 181
 	/**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function getTotalSum( array $ratingCounts )
185 185
 	{
186
-		return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use( $ratingCounts ) {
187
-			return $carry + ( $index * $ratingCounts[$index] );
186
+		return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use($ratingCounts) {
187
+			return $carry + ($index * $ratingCounts[$index]);
188 188
 		});
189 189
 	}
190 190
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false )
197 197
 	{
198 198
 		return array_reduce( array_keys( $ratingCounts ),
199
-			function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) {
199
+			function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) {
200 200
 				$ratingLevel = $powerOf2
201 201
 					? pow( $rating, 2 )
202 202
 					: $rating;
203
-				return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum;
203
+				return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
204 204
 			}
205 205
 		);
206 206
 	}
Please login to merge, or discard this patch.
plugin/Modules/Translation.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$translations = $this->translations();
32 32
 		$entries = $this->filter( $translations, $this->entries() )->results();
33
-		array_walk( $translations, function( &$entry ) use( $entries ) {
33
+		array_walk( $translations, function( &$entry ) use($entries) {
34 34
 			$entry['desc'] = array_key_exists( $entry['id'], $entries )
35 35
 				? $this->getEntryString( $entries[$entry['id']], 'msgctxt' )
36 36
 				: '';
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function entries()
45 45
 	{
46
-		if( !isset( $this->entries )) {
46
+		if( !isset($this->entries) ) {
47 47
 			$potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' );
48 48
 			$entries = $this->extractEntriesFromPotFile( $potFile );
49 49
 			$entries = apply_filters( 'site-reviews/translation/entries', $entries );
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function filter( $filterWith = null, $entries = null, $intersect = true )
90 90
 	{
91
-		if( !is_array( $entries )) {
91
+		if( !is_array( $entries ) ) {
92 92
 			$entries = $this->results;
93 93
 		}
94
-		if( !is_array( $filterWith )) {
94
+		if( !is_array( $filterWith ) ) {
95 95
 			$filterWith = $this->translations();
96 96
 		}
97
-		$keys = array_flip( glsr_array_column( $filterWith, 'id' ));
97
+		$keys = array_flip( glsr_array_column( $filterWith, 'id' ) );
98 98
 		$this->results = $intersect
99 99
 			? array_intersect_key( $entries, $keys )
100 100
 			: array_diff_key( $entries, $keys );
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	public function render( $template, array $entry )
109 109
 	{
110 110
 		$data = array_combine(
111
-			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )),
111
+			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ),
112 112
 			$entry
113 113
 		);
114 114
 		$data['data.class'] = $data['data.error'] = '';
115
-		if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' )) === false ) {
115
+		if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) === false ) {
116 116
 			$data['data.class'] = 'is-invalid';
117 117
 			$data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' );
118 118
 		}
119 119
 		return glsr( Template::class )->build( 'partials/translations/'.$template, [
120 120
 			'context' => $data,
121
-		]);
121
+		] );
122 122
 	}
123 123
 
124 124
 	/**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 				'p1' => $this->getEntryString( $entry, 'msgid_plural' ),
151 151
 				's1' => $this->getEntryString( $entry, 'msgid' ),
152 152
 			];
153
-			$text = !empty( $data['p1'] )
153
+			$text = !empty($data['p1'])
154 154
 				? sprintf( '%s | %s', $data['s1'], $data['p1'] )
155 155
 				: $data['s1'];
156 156
 			$rendered .= $this->render( 'result', [
157
-				'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ),
157
+				'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ),
158 158
 				'text' => wp_strip_all_tags( $text ),
159
-			]);
159
+			] );
160 160
 		}
161 161
 		if( $resetAfterRender ) {
162 162
 			$this->reset();
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 	public function search( $needle = '' )
190 190
 	{
191 191
 		$this->reset();
192
-		$needle = trim( strtolower( $needle ));
192
+		$needle = trim( strtolower( $needle ) );
193 193
 		foreach( $this->entries() as $key => $entry ) {
194
-			$single = strtolower( $this->getEntryString( $entry, 'msgid' ));
195
-			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ));
194
+			$single = strtolower( $this->getEntryString( $entry, 'msgid' ) );
195
+			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) );
196 196
 			if( strlen( $needle ) < static::SEARCH_THRESHOLD ) {
197
-				if( in_array( $needle, [$single, $plural] )) {
197
+				if( in_array( $needle, [$single, $plural] ) ) {
198 198
 					$this->results[$key] = $entry;
199 199
 				}
200 200
 			}
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	public function translations()
213 213
 	{
214 214
 		static $translations;
215
-		if( empty( $translations )) {
215
+		if( empty($translations) ) {
216 216
 			$settings = glsr( OptionManager::class )->get( 'settings' );
217
-			$translations = isset( $settings['strings'] )
218
-				? $this->normalizeSettings( (array) $settings['strings'] )
217
+			$translations = isset($settings['strings'])
218
+				? $this->normalizeSettings( (array)$settings['strings'] )
219 219
 				: [];
220 220
 		}
221 221
 		return $translations;
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	protected function getEntryString( array $entry, $key )
229 229
 	{
230
-		return isset( $entry[$key] )
231
-			? implode( '', (array) $entry[$key] )
230
+		return isset($entry[$key])
231
+			? implode( '', (array)$entry[$key] )
232 232
 			: '';
233 233
 	}
234 234
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		$keys = [
241 241
 			'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]',
242 242
 		];
243
-		array_walk( $entries, function( &$entry ) use( $keys ) {
243
+		array_walk( $entries, function( &$entry ) use($keys) {
244 244
 			foreach( $keys as $key ) {
245 245
 				$entry = $this->normalizeEntryString( $entry, $key );
246 246
 			}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	protected function normalizeEntryString( array $entry, $key )
256 256
 	{
257
-		if( isset( $entry[$key] )) {
257
+		if( isset($entry[$key]) ) {
258 258
 			$entry[$key] = $this->getEntryString( $entry, $key );
259 259
 		}
260 260
 		return $entry;
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 		$defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' );
269 269
 		$strings = array_filter( $strings, 'is_array' );
270 270
 		foreach( $strings as &$string ) {
271
-			$string['type'] = isset( $string['p1'] ) ? 'plural' : 'single';
271
+			$string['type'] = isset($string['p1']) ? 'plural' : 'single';
272 272
 			$string = wp_parse_args( $string, $defaultString );
273 273
 		}
274 274
 		return array_filter( $strings, function( $string ) {
275
-			return !empty( $string['id'] );
275
+			return !empty($string['id']);
276 276
 		});
277 277
 	}
278 278
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsSummary.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	public function build( array $args = [] )
36 36
 	{
37 37
 		$this->args = $args;
38
-		$counts = glsr( CountsManager::class )->get([
38
+		$counts = glsr( CountsManager::class )->get( [
39 39
 			'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ),
40 40
 			'term_ids' => glsr( ReviewManager::class )->normalizeTermIds( $args['category'] ),
41 41
 			'type' => $args['type'],
42
-		]);
42
+		] );
43 43
 		$this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [
44 44
 			'min' => $args['rating'],
45
-		]);
46
-		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return;
45
+		] );
46
+		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return;
47 47
 		$this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts );
48 48
 		$this->generateSchema();
49 49
 		return glsr( Template::class )->build( 'templates/reviews-summary', [
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 				'stars' => $this->buildStars(),
57 57
 				'text' => $this->buildText(),
58 58
 			],
59
-		]);
59
+		] );
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	protected function buildPercentage()
66 66
 	{
67
-		if( $this->isHidden( 'bars' ))return;
68
-		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ));
69
-		$bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) {
67
+		if( $this->isHidden( 'bars' ) )return;
68
+		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) );
69
+		$bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) {
70 70
 			$label = $this->buildPercentageLabel( $this->args['labels'][$level] );
71 71
 			$background = $this->buildPercentageBackground( $percentages[$level] );
72 72
 			$count = apply_filters( 'site-reviews/summary/counts',
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$percent = $this->buildPercentageCount( $count );
77 77
 			return $carry.glsr( Builder::class )->div( $label.$background.$percent, [
78 78
 				'class' => 'glsr-bar',
79
-			]);
79
+			] );
80 80
 		});
81 81
 		return $this->wrap( 'percentage', $bars );
82 82
 	}
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	protected function buildPercentageBackground( $percent )
89 89
 	{
90
-		$backgroundPercent = glsr( Builder::class )->span([
90
+		$backgroundPercent = glsr( Builder::class )->span( [
91 91
 			'class' => 'glsr-bar-background-percent',
92 92
 			'style' => 'width:'.$percent,
93
-		]);
93
+		] );
94 94
 		return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
95 95
 	}
96 96
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function buildRating()
119 119
 	{
120
-		if( $this->isHidden( 'rating' ))return;
120
+		if( $this->isHidden( 'rating' ) )return;
121 121
 		return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' );
122 122
 	}
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function buildStars()
128 128
 	{
129
-		if( $this->isHidden( 'stars' ))return;
129
+		if( $this->isHidden( 'stars' ) )return;
130 130
 		$stars = glsr( Partial::class )->build( 'star-rating', ['rating' => $this->averageRating] );
131 131
 		return $this->wrap( 'stars', $stars );
132 132
 	}
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	protected function buildText()
138 138
 	{
139
-		if( $this->isHidden( 'summary' ))return;
140
-		$count = intval( array_sum( $this->ratingCounts ));
141
-		if( empty( $this->args['text'] )) {
139
+		if( $this->isHidden( 'summary' ) )return;
140
+		$count = intval( array_sum( $this->ratingCounts ) );
141
+		if( empty($this->args['text']) ) {
142 142
 			// @todo document this change
143 143
 			 $this->args['text'] = _nx(
144 144
 				'{rating} out of {max} stars (based on {num} review)',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			);
150 150
 		}
151 151
 		$summary = str_replace(
152
-			['{rating}','{max}', '{num}'],
152
+			['{rating}', '{max}', '{num}'],
153 153
 			[$this->averageRating, Rating::MAX_RATING, $count],
154 154
 			$this->args['text']
155 155
 		);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function generateSchema()
163 163
 	{
164
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
164
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
165 165
 		glsr( Schema::class )->store(
166 166
 			glsr( Schema::class )->buildSummary( $this->args )
167 167
 		);
@@ -193,6 +193,6 @@  discard block
 block discarded – undo
193 193
 	{
194 194
 		return glsr( Builder::class )->div( $value, [
195 195
 			'class' => 'glsr-summary-'.$key,
196
-		]);
196
+		] );
197 197
 	}
198 198
 }
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( empty( glsr()->schemas ))return;
83
+		if( empty(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 )->normalizeTermIds( $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.
plugin/Database/SqlQueries.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function deleteAllSessions( $sessionCookiePrefix )
25 25
 	{
26
-		return $this->db->query("
26
+		return $this->db->query( "
27 27
 			DELETE
28 28
 			FROM {$this->db->options}
29 29
 			WHERE option_name LIKE '{$sessionCookiePrefix}_%'
30
-		");
30
+		" );
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function deleteExpiredSessions( $expiredSessions )
38 38
 	{
39
-		return $this->db->query("
39
+		return $this->db->query( "
40 40
 			DELETE
41 41
 			FROM {$this->db->options}
42 42
 			WHERE option_name IN ('{$expiredSessions}')
43
-		");
43
+		" );
44 44
 	}
45 45
 
46 46
 	/**
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function getReviewCountsFor( $metaKey )
51 51
 	{
52
-		return (array) $this->db->get_results("
52
+		return (array)$this->db->get_results( "
53 53
 			SELECT m.meta_value AS name, COUNT(*) num_posts
54 54
 			FROM {$this->db->posts} AS p
55 55
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
56 56
 			WHERE p.post_type = '{$this->postType}'
57 57
 			AND m.meta_key = '{$metaKey}'
58 58
 			GROUP BY name
59
-		");
59
+		" );
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function getExpiredSessions( $sessionCookiePrefix, $limit )
68 68
 	{
69
-		return $this->db->get_results("
69
+		return $this->db->get_results( "
70 70
 			SELECT option_name AS name, option_value AS expiration
71 71
 			FROM {$this->db->options}
72 72
 			WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%'
73 73
 			ORDER BY option_value ASC
74 74
 			LIMIT 0, {$limit}
75
-		");
75
+		" );
76 76
 	}
77 77
 
78 78
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function getReviewCounts( $lastPostId = 0, $limit = 500 )
84 84
 	{
85
-		return $this->db->get_results("
85
+		return $this->db->get_results( "
86 86
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
87 87
 			FROM {$this->db->posts} AS p
88 88
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function getReviewPostId( $metaReviewId )
105 105
 	{
106
-		$postId = $this->db->get_var("
106
+		$postId = $this->db->get_var( "
107 107
 			SELECT p.ID
108 108
 			FROM {$this->db->posts} AS p
109 109
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
110 110
 			WHERE p.post_type = '{$this->postType}'
111 111
 			AND m.meta_key = 'review_id'
112 112
 			AND m.meta_value = '{$metaReviewId}'
113
-		");
113
+		" );
114 114
 		return intval( $postId );
115 115
 	}
116 116
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getReviewIdsByType( $reviewType )
122 122
 	{
123
-		$query = $this->db->get_col("
123
+		$query = $this->db->get_col( "
124 124
 			SELECT m1.meta_value AS review_id
125 125
 			FROM {$this->db->posts} AS p
126 126
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 			AND m1.meta_key = 'review_id'
130 130
 			AND m2.meta_key = 'review_type'
131 131
 			AND m2.meta_value = '{$reviewType}'
132
-		");
133
-		return array_keys( array_flip( $query ));
132
+		" );
133
+		return array_keys( array_flip( $query ) );
134 134
 	}
135 135
 
136 136
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function getReviewPostCounts( $postId, $lastPostId = 0, $limit = 500 )
143 143
 	{
144
-		return $this->db->get_results("
144
+		return $this->db->get_results( "
145 145
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
146 146
 			FROM {$this->db->posts} AS p
147 147
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
168 168
 	{
169 169
 		sort( $postIds );
170
-		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit );
170
+		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
171 171
 		$postIds = implode( ',', $postIds );
172
-		return $this->db->get_results("
172
+		return $this->db->get_results( "
173 173
 			SELECT p.ID, m.meta_value AS rating
174 174
 			FROM {$this->db->posts} AS p
175 175
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		$queryBuilder = glsr( QueryBuilder::class );
194 194
 		$key = $queryBuilder->buildSqlOr( $key, "m.meta_key = '%s'" );
195 195
 		$status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" );
196
-		return $this->db->get_col("
196
+		return $this->db->get_col( "
197 197
 			SELECT DISTINCT m.meta_value
198 198
 			FROM {$this->db->postmeta} m
199 199
 			LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			AND ({$key})
202 202
 			AND ({$status})
203 203
 			ORDER BY m.meta_value
204
-		");
204
+		" );
205 205
 	}
206 206
 
207 207
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function getReviewTermCounts( $termTaxonomyId, $lastPostId = 0, $limit = 500 )
214 214
 	{
215
-		return $this->db->get_results("
215
+		return $this->db->get_results( "
216 216
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
217 217
 			FROM {$this->db->posts} AS p
218 218
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
Please login to merge, or discard this patch.