@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsSummaryShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
12 | 13 | 'stars' => __( 'Hide the stars', 'site-reviews' ), |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'title' => __( 'Hide the title', 'site-reviews' ), |
12 | 13 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsFormShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
12 | 13 | 'title' => __( 'Hide the title field', 'site-reviews' ), |
@@ -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 |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 97 | } |
94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
105 | 109 | */ |
106 | 110 | protected function customize( Builder $instance ) |
107 | 111 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
113 | + return; |
|
114 | + } |
|
109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
110 | 116 | $key = $instance->tag.'_'.$args['type']; |
111 | 117 | $classes = !isset( $this->fields[$key] ) |
@@ -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(); |