@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function validateRequest( array $request ) |
| 57 | 57 | { |
| 58 | - if( !$this->isRequestValid( $request )) { |
|
| 58 | + if( !$this->isRequestValid( $request ) ) { |
|
| 59 | 59 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
| 60 | 60 | return $request; |
| 61 | 61 | } |
| 62 | - if( empty( $request['title'] )) { |
|
| 62 | + if( empty($request['title']) ) { |
|
| 63 | 63 | $request['title'] = __( 'No Title', 'site-reviews' ); |
| 64 | 64 | } |
| 65 | 65 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | $rules = array_intersect_key( |
| 74 | 74 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ), |
| 75 | 75 | array_flip( array_merge( |
| 76 | - ['rating','terms'], |
|
| 76 | + ['rating', 'terms'], |
|
| 77 | 77 | glsr( OptionManager::class )->get( 'settings.reviews-form.required', [] ) |
| 78 | - )) |
|
| 78 | + ) ) |
|
| 79 | 79 | ); |
| 80 | - $excluded = isset( $request['excluded'] ) |
|
| 80 | + $excluded = isset($request['excluded']) |
|
| 81 | 81 | ? json_decode( $request['excluded'] ) |
| 82 | 82 | : []; |
| 83 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
| 83 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | return true; |
| 94 | 94 | } |
| 95 | 95 | $recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' ); |
| 96 | - if( empty( $recaptchaResponse ))return; //if response is empty we need to return null |
|
| 96 | + if( empty($recaptchaResponse) )return; //if response is empty we need to return null |
|
| 97 | 97 | if( $integration == 'custom' ) { |
| 98 | 98 | return $this->isRecaptchaValid( $recaptchaResponse ); |
| 99 | 99 | } |
| 100 | 100 | if( $integration == 'invisible-recaptcha' ) { |
| 101 | - return boolval( apply_filters( 'google_invre_is_valid_request_filter', true )); |
|
| 101 | + return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) ); |
|
| 102 | 102 | } |
| 103 | 103 | return false; |
| 104 | 104 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function isRecaptchaValid( $recaptchaResponse ) |
| 110 | 110 | { |
| 111 | - $endpoint = add_query_arg([ |
|
| 111 | + $endpoint = add_query_arg( [ |
|
| 112 | 112 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
| 113 | 113 | 'response' => $recaptchaResponse, |
| 114 | 114 | 'secret' => glsr( OptionManager::class )->get( 'settings.reviews-form.recaptcha.secret' ), |
| 115 | 115 | ], 'https://www.google.com/recaptcha/api/siteverify' ); |
| 116 | - $response = json_decode( wp_remote_retrieve_body( wp_remote_get( $endpoint ))); |
|
| 117 | - if( !empty( $response->success )) { |
|
| 116 | + $response = json_decode( wp_remote_retrieve_body( wp_remote_get( $endpoint ) ) ); |
|
| 117 | + if( !empty($response->success) ) { |
|
| 118 | 118 | return boolval( $response->success ); |
| 119 | 119 | } |
| 120 | 120 | $errorCodes = [ |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $rules = $this->getValidationRules( $request ); |
| 139 | 139 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
| 140 | - if( empty( $errors )) { |
|
| 140 | + if( empty($errors) ) { |
|
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | $this->setSession( 'errors', $errors ); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
| 155 | 155 | { |
| 156 | 156 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
| 157 | - if( !empty( $loggedMessage )) { |
|
| 157 | + if( !empty($loggedMessage) ) { |
|
| 158 | 158 | glsr_log()->warning( $loggedMessage ); |
| 159 | 159 | glsr_log()->warning( $this->request ); |
| 160 | 160 | } |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function validateAkismet() |
| 167 | 167 | { |
| 168 | - if( !empty( $this->error ))return; |
|
| 169 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 168 | + if( !empty($this->error) )return; |
|
| 169 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
| 170 | 170 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 171 | 171 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
| 172 | 172 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | protected function validateBlacklist() |
| 178 | 178 | { |
| 179 | - if( !empty( $this->error ))return; |
|
| 180 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 179 | + if( !empty($this->error) )return; |
|
| 180 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
| 181 | 181 | $blacklistAction = glsr( OptionManager::class )->get( 'settings.reviews-form.blacklist.action' ); |
| 182 | 182 | if( $blacklistAction == 'unapprove' ) { |
| 183 | 183 | $this->request['blacklisted'] = true; |
@@ -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/review/submission', 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( array $request ) |
| 210 | 210 | { |
| 211 | - if( !empty( $this->error ))return; |
|
| 212 | - if( empty( $request['gotcha'] ))return; |
|
| 211 | + if( !empty($this->error) )return; |
|
| 212 | + if( empty($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( array $request ) |
| 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', true ); |
| 226 | 226 | $this->recaptchaIsUnset = true; |
| 227 | 227 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->message = $this->buildHtmlMessage( $email ); |
| 44 | 44 | $this->subject = $email['subject']; |
| 45 | 45 | $this->to = $email['to']; |
| 46 | - add_action( 'phpmailer_init', [ $this, 'buildPlainTextMessage'] ); |
|
| 46 | + add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] ); |
|
| 47 | 47 | return $this; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function buildPlainTextMessage( $phpmailer ) |
| 85 | 85 | { |
| 86 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 86 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
| 87 | 87 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 88 | 88 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 89 | 89 | } |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | 'from', |
| 100 | 100 | 'reply-to', |
| 101 | 101 | ]; |
| 102 | - $headers = array_intersect_key( $email, array_flip( $allowed )); |
|
| 102 | + $headers = array_intersect_key( $email, array_flip( $allowed ) ); |
|
| 103 | 103 | $headers = array_filter( $headers ); |
| 104 | 104 | foreach( $headers as $key => $value ) { |
| 105 | - unset( $headers[ $key ] ); |
|
| 105 | + unset($headers[$key]); |
|
| 106 | 106 | $headers[] = "{$key}: {$value}"; |
| 107 | 107 | } |
| 108 | 108 | $headers[] = 'Content-Type: text/html'; |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | protected function buildHtmlMessage( $email ) |
| 116 | 116 | { |
| 117 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
| 118 | - if( !empty( $template )) { |
|
| 117 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
| 118 | + if( !empty($template) ) { |
|
| 119 | 119 | $message = glsr( Template::class )->interpolate( $template, $email['template-tags'] ); |
| 120 | 120 | } |
| 121 | 121 | else if( $email['template'] ) { |
| 122 | 122 | $message = glsr( Template::class )->build( 'templates/'.$email['template'], [ |
| 123 | 123 | 'context' => $email['template-tags'], |
| 124 | - ]); |
|
| 124 | + ] ); |
|
| 125 | 125 | } |
| 126 | - if( !isset( $message )) { |
|
| 126 | + if( !isset($message) ) { |
|
| 127 | 127 | $message = $email['message']; |
| 128 | 128 | } |
| 129 | 129 | $message = $email['before'].$message.$email['after']; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $message = str_replace( ']]>', ']]>', $message ); |
| 135 | 135 | $message = glsr( Template::class )->build( 'email/index', [ |
| 136 | 136 | 'context' => ['message' => $message], |
| 137 | - ]); |
|
| 137 | + ] ); |
|
| 138 | 138 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'to' => '', |
| 161 | 161 | ]; |
| 162 | 162 | $email = shortcode_atts( $defaults, $email ); |
| 163 | - if( empty( $email['reply-to'] )) { |
|
| 163 | + if( empty($email['reply-to']) ) { |
|
| 164 | 164 | $email['reply-to'] = $email['from']; |
| 165 | 165 | } |
| 166 | 166 | return apply_filters( 'site-reviews/email/compose', $email, $this ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | foreach( $this->rules as $attribute => $rules ) { |
| 75 | 75 | foreach( $rules as $rule ) { |
| 76 | 76 | $this->validateAttribute( $attribute, $rule ); |
| 77 | - if( $this->shouldStopValidating( $attribute ))break; |
|
| 77 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | return $this->errors; |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function validateAttribute( $attribute, $rule ) |
| 91 | 91 | { |
| 92 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
| 92 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
| 93 | 93 | if( $rule == '' )return; |
| 94 | 94 | $value = $this->getValue( $attribute ); |
| 95 | 95 | $this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules ); |
| 96 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
| 96 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
| 97 | 97 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
| 98 | 98 | } |
| 99 | - if( !$this->$method( $attribute, $value, $parameters )) { |
|
| 99 | + if( !$this->$method( $attribute, $value, $parameters ) ) { |
|
| 100 | 100 | $this->addFailure( $attribute, $rule, $parameters ); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $message = $this->getMessage( $attribute, $rule, $parameters ); |
| 113 | 113 | $this->errors[$attribute]['errors'][] = $message; |
| 114 | - if( !isset( $this->errors[$attribute]['value'] )) { |
|
| 114 | + if( !isset($this->errors[$attribute]['value']) ) { |
|
| 115 | 115 | $this->errors[$attribute]['value'] = $this->getValue( $attribute ); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function getMessage( $attribute, $rule, array $parameters ) |
| 150 | 150 | { |
| 151 | - if( in_array( $rule, $this->sizeRules )) { |
|
| 151 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
| 152 | 152 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
| 153 | 153 | } |
| 154 | 154 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | protected function getRule( $attribute, $rules ) |
| 165 | 165 | { |
| 166 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 167 | - $rules = (array) $rules; |
|
| 166 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
| 167 | + $rules = (array)$rules; |
|
| 168 | 168 | foreach( $this->rules[$attribute] as $rule ) { |
| 169 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
| 170 | - if( in_array( $rule, $rules )) { |
|
| 169 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
| 170 | + if( in_array( $rule, $rules ) ) { |
|
| 171 | 171 | return [$rule, $parameters]; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | if( is_numeric( $value ) && $hasNumeric ) { |
| 186 | 186 | return $value; |
| 187 | 187 | } |
| 188 | - elseif( is_array( $value )) { |
|
| 188 | + elseif( is_array( $value ) ) { |
|
| 189 | 189 | return count( $value ); |
| 190 | 190 | } |
| 191 | 191 | return mb_strlen( $value ); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | protected function getValue( $attribute ) |
| 214 | 214 | { |
| 215 | - if( isset( $this->data[$attribute] )) { |
|
| 215 | + if( isset($this->data[$attribute]) ) { |
|
| 216 | 216 | return $this->data[$attribute]; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | protected function hasRule( $attribute, $rules ) |
| 227 | 227 | { |
| 228 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
| 228 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | $parameters = []; |
| 266 | 266 | // example: {rule}:{parameters} |
| 267 | 267 | if( strpos( $rule, ':' ) !== false ) { |
| 268 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
| 268 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
| 269 | 269 | // example: {parameter1,parameter2,...} |
| 270 | 270 | $parameters = $this->parseParameters( $rule, $parameter ); |
| 271 | 271 | } |
| 272 | - $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ))); |
|
| 272 | + $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) ); |
|
| 273 | 273 | $rule = str_replace( ' ', '', $rule ); |
| 274 | 274 | return [$rule, $parameters]; |
| 275 | 275 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | protected function shouldStopValidating( $attribute ) |
| 298 | 298 | { |
| 299 | 299 | return $this->hasRule( $attribute, $this->implicitRules ) |
| 300 | - && isset( $this->failedRules[$attribute] ) |
|
| 300 | + && isset($this->failedRules[$attribute]) |
|
| 301 | 301 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | protected function translator( $key, $rule, $attribute, array $parameters ) |
| 312 | 312 | { |
| 313 | 313 | $strings = glsr( Strings::class )->validation(); |
| 314 | - $message = isset( $strings[$key] ) |
|
| 314 | + $message = isset($strings[$key]) |
|
| 315 | 315 | ? $strings[$key] |
| 316 | 316 | : false; |
| 317 | 317 | if( !$message )return; |
| 318 | 318 | $message = str_replace( ':attribute', $attribute, $message ); |
| 319 | - if( method_exists( $this, $replacer = 'replace'.$rule )) { |
|
| 319 | + if( method_exists( $this, $replacer = 'replace'.$rule ) ) { |
|
| 320 | 320 | $message = $this->$replacer( $message, $parameters ); |
| 321 | 321 | } |
| 322 | 322 | return $message; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'inactive-plugin' => 'Inactive Plugins', |
| 30 | 30 | 'setting' => 'Plugin Settings', |
| 31 | 31 | ]; |
| 32 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 32 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 33 | 33 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 34 | 34 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 35 | 35 | return $carry.$this->implode( $details[$key], $systemDetails ); |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $plugins = get_plugins(); |
| 48 | 48 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 49 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 50 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 49 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 50 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function getInactivePluginDetails() |
| 72 | 72 | { |
| 73 | 73 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 74 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 74 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $plugins = array_merge( |
| 83 | 83 | get_mu_plugins(), |
| 84 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 84 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 85 | 85 | ); |
| 86 | - if( empty( $plugins ))return; |
|
| 86 | + if( empty($plugins) )return; |
|
| 87 | 87 | return $this->normalizePluginList( $plugins ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getMultisitePluginDetails() |
| 94 | 94 | { |
| 95 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 95 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 96 | 96 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
| 115 | 115 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 116 | 116 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 117 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 118 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 119 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 120 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), 1 ), |
|
| 121 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), 1 ), |
|
| 117 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 118 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 119 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 120 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), 1 ), |
|
| 121 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), 1 ), |
|
| 122 | 122 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 123 | 123 | ]; |
| 124 | 124 | } |
@@ -146,13 +146,13 @@ discard block |
||
| 146 | 146 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
| 147 | 147 | $settings = $helper->flattenArray( $settings ); |
| 148 | 148 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
| 149 | - if( empty( $settings[$key] ))continue; |
|
| 149 | + if( empty($settings[$key]) )continue; |
|
| 150 | 150 | $settings[$key] = str_repeat( '*', 10 ); |
| 151 | 151 | } |
| 152 | 152 | $details = []; |
| 153 | 153 | foreach( $settings as $key => $value ) { |
| 154 | - if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 155 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 154 | + if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 155 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 156 | 156 | $details[$key] = $value; |
| 157 | 157 | } |
| 158 | 158 | return $details; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | return $host; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - return implode( ',', array_filter( [DB_HOST, $serverName] )); |
|
| 235 | + return implode( ',', array_filter( [DB_HOST, $serverName] ) ); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | $plugins = get_plugins(); |
| 255 | 255 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 256 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 257 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 256 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 257 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 258 | 258 | return $active + $inactive; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | protected function implode( $title, array $details ) |
| 266 | 266 | { |
| 267 | 267 | $strings = ['['.$title.']']; |
| 268 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 268 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 269 | 269 | $padding = max( [$padding, static::PAD] ); |
| 270 | 270 | foreach( $details as $key => $value ) { |
| 271 | 271 | $strings[] = is_string( $key ) |
@@ -294,8 +294,8 @@ discard block |
||
| 294 | 294 | { |
| 295 | 295 | $response = wp_remote_post( static::WP_API_URL ); |
| 296 | 296 | return !is_wp_error( $response ) |
| 297 | - && !empty( $response['response']['code'] ) |
|
| 298 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
| 297 | + && !empty($response['response']['code']) |
|
| 298 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
| 299 | 299 | ? 'Works' |
| 300 | 300 | : 'Does not work'; |
| 301 | 301 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $translations = $this->getSettings(); |
| 32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
| 33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
| 33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
| 34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
| 35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
| 36 | 36 | : ''; |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function entries() |
| 45 | 45 | { |
| 46 | - if( !is_array( $this->entries )) { |
|
| 46 | + if( !is_array( $this->entries ) ) { |
|
| 47 | 47 | try { |
| 48 | 48 | $entries = $this->normalize( |
| 49 | - Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ))->getEntries() |
|
| 49 | + Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ) )->getEntries() |
|
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | catch( Exception $e ) { |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
| 79 | 79 | { |
| 80 | - if( !is_array( $entries )) { |
|
| 80 | + if( !is_array( $entries ) ) { |
|
| 81 | 81 | $entries = $this->results; |
| 82 | 82 | } |
| 83 | - if( !is_array( $filterWith )) { |
|
| 83 | + if( !is_array( $filterWith ) ) { |
|
| 84 | 84 | $filterWith = $this->getSettings(); |
| 85 | 85 | } |
| 86 | - $keys = array_flip( array_column( $filterWith, 'id' )); |
|
| 86 | + $keys = array_flip( array_column( $filterWith, 'id' ) ); |
|
| 87 | 87 | $this->results = $intersect |
| 88 | 88 | ? array_intersect_key( $entries, $keys ) |
| 89 | 89 | : array_diff_key( $entries, $keys ); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | return $this->translate( $translation, $domain, [ |
| 102 | 102 | 'single' => $text, |
| 103 | - ]); |
|
| 103 | + ] ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | return $this->translate( $translation, $domain, [ |
| 116 | 116 | 'context' => $context, |
| 117 | 117 | 'single' => $text, |
| 118 | - ]); |
|
| 118 | + ] ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'number' => $number, |
| 133 | 133 | 'plural' => $plural, |
| 134 | 134 | 'single' => $single, |
| 135 | - ]); |
|
| 135 | + ] ); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'number' => $number, |
| 152 | 152 | 'plural' => $plural, |
| 153 | 153 | 'single' => $single, |
| 154 | - ]); |
|
| 154 | + ] ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | public function render( $template, array $entry ) |
| 162 | 162 | { |
| 163 | 163 | $data = array_combine( |
| 164 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
| 164 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
| 165 | 165 | $entry |
| 166 | 166 | ); |
| 167 | 167 | ob_start(); |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
| 199 | 199 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
| 200 | 200 | ]; |
| 201 | - $text = !empty( $data['p1'] ) |
|
| 201 | + $text = !empty($data['p1']) |
|
| 202 | 202 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
| 203 | 203 | : $data['s1']; |
| 204 | 204 | $rendered .= $this->render( 'result', [ |
| 205 | 205 | 'entry' => wp_json_encode( $data ), |
| 206 | 206 | 'text' => wp_strip_all_tags( $text ), |
| 207 | - ]); |
|
| 207 | + ] ); |
|
| 208 | 208 | } |
| 209 | 209 | if( $resetAfterRender ) { |
| 210 | 210 | $this->reset(); |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | public function search( $needle = '' ) |
| 238 | 238 | { |
| 239 | 239 | $this->reset(); |
| 240 | - $needle = trim( strtolower( $needle )); |
|
| 240 | + $needle = trim( strtolower( $needle ) ); |
|
| 241 | 241 | foreach( $this->entries() as $key => $entry ) { |
| 242 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
| 243 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
| 242 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
| 243 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
| 244 | 244 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
| 245 | - if( in_array( $needle, [$single, $plural] )) { |
|
| 245 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
| 246 | 246 | $this->results[$key] = $entry; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -266,19 +266,19 @@ discard block |
||
| 266 | 266 | $args = $this->normalizeTranslationArgs( $args ); |
| 267 | 267 | extract( $args ); |
| 268 | 268 | $strings = $this->getSettings(); |
| 269 | - $strings = array_filter( $strings, function( $string ) use( $single, $plural ) { |
|
| 269 | + $strings = array_filter( $strings, function( $string ) use($single, $plural) { |
|
| 270 | 270 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
| 271 | 271 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
| 272 | 272 | }); |
| 273 | - if( empty( $strings )) { |
|
| 273 | + if( empty($strings) ) { |
|
| 274 | 274 | return $original; |
| 275 | 275 | } |
| 276 | 276 | $string = current( $strings ); |
| 277 | 277 | $translations = get_translations_for_domain( $domain ); |
| 278 | - if( !empty( $string['s2'] )) { |
|
| 278 | + if( !empty($string['s2']) ) { |
|
| 279 | 279 | $single = $string['s2']; |
| 280 | 280 | } |
| 281 | - if( !empty( $string['p2'] )) { |
|
| 281 | + if( !empty($string['p2']) ) { |
|
| 282 | 282 | $plural = $string['p2']; |
| 283 | 283 | } |
| 284 | 284 | return $string['type'] == 'plural' |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | protected function getEntryString( array $entry, $key ) |
| 294 | 294 | { |
| 295 | - return isset( $entry[$key] ) |
|
| 296 | - ? implode( '', (array) $entry[$key] ) |
|
| 295 | + return isset($entry[$key]) |
|
| 296 | + ? implode( '', (array)$entry[$key] ) |
|
| 297 | 297 | : ''; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | protected function getSettings() |
| 304 | 304 | { |
| 305 | 305 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
| 306 | - return isset( $settings['strings'] ) |
|
| 307 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
| 306 | + return isset($settings['strings']) |
|
| 307 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
| 308 | 308 | : []; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $keys = [ |
| 317 | 317 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
| 318 | 318 | ]; |
| 319 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
| 319 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
| 320 | 320 | foreach( $keys as $key ) { |
| 321 | 321 | $entry = $this->normalizeEntryString( $entry, $key ); |
| 322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | protected function normalizeEntryString( array $entry, $key ) |
| 332 | 332 | { |
| 333 | - if( isset( $entry[$key] )) { |
|
| 333 | + if( isset($entry[$key]) ) { |
|
| 334 | 334 | $entry[$key] = $this->getEntryString( $entry, $key ); |
| 335 | 335 | } |
| 336 | 336 | return $entry; |
@@ -344,11 +344,11 @@ discard block |
||
| 344 | 344 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
| 345 | 345 | $strings = array_filter( $strings, 'is_array' ); |
| 346 | 346 | foreach( $strings as &$string ) { |
| 347 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
| 347 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
| 348 | 348 | $string = wp_parse_args( $string, $defaultString ); |
| 349 | 349 | } |
| 350 | 350 | return array_filter( $strings, function( $string ) { |
| 351 | - return !empty( $string['id'] ); |
|
| 351 | + return !empty($string['id']); |
|
| 352 | 352 | }); |
| 353 | 353 | } |
| 354 | 354 | |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function add( $type, $message, array $args = [] ) |
| 17 | 17 | { |
| 18 | - if( empty( array_filter( [$message, $type] )))return; |
|
| 18 | + if( empty(array_filter( [$message, $type] )) )return; |
|
| 19 | 19 | $args['message'] = $message; |
| 20 | 20 | $args['type'] = $type; |
| 21 | - add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
|
| 21 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | public function get() |
| 55 | 55 | { |
| 56 | 56 | $notices = array_map( 'unserialize', |
| 57 | - array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
|
| 57 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
| 58 | 58 | ); |
| 59 | - if( empty( $notices ))return; |
|
| 59 | + if( empty($notices) )return; |
|
| 60 | 60 | return array_reduce( $notices, function( $carry, $notice ) { |
| 61 | - return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
|
| 61 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
| 62 | 62 | }); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | return glsr( Builder::class )->div( $messages, [ |
| 81 | 81 | 'class' => $class, |
| 82 | - ]); |
|
| 82 | + ] ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | 'type' => '', |
| 95 | 95 | ]; |
| 96 | 96 | $args = shortcode_atts( $defaults, $args ); |
| 97 | - if( !in_array( $args['type'], ['error', 'warning', 'success'] )) { |
|
| 97 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
| 98 | 98 | $args['type'] = 'success'; |
| 99 | 99 | } |
| 100 | 100 | $args['messages'] = is_wp_error( $args['message'] ) |
| 101 | 101 | ? (array)$args['message']->get_error_message() |
| 102 | 102 | : (array)$args['message']; |
| 103 | - unset( $args['message'] ); |
|
| 103 | + unset($args['message']); |
|
| 104 | 104 | return $args; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | natsort( $routines ); |
| 17 | 17 | array_walk( $routines, function( $routine ) { |
| 18 | 18 | $version = str_replace( strtolower( __CLASS__ ).'_', '', $routine ); |
| 19 | - if( version_compare( glsr()->version, $version, '>=' ))return; |
|
| 19 | + if( version_compare( glsr()->version, $version, '>=' ) )return; |
|
| 20 | 20 | call_user_func( [$this, $routine] ); |
| 21 | 21 | }); |
| 22 | 22 | $this->updateVersion(); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function updateVersion() |
| 29 | 29 | { |
| 30 | 30 | $currentVersion = glsr( OptionManager::class )->get( 'version' ); |
| 31 | - if( version_compare( $currentVersion, glsr()->version, '<' )) { |
|
| 31 | + if( version_compare( $currentVersion, glsr()->version, '<' ) ) { |
|
| 32 | 32 | glsr( OptionManager::class )->set( 'version', glsr()->version ); |
| 33 | 33 | } |
| 34 | 34 | if( $currentVersion != glsr()->version ) { |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | 'style' => 'display:none!important', |
| 18 | 18 | 'tabindex' => '-1', |
| 19 | 19 | 'type' => 'text', |
| 20 | - ]); |
|
| 20 | + ] ); |
|
| 21 | 21 | $this->builder->tag = 'input'; |
| 22 | 22 | return $this->builder->getOpeningTag(); |
| 23 | 23 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | 'no' => __( 'No', 'site-reviews' ), |
| 18 | 18 | 'yes' => __( 'Yes', 'site-reviews' ), |
| 19 | 19 | ], |
| 20 | - ]); |
|
| 20 | + ] ); |
|
| 21 | 21 | $this->builder->tag = 'input'; |
| 22 | 22 | return $this->builder->buildFormInput(); |
| 23 | 23 | } |