@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | // Database/ReviewManager.php |
| 6 | 6 | add_action( 'site-reviews/review/created', function( $review ) { |
| 7 | - if( has_action( 'site-reviews/local/review/create' )) { |
|
| 7 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
| 8 | 8 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/create/review" hook instead.'; |
| 9 | 9 | do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
| 10 | 10 | } |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // Handlers/CreateReview.php |
| 14 | 14 | add_action( 'site-reviews/review/submitted', function( $review ) { |
| 15 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
| 15 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
| 16 | 16 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
| 17 | 17 | do_action( 'site-reviews/local/review/submitted', null, $review ); |
| 18 | 18 | } |
| 19 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
| 19 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
| 20 | 20 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
| 21 | 21 | } |
| 22 | 22 | }, 9 ); |
| 23 | 23 | |
| 24 | 24 | // Database/ReviewManager.php |
| 25 | 25 | add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
| 26 | - if( has_filter( 'site-reviews/local/review' )) { |
|
| 26 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
| 27 | 27 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
| 28 | 28 | return apply_filters( 'site-reviews/local/review', $values, $command ); |
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Handlers/EnqueuePublicAssets.php |
| 34 | 34 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
| 35 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
| 35 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
| 36 | 36 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
| 37 | 37 | return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Modules/Rating.php |
| 43 | 43 | add_filter( 'site-reviews/rating/average', function( $average ) { |
| 44 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
| 44 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
| 45 | 45 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
| 46 | 46 | } |
| 47 | 47 | return $average; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Modules/Rating.php |
| 51 | 51 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
| 52 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
| 52 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
| 53 | 53 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
| 54 | 54 | } |
| 55 | 55 | return $ranking; |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // Modules/Html/Partials/SiteReviews.php |
| 59 | 59 | add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
| 60 | - if( has_filter( 'site-reviews/rendered/field' )) { |
|
| 60 | + if( has_filter( 'site-reviews/rendered/field' ) ) { |
|
| 61 | 61 | glsr()->deprecated[] = 'The "site-reviews/rendered/field" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 62 | 62 | } |
| 63 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
| 63 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
| 64 | 64 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 65 | 65 | } |
| 66 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
| 66 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
| 67 | 67 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 68 | 68 | } |
| 69 | 69 | return $renderedFields; |
@@ -71,26 +71,26 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Modules/Html/Partials/SiteReviews.php |
| 73 | 73 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
| 74 | - if( has_filter( 'site-reviews/rendered/review' )) { |
|
| 74 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
| 75 | 75 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
| 76 | 76 | } |
| 77 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
| 77 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
| 78 | 78 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 79 | 79 | } |
| 80 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
| 80 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
| 81 | 81 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 82 | 82 | } |
| 83 | - if( has_filter( 'site-reviews/rendered/review-form/login-register' )) { |
|
| 83 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
| 84 | 84 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
| 85 | 85 | } |
| 86 | - if( has_filter( 'site-reviews/reviews/navigation_links' )) { |
|
| 86 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
| 87 | 87 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
| 88 | 88 | } |
| 89 | 89 | return $review; |
| 90 | 90 | }, 9 ); |
| 91 | 91 | |
| 92 | 92 | add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
| 93 | - if( has_filter( 'site-reviews/validate/review/submission' )) { |
|
| 93 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
| 94 | 94 | glsr_log()->notice( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
| 95 | 95 | try { |
| 96 | 96 | $result = apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | }, 9, 2 ); |
| 102 | 102 | |
| 103 | 103 | add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
| 104 | - if( has_filter( 'site-reviews/addon/views/file' )) { |
|
| 104 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
| 105 | 105 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
| 106 | 106 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
| 107 | 107 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | }, 9, 3 ); |
| 110 | 110 | |
| 111 | 111 | add_action( 'wp_footer', function() { |
| 112 | - $notices = array_keys( array_flip( glsr()->deprecated )); |
|
| 112 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
| 113 | 113 | natsort( $notices ); |
| 114 | 114 | foreach( $notices as $notice ) { |
| 115 | 115 | glsr_log()->notice( $notice ); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | defined( 'WPINC' ) || die; |
| 20 | 20 | |
| 21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
| 21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | 24 | if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $app = new GeminiLabs\SiteReviews\Application; |
| 31 | 31 | $app->make( 'Provider' )->register( $app ); |
| 32 | -register_activation_hook( __FILE__, array( $app, 'activate' )); |
|
| 33 | -register_deactivation_hook( __FILE__, array( $app, 'deactivate' )); |
|
| 34 | -register_shutdown_function( array( $app, 'catchFatalError' )); |
|
| 32 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
| 33 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
| 34 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
| 35 | 35 | $app->init(); |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function __get( $key ) |
| 48 | 48 | { |
| 49 | - if( property_exists( $this, $key )) { |
|
| 49 | + if( property_exists( $this, $key ) ) { |
|
| 50 | 50 | return $this->$key; |
| 51 | 51 | } |
| 52 | - if( is_array( $this->custom ) && array_key_exists( key, $this->custom )) { |
|
| 52 | + if( is_array( $this->custom ) && array_key_exists( key, $this->custom ) ) { |
|
| 53 | 53 | return $this->custom[$key]; |
| 54 | 54 | } |
| 55 | 55 | return ''; |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | 'review_type' => '', |
| 78 | 78 | ]; |
| 79 | 79 | $meta = array_filter( |
| 80 | - array_map( 'array_shift', (array)get_post_meta( $post->ID )), |
|
| 80 | + array_map( 'array_shift', (array)get_post_meta( $post->ID ) ), |
|
| 81 | 81 | 'strlen' |
| 82 | 82 | ); |
| 83 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
| 83 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
| 84 | 84 | $this->modified = $this->isModified( $properties ); |
| 85 | 85 | array_walk( $properties, function( $value, $key ) { |
| 86 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 86 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
| 87 | 87 | $this->$key = maybe_unserialize( $value ); |
| 88 | 88 | }); |
| 89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | protected function setTermIds( WP_Post $post ) |
| 95 | 95 | { |
| 96 | 96 | $this->term_ids = []; |
| 97 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 97 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
| 98 | 98 | foreach( $terms as $term ) { |
| 99 | 99 | $this->term_ids[] = $term->term_id; |
| 100 | 100 | } |
@@ -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 )return; |
|
| 63 | + if( $error['type'] !== E_ERROR ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 64 | 66 | glsr_log()->error( $error['message'] ); |
| 65 | 67 | } |
| 66 | 68 | |
@@ -204,7 +206,9 @@ discard block |
||
| 204 | 206 | */ |
| 205 | 207 | public function scheduleCronJob() |
| 206 | 208 | { |
| 207 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 209 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
| 210 | + return; |
|
| 211 | + } |
|
| 208 | 212 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 209 | 213 | } |
| 210 | 214 | |
@@ -235,7 +239,9 @@ discard block |
||
| 235 | 239 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 236 | 240 | || $data['action'] != 'update' |
| 237 | 241 | || $data['type'] != 'plugin' |
| 238 | - )return; |
|
| 242 | + ) { |
|
| 243 | + return; |
|
| 244 | + } |
|
| 239 | 245 | $this->upgrade(); |
| 240 | 246 | } |
| 241 | 247 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $this->validateBlacklist(); |
| 62 | 62 | $this->validateAkismet(); |
| 63 | 63 | $this->validateRecaptcha(); |
| 64 | - if( !empty( $this->error )) { |
|
| 64 | + if( !empty($this->error) ) { |
|
| 65 | 65 | $this->setSessionValues( 'message', $this->error ); |
| 66 | 66 | } |
| 67 | 67 | return $this; |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $rules = array_intersect_key( |
| 86 | 86 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ), |
| 87 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
| 87 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
| 88 | 88 | ); |
| 89 | - $excluded = isset( $request['excluded'] ) |
|
| 89 | + $excluded = isset($request['excluded']) |
|
| 90 | 90 | ? (array)json_decode( $request['excluded'] ) |
| 91 | 91 | : []; |
| 92 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
| 92 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | - if( empty( $this->request['recaptcha-token'] )) { |
|
| 103 | + if( empty($this->request['recaptcha-token']) ) { |
|
| 104 | 104 | return null; // @see $this->validateRecaptcha() |
| 105 | 105 | } |
| 106 | 106 | return $this->isRecaptchaValid( $this->request['recaptcha-token'] ); |
@@ -112,17 +112,17 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function isRecaptchaValid( $recaptchaToken ) |
| 114 | 114 | { |
| 115 | - $endpoint = add_query_arg([ |
|
| 115 | + $endpoint = add_query_arg( [ |
|
| 116 | 116 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
| 117 | 117 | 'response' => $recaptchaToken, |
| 118 | 118 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
| 119 | 119 | ], static::RECAPTCHA_ENDPOINT ); |
| 120 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
| 120 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
| 121 | 121 | glsr_log()->error( $response->get_error_message() ); |
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
| 125 | - if( !empty( $response->success )) { |
|
| 124 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 125 | + if( !empty($response->success) ) { |
|
| 126 | 126 | return boolval( $response->success ); |
| 127 | 127 | } |
| 128 | 128 | foreach( $response->{'error-codes'} as $error ) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $rules = $this->getValidationRules( $request ); |
| 140 | 140 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
| 141 | - if( empty( $errors )) { |
|
| 141 | + if( empty($errors) ) { |
|
| 142 | 142 | return true; |
| 143 | 143 | } |
| 144 | 144 | $this->setSessionValues( 'errors', $errors ); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
| 156 | 156 | { |
| 157 | 157 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
| 158 | - if( !empty( $loggedMessage )) { |
|
| 158 | + if( !empty($loggedMessage) ) { |
|
| 159 | 159 | glsr_log()->warning( $loggedMessage ); |
| 160 | 160 | glsr_log()->warning( $this->request ); |
| 161 | 161 | } |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function validateAkismet() |
| 168 | 168 | { |
| 169 | - if( !empty( $this->error ))return; |
|
| 170 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 169 | + if( !empty($this->error) )return; |
|
| 170 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
| 171 | 171 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 172 | 172 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
| 173 | 173 | } |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function validateBlacklist() |
| 179 | 179 | { |
| 180 | - if( !empty( $this->error ))return; |
|
| 181 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 180 | + if( !empty($this->error) )return; |
|
| 181 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
| 182 | 182 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 183 | 183 | if( $blacklistAction == 'reject' ) { |
| 184 | 184 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | protected function validateCustom() |
| 195 | 195 | { |
| 196 | - if( !empty( $this->error ))return; |
|
| 196 | + if( !empty($this->error) )return; |
|
| 197 | 197 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
| 198 | 198 | if( $validated === true )return; |
| 199 | 199 | $this->setSessionValues( 'errors', [] ); |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | protected function validateHoneyPot() |
| 210 | 210 | { |
| 211 | - if( !empty( $this->error ))return; |
|
| 212 | - if( empty( $this->request['gotcha'] ))return; |
|
| 211 | + if( !empty($this->error) )return; |
|
| 212 | + if( empty($this->request['gotcha']) )return; |
|
| 213 | 213 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 214 | 214 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 215 | 215 | } |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function validateRecaptcha() |
| 221 | 221 | { |
| 222 | - if( !empty( $this->error ))return; |
|
| 222 | + if( !empty($this->error) )return; |
|
| 223 | 223 | $isValid = $this->isRecaptchaResponseValid(); |
| 224 | - if( is_null( $isValid )) { |
|
| 224 | + if( is_null( $isValid ) ) { |
|
| 225 | 225 | $this->setSessionValues( 'recaptcha', 'unset' ); |
| 226 | 226 | $this->recaptchaIsUnset = true; |
| 227 | 227 | } |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function validateRequest( array $request ) |
| 239 | 239 | { |
| 240 | - if( !$this->isRequestValid( $request )) { |
|
| 240 | + if( !$this->isRequestValid( $request ) ) { |
|
| 241 | 241 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
| 242 | 242 | return $request; |
| 243 | 243 | } |
| 244 | - if( empty( $request['title'] )) { |
|
| 244 | + if( empty($request['title']) ) { |
|
| 245 | 245 | $request['title'] = __( 'No Title', 'site-reviews' ); |
| 246 | 246 | } |
| 247 | 247 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -166,8 +166,12 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function validateAkismet() |
| 168 | 168 | { |
| 169 | - if( !empty( $this->error ))return; |
|
| 170 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 169 | + if( !empty( $this->error )) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 172 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 171 | 175 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 172 | 176 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
| 173 | 177 | } |
@@ -177,8 +181,12 @@ discard block |
||
| 177 | 181 | */ |
| 178 | 182 | protected function validateBlacklist() |
| 179 | 183 | { |
| 180 | - if( !empty( $this->error ))return; |
|
| 181 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 184 | + if( !empty( $this->error )) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 187 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
| 188 | + return; |
|
| 189 | + } |
|
| 182 | 190 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 183 | 191 | if( $blacklistAction == 'reject' ) { |
| 184 | 192 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -193,9 +201,13 @@ discard block |
||
| 193 | 201 | */ |
| 194 | 202 | protected function validateCustom() |
| 195 | 203 | { |
| 196 | - if( !empty( $this->error ))return; |
|
| 204 | + if( !empty( $this->error )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 197 | 207 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
| 198 | - if( $validated === true )return; |
|
| 208 | + if( $validated === true ) { |
|
| 209 | + return; |
|
| 210 | + } |
|
| 199 | 211 | $this->setSessionValues( 'errors', [] ); |
| 200 | 212 | $this->setSessionValues( 'values', $this->request ); |
| 201 | 213 | $this->error = is_string( $validated ) |
@@ -208,8 +220,12 @@ discard block |
||
| 208 | 220 | */ |
| 209 | 221 | protected function validateHoneyPot() |
| 210 | 222 | { |
| 211 | - if( !empty( $this->error ))return; |
|
| 212 | - if( empty( $this->request['gotcha'] ))return; |
|
| 223 | + if( !empty( $this->error )) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 226 | + if( empty( $this->request['gotcha'] )) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 213 | 229 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 214 | 230 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 215 | 231 | } |
@@ -219,7 +235,9 @@ discard block |
||
| 219 | 235 | */ |
| 220 | 236 | protected function validateRecaptcha() |
| 221 | 237 | { |
| 222 | - if( !empty( $this->error ))return; |
|
| 238 | + if( !empty( $this->error )) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 223 | 241 | $isValid = $this->isRecaptchaResponseValid(); |
| 224 | 242 | if( is_null( $isValid )) { |
| 225 | 243 | $this->setSessionValues( 'recaptcha', 'unset' ); |