@@ -48,7 +48,9 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | public function enqueueRecaptchaScript() |
| 50 | 50 | { |
| 51 | - if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
|
| 51 | + if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' ) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
| 53 | 55 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
| 54 | 56 | 'hl' => $language, |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | [], |
| 37 | 37 | glsr()->version |
| 38 | 38 | ); |
| 39 | - if( !$this->isCurrentScreen() )return; |
|
| 39 | + if( !$this->isCurrentScreen() ) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | wp_enqueue_script( |
| 41 | 43 | Application::ID, |
| 42 | 44 | glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ), |
@@ -113,8 +115,12 @@ discard block |
||
| 113 | 115 | $dismissedPointers = explode( ',', (string)$dismissedPointers ); |
| 114 | 116 | $generatedPointers = []; |
| 115 | 117 | foreach( $pointers as $pointer ) { |
| 116 | - if( $pointer['screen'] != glsr_current_screen()->id )continue; |
|
| 117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
| 118 | + if( $pointer['screen'] != glsr_current_screen()->id ) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 121 | + if( in_array( $pointer['id'], $dismissedPointers )) { |
|
| 122 | + continue; |
|
| 123 | + } |
|
| 118 | 124 | $generatedPointers[] = $this->generatePointer( $pointer ); |
| 119 | 125 | } |
| 120 | 126 | $this->pointers = $generatedPointers; |
@@ -140,7 +146,9 @@ discard block |
||
| 140 | 146 | { |
| 141 | 147 | $variables = []; |
| 142 | 148 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
| 143 | - if( empty( $args['required'] ))continue; |
|
| 149 | + if( empty( $args['required'] )) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 144 | 152 | $variables[$tag] = $args['required']; |
| 145 | 153 | } |
| 146 | 154 | return $variables; |
@@ -15,9 +15,13 @@ |
||
| 15 | 15 | ]; |
| 16 | 16 | foreach( $namespaces as $prefix => $baseDir ) { |
| 17 | 17 | $len = strlen( $prefix ); |
| 18 | - if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
|
| 18 | + if( strncmp( $prefix, $className, $len ) !== 0 ) { |
|
| 19 | + continue; |
|
| 20 | + } |
|
| 19 | 21 | $file = $baseDir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
| 20 | - if( !file_exists( $file ))continue; |
|
| 22 | + if( !file_exists( $file )) { |
|
| 23 | + continue; |
|
| 24 | + } |
|
| 21 | 25 | require $file; |
| 22 | 26 | break; |
| 23 | 27 | } |
@@ -50,7 +50,9 @@ |
||
| 50 | 50 | public function routerSubmitReview( array $request ) |
| 51 | 51 | { |
| 52 | 52 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 53 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
| 53 | + if( !empty( $validated->error ) || $validated->recaptchaIsUnset ) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 54 | 56 | $this->execute( new CreateReview( $validated->request )); |
| 55 | 57 | } |
| 56 | 58 | } |
@@ -152,7 +152,9 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function normalizeFieldErrors( Field &$field ) |
| 154 | 154 | { |
| 155 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 155 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 156 | 158 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 157 | 159 | } |
| 158 | 160 | |
@@ -161,7 +163,9 @@ discard block |
||
| 161 | 163 | */ |
| 162 | 164 | protected function normalizeFieldRequired( Field &$field ) |
| 163 | 165 | { |
| 164 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 166 | + if( !in_array( $field->field['path'], $this->required )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 165 | 169 | $field->field['required'] = true; |
| 166 | 170 | } |
| 167 | 171 | |
@@ -183,7 +187,9 @@ discard block |
||
| 183 | 187 | */ |
| 184 | 188 | protected function normalizeFieldValue( Field &$field ) |
| 185 | 189 | { |
| 186 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 190 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
| 191 | + return; |
|
| 192 | + } |
|
| 187 | 193 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
| 188 | 194 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 189 | 195 | } |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function build() |
| 45 | 45 | { |
| 46 | - if( !$this->field['is_valid'] )return; |
|
| 46 | + if( !$this->field['is_valid'] ) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | if( $this->field['is_raw'] ) { |
| 48 | 50 | return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
| 49 | 51 | } |
@@ -143,7 +145,9 @@ discard block |
||
| 143 | 145 | */ |
| 144 | 146 | protected function getFieldErrors() |
| 145 | 147 | { |
| 146 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
| 148 | + if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] )) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 147 | 151 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
| 148 | 152 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
| 149 | 153 | }); |
@@ -170,7 +174,9 @@ discard block |
||
| 170 | 174 | 'name', 'type', |
| 171 | 175 | ]; |
| 172 | 176 | foreach( $requiredValues as $value ) { |
| 173 | - if( isset( $this->field[$value] ))continue; |
|
| 177 | + if( isset( $this->field[$value] )) { |
|
| 178 | + continue; |
|
| 179 | + } |
|
| 174 | 180 | $missingValues[] = $value; |
| 175 | 181 | $this->field['is_valid'] = false; |
| 176 | 182 | } |
@@ -187,7 +193,9 @@ discard block |
||
| 187 | 193 | */ |
| 188 | 194 | protected function normalize() |
| 189 | 195 | { |
| 190 | - if( !$this->isFieldValid() )return; |
|
| 196 | + if( !$this->isFieldValid() ) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 191 | 199 | $this->field['path'] = $this->field['name']; |
| 192 | 200 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 193 | 201 | if( class_exists( $className )) { |
@@ -205,7 +213,9 @@ discard block |
||
| 205 | 213 | */ |
| 206 | 214 | protected function normalizeFieldId() |
| 207 | 215 | { |
| 208 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
| 216 | + if( isset( $this->field['id'] ) || $this->field['is_raw'] ) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 209 | 219 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
| 210 | 220 | $this->field['path'], |
| 211 | 221 | $this->getFieldPrefix() |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | foreach( $this->rules as $attribute => $rules ) { |
| 74 | 74 | foreach( $rules as $rule ) { |
| 75 | 75 | $this->validateAttribute( $attribute, $rule ); |
| 76 | - if( $this->shouldStopValidating( $attribute ))break; |
|
| 76 | + if( $this->shouldStopValidating( $attribute )) { |
|
| 77 | + break; |
|
| 78 | + } |
|
| 77 | 79 | } |
| 78 | 80 | } |
| 79 | 81 | return $this->errors; |
@@ -89,7 +91,9 @@ discard block |
||
| 89 | 91 | public function validateAttribute( $attribute, $rule ) |
| 90 | 92 | { |
| 91 | 93 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
| 92 | - if( $rule == '' )return; |
|
| 94 | + if( $rule == '' ) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 93 | 97 | $value = $this->getValue( $attribute ); |
| 94 | 98 | if( !method_exists( $this, $method = 'validate'.$rule )) { |
| 95 | 99 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
@@ -158,7 +162,9 @@ discard block |
||
| 158 | 162 | */ |
| 159 | 163 | protected function getRule( $attribute, $rules ) |
| 160 | 164 | { |
| 161 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 165 | + if( !array_key_exists( $attribute, $this->rules )) { |
|
| 166 | + return; |
|
| 167 | + } |
|
| 162 | 168 | $rules = (array) $rules; |
| 163 | 169 | foreach( $this->rules[$attribute] as $rule ) { |
| 164 | 170 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
@@ -318,7 +324,9 @@ discard block |
||
| 318 | 324 | $message = isset( $strings[$key] ) |
| 319 | 325 | ? $strings[$key] |
| 320 | 326 | : false; |
| 321 | - if( !$message )return; |
|
| 327 | + if( !$message ) { |
|
| 328 | + return; |
|
| 329 | + } |
|
| 322 | 330 | if( method_exists( $this, $method = 'replace'.$rule )) { |
| 323 | 331 | $message = $this->$method( $message, $parameters ); |
| 324 | 332 | } |
@@ -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 ); |
@@ -35,7 +35,9 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( get_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( get_current_screen()->post_type, Application::TAXONOMY )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | glsr( Html::class )->render()->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 42 | 'class' => 'screen-reader-text', |
| 41 | 43 | 'for' => Application::TAXONOMY, |