@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | $filenames = []; |
| 21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
| 22 | 22 | foreach( $iterator as $fileinfo ) { |
| 23 | - if( !$fileinfo->isFile() )continue; |
|
| 23 | + if( !$fileinfo->isFile() ) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 24 | 26 | $filenames[] = $fileinfo->getFilename(); |
| 25 | 27 | } |
| 26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | $className = str_replace( '.php', '', $file ); |
| 29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 34 | 38 | }); |
@@ -203,7 +203,9 @@ discard block |
||
| 203 | 203 | $key = $value; |
| 204 | 204 | $value = true; |
| 205 | 205 | } |
| 206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 207 | 209 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 208 | 210 | } |
| 209 | 211 | } |
@@ -218,7 +220,9 @@ discard block |
||
| 218 | 220 | $key = $value; |
| 219 | 221 | $value = ''; |
| 220 | 222 | } |
| 221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 223 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 222 | 226 | if( is_array( $value )) { |
| 223 | 227 | $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
| 224 | 228 | } |
@@ -232,7 +236,9 @@ discard block |
||
| 232 | 236 | protected function normalizeStringAttributes() |
| 233 | 237 | { |
| 234 | 238 | foreach( $this->attributes as $key => $value ) { |
| 235 | - if( !is_string( $value ))continue; |
|
| 239 | + if( !is_string( $value )) { |
|
| 240 | + continue; |
|
| 241 | + } |
|
| 236 | 242 | $this->attributes[$key] = trim( $value ); |
| 237 | 243 | } |
| 238 | 244 | } |
@@ -243,7 +249,9 @@ discard block |
||
| 243 | 249 | */ |
| 244 | 250 | protected function normalizeInputType( $method ) |
| 245 | 251 | { |
| 246 | - if( $method != 'input' )return; |
|
| 252 | + if( $method != 'input' ) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 247 | 255 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 248 | 256 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
| 249 | 257 | $this->attributes['type'] = 'text'; |
@@ -74,9 +74,13 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->newSettings = $this->getNewSettings(); |
| 76 | 76 | $this->oldSettings = $this->getOldSettings(); |
| 77 | - if( empty( $this->oldSettings ))return; |
|
| 77 | + if( empty( $this->oldSettings )) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 78 | 80 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
| 79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
| 81 | + if( empty( $this->oldSettings[$old] )) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 80 | 84 | $this->newSettings[$new] = $this->oldSettings[$old]; |
| 81 | 85 | } |
| 82 | 86 | $this->migrateNotificationSettings(); |
@@ -136,7 +140,9 @@ discard block |
||
| 136 | 140 | ]; |
| 137 | 141 | $this->newSettings['settings.general.notifications'] = []; |
| 138 | 142 | foreach( $notifications as $old => $new ) { |
| 139 | - if( $this->oldSettings['settings.general.notification'] != $old )continue; |
|
| 143 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
| 144 | + continue; |
|
| 145 | + } |
|
| 140 | 146 | $this->newSettings['settings.general.notifications'][] = $new; |
| 141 | 147 | } |
| 142 | 148 | } |
@@ -57,9 +57,13 @@ discard block |
||
| 57 | 57 | protected function generateFields( array $fields ) |
| 58 | 58 | { |
| 59 | 59 | $generatedFields = array_map( function( $field ) { |
| 60 | - if( empty( $field ))return; |
|
| 60 | + if( empty( $field )) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 61 | 63 | $field = $this->normalize( $field ); |
| 62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 64 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 63 | 67 | return $this->$method( $field ); |
| 64 | 68 | }, $fields ); |
| 65 | 69 | return array_values( array_filter( $generatedFields )); |
@@ -74,7 +78,9 @@ discard block |
||
| 74 | 78 | if( !empty( $this->errors )) { |
| 75 | 79 | $errors = []; |
| 76 | 80 | foreach( $this->required as $name => $alert ) { |
| 77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
| 81 | + if( false !== array_search( $name, array_column( $fields, 'name' ))) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 78 | 84 | $errors[] = $this->errors[$name]; |
| 79 | 85 | } |
| 80 | 86 | $this->errors = $errors; |
@@ -118,7 +124,9 @@ discard block |
||
| 118 | 124 | */ |
| 119 | 125 | protected function normalizeContainer( array $field ) |
| 120 | 126 | { |
| 121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 127 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 122 | 130 | $field['items'] = $this->generateFields( $field['items'] ); |
| 123 | 131 | return $field; |
| 124 | 132 | } |
@@ -128,7 +136,9 @@ discard block |
||
| 128 | 136 | */ |
| 129 | 137 | protected function normalizeField( array $field, array $defaults ) |
| 130 | 138 | { |
| 131 | - if( !$this->validate( $field ))return; |
|
| 139 | + if( !$this->validate( $field )) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 132 | 142 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 133 | 143 | return $value !== ''; |
| 134 | 144 | }); |
@@ -149,7 +159,9 @@ discard block |
||
| 149 | 159 | 'type' => '', |
| 150 | 160 | 'value' => '', |
| 151 | 161 | ]); |
| 152 | - if( !is_array( $listbox ))return; |
|
| 162 | + if( !is_array( $listbox )) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 153 | 165 | if( !array_key_exists( '', $listbox['options'] )) { |
| 154 | 166 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 155 | 167 | } |
@@ -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:' ); |
| 181 | 185 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', '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; |
@@ -261,7 +261,9 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | $result = []; |
| 263 | 263 | foreach( $array as $key => $value ) { |
| 264 | - if( !$value )continue; |
|
| 264 | + if( !$value ) { |
|
| 265 | + continue; |
|
| 266 | + } |
|
| 265 | 267 | $result[$key] = is_array( $value ) |
| 266 | 268 | ? $this->removeEmptyArrayValues( $value ) |
| 267 | 269 | : $value; |
@@ -274,7 +276,8 @@ discard block |
||
| 274 | 276 | * @param string $text |
| 275 | 277 | * @return string |
| 276 | 278 | */ |
| 277 | - public function removePrefix( $prefix, $text ) { |
|
| 279 | + public function removePrefix( $prefix, $text ) |
|
| 280 | + { |
|
| 278 | 281 | return 0 === strpos( $text, $prefix ) |
| 279 | 282 | ? substr( $text, strlen( $prefix )) |
| 280 | 283 | : $text; |
@@ -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()->path( $possibleView.'.php' )))continue; |
|
| 58 | + if( !file_exists( glsr()->path( $possibleView.'.php' ))) { |
|
| 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 | |
@@ -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 | |
@@ -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 | |
@@ -244,7 +248,9 @@ discard block |
||
| 244 | 248 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 245 | 249 | || $data['action'] != 'update' |
| 246 | 250 | || $data['type'] != 'plugin' |
| 247 | - )return; |
|
| 251 | + ) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 248 | 254 | $this->upgrade(); |
| 249 | 255 | } |
| 250 | 256 | |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function enqueuePolyfillService() |
| 57 | 57 | { |
| 58 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
| 58 | + if( !apply_filters( 'site-reviews/assets/polyfill', true )) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([ |
| 60 | 62 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,MutationObserver', |
| 61 | 63 | 'flags' => 'gated', |
@@ -70,7 +72,9 @@ discard block |
||
| 70 | 72 | // wpforms-recaptcha |
| 71 | 73 | // google-recaptcha |
| 72 | 74 | // nf-google-recaptcha |
| 73 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
| 75 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
| 75 | 79 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
| 76 | 80 | 'hl' => $language, |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | public function inlineStyles() |
| 85 | 89 | { |
| 86 | 90 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
| 87 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
| 91 | + if( !apply_filters( 'site-reviews/assets/css', true )) { |
|
| 92 | + return; |
|
| 93 | + } |
|
| 88 | 94 | if( !file_exists( $inlineStylesheetPath )) { |
| 89 | 95 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
| 90 | 96 | return; |