@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | public function routeAdminPostRequest() |
| 17 | 17 | { |
| 18 | 18 | $request = $this->getRequest(); |
| 19 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 19 | + if( !$this->isValidPostRequest( $request )) { |
|
| 20 | + return; |
|
| 21 | + } |
|
| 20 | 22 | $this->checkAdminNonce( $request['action'] ); |
| 21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
| 22 | 24 | } |
@@ -51,9 +53,13 @@ discard block |
||
| 51 | 53 | */ |
| 52 | 54 | public function routePublicPostRequest() |
| 53 | 55 | { |
| 54 | - if( is_admin() )return; |
|
| 56 | + if( is_admin() ) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 55 | 59 | $request = $this->getRequest(); |
| 56 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 60 | + if( !$this->isValidPostRequest( $request )) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 57 | 63 | if( !wp_verify_nonce( $request['_wpnonce'], $request['action'] )) { |
| 58 | 64 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
| 59 | 65 | return; |
@@ -67,7 +73,9 @@ discard block |
||
| 67 | 73 | public function routeWebhookRequest() |
| 68 | 74 | { |
| 69 | 75 | $request = filter_input( INPUT_GET, Application::PREFIX.'hook' ); |
| 70 | - if( !$request )return; |
|
| 76 | + if( !$request ) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 71 | 79 | // @todo manage webhook here |
| 72 | 80 | } |
| 73 | 81 | |
@@ -92,7 +100,9 @@ discard block |
||
| 92 | 100 | { |
| 93 | 101 | foreach( ['request', Application::ID] as $key ) { |
| 94 | 102 | $request = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
| 95 | - if( !empty( $request ))break; |
|
| 103 | + if( !empty( $request )) { |
|
| 104 | + break; |
|
| 105 | + } |
|
| 96 | 106 | } |
| 97 | 107 | if( isset( $request[Application::ID]['action'] )) { |
| 98 | 108 | $request = $request[Application::ID]; |
@@ -193,8 +193,12 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | protected function validateAkismet() |
| 195 | 195 | { |
| 196 | - if( !empty( $this->error ))return; |
|
| 197 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 196 | + if( !empty( $this->error )) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
| 200 | + return; |
|
| 201 | + } |
|
| 198 | 202 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 199 | 203 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
| 200 | 204 | } |
@@ -204,8 +208,12 @@ discard block |
||
| 204 | 208 | */ |
| 205 | 209 | protected function validateBlacklist() |
| 206 | 210 | { |
| 207 | - if( !empty( $this->error ))return; |
|
| 208 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 211 | + if( !empty( $this->error )) { |
|
| 212 | + return; |
|
| 213 | + } |
|
| 214 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
| 215 | + return; |
|
| 216 | + } |
|
| 209 | 217 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 210 | 218 | if( $blacklistAction == 'reject' ) { |
| 211 | 219 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -220,9 +228,13 @@ discard block |
||
| 220 | 228 | */ |
| 221 | 229 | protected function validateCustom() |
| 222 | 230 | { |
| 223 | - if( !empty( $this->error ))return; |
|
| 231 | + if( !empty( $this->error )) { |
|
| 232 | + return; |
|
| 233 | + } |
|
| 224 | 234 | $validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request ); |
| 225 | - if( $validated === true )return; |
|
| 235 | + if( $validated === true ) { |
|
| 236 | + return; |
|
| 237 | + } |
|
| 226 | 238 | $this->setSessionValues( 'errors', [] ); |
| 227 | 239 | $this->setSessionValues( 'values', $this->request ); |
| 228 | 240 | $this->error = is_string( $validated ) |
@@ -235,8 +247,12 @@ discard block |
||
| 235 | 247 | */ |
| 236 | 248 | protected function validateHoneyPot() |
| 237 | 249 | { |
| 238 | - if( !empty( $this->error ))return; |
|
| 239 | - if( empty( $this->request['gotcha'] ))return; |
|
| 250 | + if( !empty( $this->error )) { |
|
| 251 | + return; |
|
| 252 | + } |
|
| 253 | + if( empty( $this->request['gotcha'] )) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 240 | 256 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 241 | 257 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 242 | 258 | } |
@@ -246,7 +262,9 @@ discard block |
||
| 246 | 262 | */ |
| 247 | 263 | protected function validateRecaptcha() |
| 248 | 264 | { |
| 249 | - if( !empty( $this->error ))return; |
|
| 265 | + if( !empty( $this->error )) { |
|
| 266 | + return; |
|
| 267 | + } |
|
| 250 | 268 | $isValid = $this->isRecaptchaResponseValid(); |
| 251 | 269 | if( is_null( $isValid )) { |
| 252 | 270 | $this->setSessionValues( 'recaptcha', true ); |