Passed
Push — master ( e5c4f5...cb56ad )
by Paul
03:27
created
plugin/Modules/Schema.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 		foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) {
36 36
 			// Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews.
37 37
 			// @see https://developers.google.com/search/docs/data-types/review
38
-			if( $review->review_type != 'local' )continue;
38
+			if( $review->review_type != 'local' ) {
39
+				continue;
40
+			}
39 41
 			$reviews[] = $this->buildReview( $review );
40 42
 		}
41 43
 		if( !empty( $reviews )) {
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
 	 */
81 83
 	public function render()
82 84
 	{
83
-		if( empty( glsr()->schemas ))return;
85
+		if( empty( glsr()->schemas )) {
86
+			return;
87
+		}
84 88
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
85 89
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
86 90
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
@@ -132,7 +136,9 @@  discard block
 block discarded – undo
132 136
 	{
133 137
 		foreach( $values as $value ) {
134 138
 			$option = $this->getSchemaOptionValue( $value );
135
-			if( empty( $option ))continue;
139
+			if( empty( $option )) {
140
+				continue;
141
+			}
136 142
 			$schema->$value( $option );
137 143
 		}
138 144
 		return $schema;
@@ -242,7 +248,9 @@  discard block
 block discarded – undo
242 248
 		if( $value != $fallback ) {
243 249
 			return $value;
244 250
 		}
245
-		if( !is_single() && !is_page() )return;
251
+		if( !is_single() && !is_page() ) {
252
+			return;
253
+		}
246 254
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
247 255
 		if( method_exists( $this, $method )) {
248 256
 			return $this->$method();
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 1 patch
Braces   +42 added lines, -14 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 			$field = method_exists( $this, $method )
70 70
 				? $this->$method( $key, $value )
71 71
 				: apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review );
72
-			if( $field === false )continue;
72
+			if( $field === false ) {
73
+				continue;
74
+			}
73 75
 			$renderedFields[$key] = $field;
74 76
 		}
75 77
 		$this->wrap( $renderedFields, $review );
@@ -97,7 +99,9 @@  discard block
 block discarded – undo
97 99
 	 */
98 100
 	public function generateSchema()
99 101
 	{
100
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
102
+		if( !wp_validate_boolean( $this->args['schema'] )) {
103
+			return;
104
+		}
101 105
 		glsr( Schema::class )->store(
102 106
 			glsr( Schema::class )->build( $this->args )
103 107
 		);
@@ -123,9 +127,13 @@  discard block
 block discarded – undo
123 127
 	 */
124 128
 	protected function buildOptionAssignedTo( $key, $value )
125 129
 	{
126
-		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return;
130
+		if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) {
131
+			return;
132
+		}
127 133
 		$post = glsr( Polylang::class )->getPost( $value );
128
-		if( !( $post instanceof WP_Post ))return;
134
+		if( !( $post instanceof WP_Post )) {
135
+			return;
136
+		}
129 137
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
130 138
 			'href' => get_the_permalink( $post->ID ),
131 139
 		]);
@@ -140,7 +148,9 @@  discard block
 block discarded – undo
140 148
 	 */
141 149
 	protected function buildOptionAuthor( $key, $value )
142 150
 	{
143
-		if( $this->isHidden( $key ))return;
151
+		if( $this->isHidden( $key )) {
152
+			return;
153
+		}
144 154
 		return '<span>'.$value.'</span>';
145 155
 	}
146 156
 
@@ -151,7 +161,9 @@  discard block
 block discarded – undo
151 161
 	 */
152 162
 	protected function buildOptionAvatar( $key, $value )
153 163
 	{
154
-		if( $this->isHidden( $key, 'settings.reviews.avatars' ))return;
164
+		if( $this->isHidden( $key, 'settings.reviews.avatars' )) {
165
+			return;
166
+		}
155 167
 		$size = $this->getOption( 'settings.reviews.avatars_size', 40 );
156 168
 		return glsr( Builder::class )->img([
157 169
 			'height' => $size,
@@ -169,7 +181,9 @@  discard block
 block discarded – undo
169 181
 	protected function buildOptionContent( $key, $value )
170 182
 	{
171 183
 		$text = $this->normalizeText( $value );
172
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
184
+		if( $this->isHiddenOrEmpty( $key, $text )) {
185
+			return;
186
+		}
173 187
 		return '<p>'.$text.'</p>';
174 188
 	}
175 189
 
@@ -180,7 +194,9 @@  discard block
 block discarded – undo
180 194
 	 */
181 195
 	protected function buildOptionDate( $key, $value )
182 196
 	{
183
-		if( $this->isHidden( $key ))return;
197
+		if( $this->isHidden( $key )) {
198
+			return;
199
+		}
184 200
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
185 201
 		if( $dateFormat == 'relative' ) {
186 202
 			$date = glsr( Date::class )->relative( $value );
@@ -201,7 +217,9 @@  discard block
 block discarded – undo
201 217
 	 */
202 218
 	protected function buildOptionRating( $key, $value )
203 219
 	{
204
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
220
+		if( $this->isHiddenOrEmpty( $key, $value )) {
221
+			return;
222
+		}
205 223
 		return glsr( Partial::class )->build( 'star-rating', [
206 224
 			'rating' => $value,
207 225
 		]);
@@ -214,7 +232,9 @@  discard block
 block discarded – undo
214 232
 	 */
215 233
 	protected function buildOptionResponse( $key, $value )
216 234
 	{
217
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
235
+		if( $this->isHiddenOrEmpty( $key, $value )) {
236
+			return;
237
+		}
218 238
 		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
219 239
 		$text = $this->normalizeText( $value );
220 240
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
@@ -230,7 +250,9 @@  discard block
 block discarded – undo
230 250
 	 */
231 251
 	protected function buildOptionTitle( $key, $value )
232 252
 	{
233
-		if( $this->isHidden( $key ))return;
253
+		if( $this->isHidden( $key )) {
254
+			return;
255
+		}
234 256
 		if( empty( $value )) {
235 257
 			$value = __( 'No Title', 'site-reviews' );
236 258
 		}
@@ -289,9 +311,13 @@  discard block
 block discarded – undo
289 311
 		$words->setText( $text );
290 312
 		$count = 0;
291 313
 		foreach( $words as $offset ){
292
-			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue;
314
+			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) {
315
+				continue;
316
+			}
293 317
 			$count++;
294
-			if( $count != $limit )continue;
318
+			if( $count != $limit ) {
319
+				continue;
320
+			}
295 321
 			return $offset;
296 322
 		}
297 323
 		return strlen( $text );
@@ -367,7 +393,9 @@  discard block
 block discarded – undo
367 393
 		$renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review );
368 394
 		array_walk( $renderedFields, function( &$value, $key ) use( $review ) {
369 395
 			$value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review );
370
-			if( empty( $value ))return;
396
+			if( empty( $value )) {
397
+				return;
398
+			}
371 399
 			$value = glsr( Builder::class )->div( $value, [
372 400
 				'class' => 'glsr-review-'.$key,
373 401
 			]);
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewHtml.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@
 block discarded – undo
33 33
 	 */
34 34
 	public function __toString()
35 35
 	{
36
-		if( empty( $this->values ))return;
36
+		if( empty( $this->values )) {
37
+			return;
38
+		}
37 39
 		return glsr( Template::class )->build( 'templates/review', [
38 40
 			'context' => $this->values,
39 41
 		]);
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 				$termId = intval( $termId );
124 124
 			}
125 125
 			$term = term_exists( $termId, Application::TAXONOMY );
126
-			if( !isset( $term['term_id'] ))continue;
126
+			if( !isset( $term['term_id'] )) {
127
+				continue;
128
+			}
127 129
 			$terms[] = $term;
128 130
 		}
129 131
 		return $terms;
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
 	 */
136 138
 	public function revert( $postId )
137 139
 	{
138
-		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
140
+		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) {
141
+			return;
142
+		}
139 143
 		delete_post_meta( $postId, '_edit_last' );
140 144
 		$result = wp_update_post([
141 145
 			'ID' => $postId,
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
 	protected function setTerms( $postId, $termIds )
181 185
 	{
182 186
 		$terms = $this->normalizeTermIds( $termIds );
183
-		if( empty( $terms ))return;
187
+		if( empty( $terms )) {
188
+			return;
189
+		}
184 190
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
185 191
 		if( is_wp_error( $result )) {
186 192
 			glsr_log()->error( $result->get_error_message() );
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 
37 37
 	public function __construct( WP_Post $post )
38 38
 	{
39
-		if( $post->post_type != Application::POST_TYPE )return;
39
+		if( $post->post_type != Application::POST_TYPE ) {
40
+			return;
41
+		}
40 42
 		$this->content = $post->post_content;
41 43
 		$this->date = $post->post_date;
42 44
 		$this->ID = intval( $post->ID );
@@ -163,7 +165,9 @@  discard block
 block discarded – undo
163 165
 		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ));
164 166
 		$this->modified = $this->isModified( $properties );
165 167
 		array_walk( $properties, function( $value, $key ) {
166
-			if( !property_exists( $this, $key ) || isset( $this->$key ))return;
168
+			if( !property_exists( $this, $key ) || isset( $this->$key )) {
169
+				return;
170
+			}
167 171
 			$this->$key = maybe_unserialize( $value );
168 172
 		});
169 173
 	}
@@ -174,7 +178,9 @@  discard block
 block discarded – undo
174 178
 	protected function setTermIds( WP_Post $post )
175 179
 	{
176 180
 		$this->term_ids = [];
177
-		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return;
181
+		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) {
182
+			return;
183
+		}
178 184
 		foreach( $terms as $term ) {
179 185
 			$this->term_ids[] = $term->term_id;
180 186
 		}
Please login to merge, or discard this patch.
helpers.php 1 patch
Braces   +28 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 		'glsr_get_review', 'glsr_get_reviews',
20 20
 		'glsr_log',
21 21
 	);
22
-	if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
22
+	if( !in_array( $hook, $hooks ) || !function_exists( $hook )) {
23
+		return;
24
+	}
23 25
 	add_filter( $hook, function() use( $hook, $args ) {
24 26
 		array_shift( $args ); // remove the fallback value
25 27
 		return call_user_func_array( $hook, $args );
@@ -29,7 +31,8 @@  discard block
 block discarded – undo
29 31
 /**
30 32
  * @return mixed
31 33
  */
32
-function glsr( $alias = null ) {
34
+function glsr( $alias = null )
35
+{
33 36
 	$app = \GeminiLabs\SiteReviews\Application::load();
34 37
 	return !empty( $alias )
35 38
 		? $app->make( $alias )
@@ -41,11 +44,14 @@  discard block
 block discarded – undo
41 44
  * @param $column string
42 45
  * @return array
43 46
  */
44
-function glsr_array_column( array $array, $column ) {
47
+function glsr_array_column( array $array, $column )
48
+{
45 49
 	$result = array();
46 50
 	foreach( $array as $subarray ) {
47 51
 		$subarray = (array)$subarray;
48
-		if( !isset( $subarray[$column] ))continue;
52
+		if( !isset( $subarray[$column] )) {
53
+			continue;
54
+		}
49 55
 		$result[] = $subarray[$column];
50 56
 	}
51 57
 	return $result;
@@ -54,7 +60,8 @@  discard block
 block discarded – undo
54 60
 /**
55 61
  * @return void
56 62
  */
57
-function glsr_calculate_ratings() {
63
+function glsr_calculate_ratings()
64
+{
58 65
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
59 66
 	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ));
60 67
 }
@@ -62,7 +69,8 @@  discard block
 block discarded – undo
62 69
 /**
63 70
  * @return \GeminiLabs\SiteReviews\Review|false
64 71
  */
65
-function glsr_create_review( $reviewValues = array() ) {
72
+function glsr_create_review( $reviewValues = array() )
73
+{
66 74
 	if( !is_array( $reviewValues )) {
67 75
 		$reviewValues = array();
68 76
 	}
@@ -73,7 +81,8 @@  discard block
 block discarded – undo
73 81
 /**
74 82
  * @return \WP_Screen|object
75 83
  */
76
-function glsr_current_screen() {
84
+function glsr_current_screen()
85
+{
77 86
 	if( function_exists( 'get_current_screen' )) {
78 87
 		$screen = get_current_screen();
79 88
 	}
@@ -86,7 +95,8 @@  discard block
 block discarded – undo
86 95
  * @param mixed ...$vars
87 96
  * @return void
88 97
  */
89
-function glsr_debug( ...$vars ) {
98
+function glsr_debug( ...$vars )
99
+{
90 100
 	if( count( $vars ) == 1 ) {
91 101
 		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
92 102
 		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
@@ -105,7 +115,8 @@  discard block
 block discarded – undo
105 115
  * @param mixed $fallback
106 116
  * @return string|array
107 117
  */
108
-function glsr_get_option( $path = '', $fallback = '' ) {
118
+function glsr_get_option( $path = '', $fallback = '' )
119
+{
109 120
 	return is_string( $path )
110 121
 		? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback )
111 122
 		: $fallback;
@@ -114,7 +125,8 @@  discard block
 block discarded – undo
114 125
 /**
115 126
  * @return array
116 127
  */
117
-function glsr_get_options() {
128
+function glsr_get_options()
129
+{
118 130
 	return glsr( 'Database\OptionManager' )->get( 'settings' );
119 131
 }
120 132
 
@@ -122,7 +134,8 @@  discard block
 block discarded – undo
122 134
  * @param int $post_id
123 135
  * @return \GeminiLabs\SiteReviews\Review
124 136
  */
125
-function glsr_get_review( $post_id ) {
137
+function glsr_get_review( $post_id )
138
+{
126 139
 	$post = null;
127 140
 	if( is_numeric( $post_id )) {
128 141
 		$post = get_post( $post_id );
@@ -136,7 +149,8 @@  discard block
 block discarded – undo
136 149
 /**
137 150
  * @return array
138 151
  */
139
-function glsr_get_reviews( $args = array() ) {
152
+function glsr_get_reviews( $args = array() )
153
+{
140 154
 	if( !is_array( $args )) {
141 155
 		$args = [];
142 156
 	}
@@ -146,7 +160,8 @@  discard block
 block discarded – undo
146 160
 /**
147 161
  * @return \GeminiLabs\SiteReviews\Modules\Console
148 162
  */
149
-function glsr_log() {
163
+function glsr_log()
164
+{
150 165
 	$args = func_get_args();
151 166
 	$context = isset( $args[1] )
152 167
 		? $args[1]
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@  discard block
 block discarded – undo
58 58
 		$columns = glsr( Helper::class )->consolidateArray( $columns );
59 59
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
60 60
 		foreach( $postTypeColumns as $key => &$value ) {
61
-			if( !array_key_exists( $key, $columns ) || !empty( $value ))continue;
61
+			if( !array_key_exists( $key, $columns ) || !empty( $value )) {
62
+				continue;
63
+			}
62 64
 			$value = $columns[$key];
63 65
 		}
64 66
 		if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) {
@@ -99,7 +101,8 @@  discard block
 block discarded – undo
99 101
 	 * @return array
100 102
 	 * @filter display_post_states
101 103
 	 */
102
-	public function filterPostStates( $postStates, WP_Post $post ) {
104
+	public function filterPostStates( $postStates, WP_Post $post )
105
+	{
103 106
 		$postStates = glsr( Helper::class )->consolidateArray( $postStates );
104 107
 		if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) {
105 108
 			$postStates['pending'] = __( 'Unapproved', 'site-reviews' );
@@ -147,7 +150,9 @@  discard block
 block discarded – undo
147 150
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
148 151
 		unset( $postTypeColumns['cb'] );
149 152
 		foreach( $postTypeColumns as $key => $value ) {
150
-			if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue;
153
+			if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) {
154
+				continue;
155
+			}
151 156
 			$columns[$key] = $key;
152 157
 		}
153 158
 		return $columns;
@@ -171,7 +176,9 @@  discard block
 block discarded – undo
171 176
 				'Pending' => __( 'Unapproved', 'site-reviews' ),
172 177
 			];
173 178
 			foreach( $strings as $search => $replace ) {
174
-				if( strpos( $single, $search ) === false )continue;
179
+				if( strpos( $single, $search ) === false ) {
180
+					continue;
181
+				}
175 182
 				$translation = $this->getTranslation([
176 183
 					'number' => $number,
177 184
 					'plural' => str_replace( $search, $replace, $plural ),
@@ -223,7 +230,9 @@  discard block
 block discarded – undo
223 230
 	 */
224 231
 	public function saveBulkEditFields( $postId )
225 232
 	{
226
-		if( !current_user_can( 'edit_posts' ))return;
233
+		if( !current_user_can( 'edit_posts' )) {
234
+			return;
235
+		}
227 236
 		$assignedTo = filter_input( INPUT_GET, 'assigned_to' );
228 237
 		if( $assignedTo && get_post( $assignedTo )) {
229 238
 			update_post_meta( $postId, 'assigned_to', $assignedTo );
@@ -236,7 +245,9 @@  discard block
 block discarded – undo
236 245
 	 */
237 246
 	public function setQueryForColumn( WP_Query $query )
238 247
 	{
239
-		if( !$this->hasPermission( $query ))return;
248
+		if( !$this->hasPermission( $query )) {
249
+			return;
250
+		}
240 251
 		$this->setMetaQuery( $query, [
241 252
 			'rating', 'review_type',
242 253
 		]);
@@ -308,7 +319,9 @@  discard block
 block discarded – undo
308 319
 	protected function setMetaQuery( WP_Query $query, array $metaKeys )
309 320
 	{
310 321
 		foreach( $metaKeys as $key ) {
311
-			if( !( $value = filter_input( INPUT_GET, $key )))continue;
322
+			if( !( $value = filter_input( INPUT_GET, $key ))) {
323
+				continue;
324
+			}
312 325
 			$metaQuery = (array)$query->get( 'meta_query' );
313 326
 			$metaQuery[] = [
314 327
 				'key' => $key,
Please login to merge, or discard this patch.