@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | if( !empty( $sessions )) { |
151 | 151 | $now = time(); |
152 | 152 | foreach( $sessions as $session ) { |
153 | - if( $now <= $session->expiration )continue; |
|
153 | + if( $now <= $session->expiration ) { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $expiredSessions[] = $session->name; |
155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
193 | 195 | */ |
194 | 196 | protected function setCookie() |
195 | 197 | { |
196 | - if( headers_sent() )return; |
|
198 | + if( headers_sent() ) { |
|
199 | + return; |
|
200 | + } |
|
197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty( $this->types )) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | $this->review = $review; |
48 | 50 | $args = [ |
49 | 51 | 'link' => $this->getLink(), |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | protected function sendToEmail( array $args ) |
147 | 149 | { |
148 | 150 | $email = $this->buildEmail( $args ); |
149 | - if( !$this->email )return; |
|
151 | + if( !$this->email ) { |
|
152 | + return; |
|
153 | + } |
|
150 | 154 | if( empty( $email->to )) { |
151 | 155 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
161 | 165 | */ |
162 | 166 | protected function sendToSlack( array $args ) |
163 | 167 | { |
164 | - if( !$this->slack )return; |
|
168 | + if( !$this->slack ) { |
|
169 | + return; |
|
170 | + } |
|
165 | 171 | $notification = $this->buildSlackNotification( $args ); |
166 | 172 | $result = $notification->send(); |
167 | 173 | if( is_wp_error( $result )) { |
@@ -175,8 +175,12 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty( $this->error )) { |
|
179 | + return; |
|
180 | + } |
|
181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
182 | + return; |
|
183 | + } |
|
180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function validateBlacklist() |
188 | 192 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
193 | + if( !empty( $this->error )) { |
|
194 | + return; |
|
195 | + } |
|
196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 200 | if( $blacklistAction == 'reject' ) { |
193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
202 | 210 | */ |
203 | 211 | protected function validateCustom() |
204 | 212 | { |
205 | - if( !empty( $this->error ))return; |
|
213 | + if( !empty( $this->error )) { |
|
214 | + return; |
|
215 | + } |
|
206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | - if( $validated === true )return; |
|
217 | + if( $validated === true ) { |
|
218 | + return; |
|
219 | + } |
|
208 | 220 | $this->setSessionValues( 'errors', [] ); |
209 | 221 | $this->setSessionValues( 'values', $this->request ); |
210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
217 | 229 | */ |
218 | 230 | protected function validateHoneyPot() |
219 | 231 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
232 | + if( !empty( $this->error )) { |
|
233 | + return; |
|
234 | + } |
|
235 | + if( empty( $this->request['gotcha'] )) { |
|
236 | + return; |
|
237 | + } |
|
222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
228 | 244 | */ |
229 | 245 | protected function validateRecaptcha() |
230 | 246 | { |
231 | - if( !empty( $this->error ))return; |
|
247 | + if( !empty( $this->error )) { |
|
248 | + return; |
|
249 | + } |
|
232 | 250 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
252 | + return; |
|
253 | + } |
|
234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 256 | $this->recaptchaIsUnset = true; |
@@ -60,7 +60,9 @@ discard block |
||
60 | 60 | public function catchFatalError() |
61 | 61 | { |
62 | 62 | $error = error_get_last(); |
63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
64 | + return; |
|
65 | + } |
|
64 | 66 | glsr_log()->error( $error['message'] ); |
65 | 67 | } |
66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $filePaths[] = $this->path( $view ); |
112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 115 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
116 | + if( !file_exists( $file )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | return $file; |
116 | 120 | } |
117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
215 | 219 | */ |
216 | 220 | public function scheduleCronJob() |
217 | 221 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
223 | + return; |
|
224 | + } |
|
219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 226 | } |
221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
256 | 262 | || $data['action'] != 'update' |
257 | 263 | || $data['type'] != 'plugin' |
258 | - )return; |
|
264 | + ) { |
|
265 | + return; |
|
266 | + } |
|
259 | 267 | $this->upgrade(); |
260 | 268 | } |
261 | 269 |
@@ -35,7 +35,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -33,7 +33,9 @@ |
||
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 | ]); |
@@ -36,7 +36,9 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -125,7 +125,9 @@ discard block |
||
125 | 125 | $termId = intval( $termId ); |
126 | 126 | } |
127 | 127 | $term = term_exists( $termId, Application::TAXONOMY ); |
128 | - if( !isset( $term['term_id'] ))continue; |
|
128 | + if( !isset( $term['term_id'] )) { |
|
129 | + continue; |
|
130 | + } |
|
129 | 131 | $terms[] = $term; |
130 | 132 | } |
131 | 133 | return $terms; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | */ |
138 | 140 | public function revert( $postId ) |
139 | 141 | { |
140 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
142 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
143 | + return; |
|
144 | + } |
|
141 | 145 | delete_post_meta( $postId, '_edit_last' ); |
142 | 146 | $result = wp_update_post([ |
143 | 147 | 'ID' => $postId, |
@@ -182,7 +186,9 @@ discard block |
||
182 | 186 | protected function setTerms( $postId, $termIds ) |
183 | 187 | { |
184 | 188 | $termIds = $this->normalizeTermIds( $termIds ); |
185 | - if( empty( $termIds ))return; |
|
189 | + if( empty( $termIds )) { |
|
190 | + return; |
|
191 | + } |
|
186 | 192 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
187 | 193 | if( is_wp_error( $termTaxonomyIds )) { |
188 | 194 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
@@ -67,7 +67,9 @@ discard block |
||
67 | 67 | $field = method_exists( $this, $method ) |
68 | 68 | ? $this->$method( $key, $value ) |
69 | 69 | : apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review ); |
70 | - if( $field === false )continue; |
|
70 | + if( $field === false ) { |
|
71 | + continue; |
|
72 | + } |
|
71 | 73 | $renderedFields[$key] = $field; |
72 | 74 | } |
73 | 75 | $this->wrap( $renderedFields, $review ); |
@@ -95,7 +97,9 @@ discard block |
||
95 | 97 | */ |
96 | 98 | public function generateSchema() |
97 | 99 | { |
98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
100 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
101 | + return; |
|
102 | + } |
|
99 | 103 | glsr( Schema::class )->store( |
100 | 104 | glsr( Schema::class )->build( $this->args ) |
101 | 105 | ); |
@@ -121,9 +125,13 @@ discard block |
||
121 | 125 | */ |
122 | 126 | protected function buildOptionAssignedTo( $key, $value ) |
123 | 127 | { |
124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
128 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
129 | + return; |
|
130 | + } |
|
125 | 131 | $post = glsr( Polylang::class )->getPost( $value ); |
126 | - if( !( $post instanceof WP_Post ))return; |
|
132 | + if( !( $post instanceof WP_Post )) { |
|
133 | + return; |
|
134 | + } |
|
127 | 135 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
128 | 136 | 'href' => get_the_permalink( $post->ID ), |
129 | 137 | ]); |
@@ -138,7 +146,9 @@ discard block |
||
138 | 146 | */ |
139 | 147 | protected function buildOptionAuthor( $key, $value ) |
140 | 148 | { |
141 | - if( $this->isHidden( $key ))return; |
|
149 | + if( $this->isHidden( $key )) { |
|
150 | + return; |
|
151 | + } |
|
142 | 152 | return '<span>'.$value.'</span>'; |
143 | 153 | } |
144 | 154 | |
@@ -149,7 +159,9 @@ discard block |
||
149 | 159 | */ |
150 | 160 | protected function buildOptionAvatar( $key, $value ) |
151 | 161 | { |
152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
162 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
163 | + return; |
|
164 | + } |
|
153 | 165 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
154 | 166 | return glsr( Builder::class )->img([ |
155 | 167 | 'height' => $size, |
@@ -167,7 +179,9 @@ discard block |
||
167 | 179 | protected function buildOptionContent( $key, $value ) |
168 | 180 | { |
169 | 181 | $text = $this->normalizeText( $value ); |
170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
182 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
183 | + return; |
|
184 | + } |
|
171 | 185 | return '<p>'.$text.'</p>'; |
172 | 186 | } |
173 | 187 | |
@@ -178,7 +192,9 @@ discard block |
||
178 | 192 | */ |
179 | 193 | protected function buildOptionDate( $key, $value ) |
180 | 194 | { |
181 | - if( $this->isHidden( $key ))return; |
|
195 | + if( $this->isHidden( $key )) { |
|
196 | + return; |
|
197 | + } |
|
182 | 198 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
183 | 199 | if( $dateFormat == 'relative' ) { |
184 | 200 | $date = glsr( Date::class )->relative( $value ); |
@@ -199,7 +215,9 @@ discard block |
||
199 | 215 | */ |
200 | 216 | protected function buildOptionRating( $key, $value ) |
201 | 217 | { |
202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
218 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
219 | + return; |
|
220 | + } |
|
203 | 221 | return glsr_star_rating( $value ); |
204 | 222 | } |
205 | 223 | |
@@ -210,7 +228,9 @@ discard block |
||
210 | 228 | */ |
211 | 229 | protected function buildOptionResponse( $key, $value ) |
212 | 230 | { |
213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
231 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
232 | + return; |
|
233 | + } |
|
214 | 234 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
215 | 235 | $text = $this->normalizeText( $value ); |
216 | 236 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -226,7 +246,9 @@ discard block |
||
226 | 246 | */ |
227 | 247 | protected function buildOptionTitle( $key, $value ) |
228 | 248 | { |
229 | - if( $this->isHidden( $key ))return; |
|
249 | + if( $this->isHidden( $key )) { |
|
250 | + return; |
|
251 | + } |
|
230 | 252 | if( empty( $value )) { |
231 | 253 | $value = __( 'No Title', 'site-reviews' ); |
232 | 254 | } |
@@ -285,9 +307,13 @@ discard block |
||
285 | 307 | $words->setText( $text ); |
286 | 308 | $count = 0; |
287 | 309 | foreach( $words as $offset ){ |
288 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
310 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
311 | + continue; |
|
312 | + } |
|
289 | 313 | $count++; |
290 | - if( $count != $limit )continue; |
|
314 | + if( $count != $limit ) { |
|
315 | + continue; |
|
316 | + } |
|
291 | 317 | return $offset; |
292 | 318 | } |
293 | 319 | return strlen( $text ); |
@@ -363,7 +389,9 @@ discard block |
||
363 | 389 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
364 | 390 | array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
365 | 391 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
366 | - if( empty( $value ))return; |
|
392 | + if( empty( $value )) { |
|
393 | + return; |
|
394 | + } |
|
367 | 395 | $value = glsr( Builder::class )->div( $value, [ |
368 | 396 | 'class' => 'glsr-review-'.$key, |
369 | 397 | ]); |