@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | * @param string $path |
18 | 18 | * @return string |
19 | 19 | */ |
20 | - public function buildClassName($name, $path = '') |
|
20 | + public function buildClassName( $name, $path = '' ) |
|
21 | 21 | { |
22 | - $className = $this->camelCase($name); |
|
23 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
22 | + $className = $this->camelCase( $name ); |
|
23 | + $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
|
24 | 24 | return !empty($path) |
25 | 25 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
26 | 26 | : $className; |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | * @param string $prefix |
32 | 32 | * @return string |
33 | 33 | */ |
34 | - public function buildMethodName($name, $prefix = '') |
|
34 | + public function buildMethodName( $name, $prefix = '' ) |
|
35 | 35 | { |
36 | - return lcfirst($prefix.$this->buildClassName($name)); |
|
36 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @param string $name |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function buildPropertyName($name) |
|
43 | + public function buildPropertyName( $name ) |
|
44 | 44 | { |
45 | - return lcfirst($this->buildClassName($name)); |
|
45 | + return lcfirst( $this->buildClassName( $name ) ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -50,27 +50,27 @@ discard block |
||
50 | 50 | * @param mixed $value |
51 | 51 | * @return mixed |
52 | 52 | */ |
53 | - public function castTo($cast = '', $value) |
|
53 | + public function castTo( $cast = '', $value ) |
|
54 | 54 | { |
55 | - switch ($cast) { |
|
55 | + switch( $cast ) { |
|
56 | 56 | case 'array': |
57 | - return (array) $value; |
|
57 | + return (array)$value; |
|
58 | 58 | case 'boolean': |
59 | - return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
59 | + return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); |
|
60 | 60 | case 'float': |
61 | - return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
61 | + return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND ); |
|
62 | 62 | case 'integer': |
63 | - return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
63 | + return (int)filter_var( $value, FILTER_VALIDATE_INT ); |
|
64 | 64 | case 'object': |
65 | - return (object) (array) $value; |
|
65 | + return (object)(array)$value; |
|
66 | 66 | case 'string': |
67 | - if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
68 | - return (string) $value->__toString(); |
|
67 | + if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) { |
|
68 | + return (string)$value->__toString(); |
|
69 | 69 | } |
70 | - if (is_array($value) || is_object($value)) { |
|
71 | - return serialize($value); |
|
70 | + if( is_array( $value ) || is_object( $value ) ) { |
|
71 | + return serialize( $value ); |
|
72 | 72 | } |
73 | - return (string) $value; |
|
73 | + return (string)$value; |
|
74 | 74 | default: |
75 | 75 | return $value; |
76 | 76 | } |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | * @param string $key |
81 | 81 | * @return mixed |
82 | 82 | */ |
83 | - public function filterInput($key, array $request = []) |
|
83 | + public function filterInput( $key, array $request = [] ) |
|
84 | 84 | { |
85 | - if (isset($request[$key])) { |
|
85 | + if( isset($request[$key]) ) { |
|
86 | 86 | return $request[$key]; |
87 | 87 | } |
88 | - $variable = filter_input(INPUT_POST, $key); |
|
89 | - if (is_null($variable) && isset($_POST[$key])) { |
|
88 | + $variable = filter_input( INPUT_POST, $key ); |
|
89 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
90 | 90 | $variable = $_POST[$key]; |
91 | 91 | } |
92 | 92 | return $variable; |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | * @param string $key |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function filterInputArray($key) |
|
99 | + public function filterInputArray( $key ) |
|
100 | 100 | { |
101 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
102 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
101 | + $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
102 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
103 | 103 | $variable = $_POST[$key]; |
104 | 104 | } |
105 | - return (array) $variable; |
|
105 | + return (array)$variable; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getIpAddress() |
112 | 112 | { |
113 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
114 | - $ipv6 = defined('AF_INET6') |
|
113 | + $cloudflareIps = glsr( Cache::class )->getCloudflareIps(); |
|
114 | + $ipv6 = defined( 'AF_INET6' ) |
|
115 | 115 | ? $cloudflareIps['v6'] |
116 | 116 | : []; |
117 | - $whitelist = apply_filters('site-reviews/whip/whitelist', [ |
|
117 | + $whitelist = apply_filters( 'site-reviews/whip/whitelist', [ |
|
118 | 118 | Whip::CLOUDFLARE_HEADERS => [ |
119 | 119 | Whip::IPV4 => $cloudflareIps['v4'], |
120 | 120 | Whip::IPV6 => $ipv6, |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | Whip::IPV4 => ['127.0.0.1'], |
124 | 124 | Whip::IPV6 => ['::1'], |
125 | 125 | ], |
126 | - ]); |
|
126 | + ] ); |
|
127 | 127 | $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
128 | - $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
129 | - $whip = new Whip($methods, $whitelist); |
|
130 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
131 | - return (string) $whip->getValidIpAddress(); |
|
128 | + $methods = apply_filters( 'site-reviews/whip/methods', $methods ); |
|
129 | + $whip = new Whip( $methods, $whitelist ); |
|
130 | + do_action_ref_array( 'site-reviews/whip', [$whip] ); |
|
131 | + return (string)$whip->getValidIpAddress(); |
|
132 | 132 | } |
133 | 133 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $this->migrateSettings(); |
15 | 15 | $this->protectMetaKeys(); |
16 | 16 | $this->deleteSessions(); |
17 | - delete_transient(Application::ID.'_cloudflare_ips'); |
|
17 | + delete_transient( Application::ID.'_cloudflare_ips' ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | public function deleteSessions() |
24 | 24 | { |
25 | 25 | global $wpdb; |
26 | - $wpdb->query(" |
|
26 | + $wpdb->query( " |
|
27 | 27 | DELETE |
28 | 28 | FROM {$wpdb->options} |
29 | 29 | WHERE option_name LIKE '_glsr_session%' |
30 | - "); |
|
30 | + " ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function migrateSettings() |
37 | 37 | { |
38 | - if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
39 | - $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang') |
|
38 | + if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) { |
|
39 | + $multilingual = 'yes' == glsr( Helper::class )->dataGet( $settings, 'settings.general.support.polylang' ) |
|
40 | 40 | ? 'polylang' |
41 | 41 | : ''; |
42 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual); |
|
43 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', ''); |
|
44 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', ''); |
|
45 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
46 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
47 | - $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
42 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.general.multilingual', $multilingual ); |
|
43 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.blacklist.integration', '' ); |
|
44 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit', '' ); |
|
45 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.email', '' ); |
|
46 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.ip_address', '' ); |
|
47 | + $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.limit_whitelist.username', '' ); |
|
48 | 48 | unset($settings['settings']['general']['support']); |
49 | - update_option(OptionManager::databaseKey(4), $settings); |
|
49 | + update_option( OptionManager::databaseKey( 4 ), $settings ); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | public function protectMetaKeys() |
57 | 57 | { |
58 | 58 | global $wpdb; |
59 | - $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
60 | - $keys = implode("','", $keys); |
|
59 | + $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() ); |
|
60 | + $keys = implode( "','", $keys ); |
|
61 | 61 | $postType = Application::POST_TYPE; |
62 | - $wpdb->query(" |
|
62 | + $wpdb->query( " |
|
63 | 63 | UPDATE {$wpdb->postmeta} pm |
64 | 64 | INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id |
65 | 65 | SET pm.meta_key = CONCAT('_', pm.meta_key) |
66 | 66 | WHERE pm.meta_key IN ('{$keys}') |
67 | 67 | AND p.post_type = '{$postType}' |
68 | - "); |
|
68 | + " ); |
|
69 | 69 | } |
70 | 70 | } |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @return static |
59 | 59 | */ |
60 | - public function validate(array $request) |
|
60 | + public function validate( array $request ) |
|
61 | 61 | { |
62 | 62 | $this->form_id = $request['form_id']; |
63 | - $this->options = glsr(OptionManager::class)->all(); |
|
64 | - $this->request = $this->validateRequest($request); |
|
63 | + $this->options = glsr( OptionManager::class )->all(); |
|
64 | + $this->request = $this->validateRequest( $request ); |
|
65 | 65 | $this->validateCustom(); |
66 | 66 | $this->validateHoneyPot(); |
67 | 67 | $this->validateReviewLimits(); |
68 | 68 | $this->validateBlacklist(); |
69 | 69 | $this->validateAkismet(); |
70 | 70 | $this->validateRecaptcha(); |
71 | - if (!empty($this->error)) { |
|
72 | - $this->setSessionValues('message', $this->error); |
|
71 | + if( !empty($this->error) ) { |
|
72 | + $this->setSessionValues( 'message', $this->error ); |
|
73 | 73 | } |
74 | 74 | return $this; |
75 | 75 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param mixed $fallback |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - protected function getOption($path, $fallback = '') |
|
82 | + protected function getOption( $path, $fallback = '' ) |
|
83 | 83 | { |
84 | - return glsr(Helper::class)->dataGet($this->options, $path, $fallback); |
|
84 | + return glsr( Helper::class )->dataGet( $this->options, $path, $fallback ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function getRecaptchaStatus() |
91 | 91 | { |
92 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
92 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
93 | 93 | return static::RECAPTCHA_DISABLED; |
94 | 94 | } |
95 | - if (empty($this->request['_recaptcha-token'])) { |
|
96 | - return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5)) |
|
95 | + if( empty($this->request['_recaptcha-token']) ) { |
|
96 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
97 | 97 | ? static::RECAPTCHA_EMPTY |
98 | 98 | : static::RECAPTCHA_FAILED; |
99 | 99 | } |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function getRecaptchaTokenStatus() |
107 | 107 | { |
108 | - $endpoint = add_query_arg([ |
|
109 | - 'remoteip' => glsr(Helper::class)->getIpAddress(), |
|
108 | + $endpoint = add_query_arg( [ |
|
109 | + 'remoteip' => glsr( Helper::class )->getIpAddress(), |
|
110 | 110 | 'response' => $this->request['_recaptcha-token'], |
111 | - 'secret' => $this->getOption('settings.submissions.recaptcha.secret'), |
|
112 | - ], static::RECAPTCHA_ENDPOINT); |
|
113 | - if (is_wp_error($response = wp_remote_get($endpoint))) { |
|
114 | - glsr_log()->error($response->get_error_message()); |
|
111 | + 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
|
112 | + ], static::RECAPTCHA_ENDPOINT ); |
|
113 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
114 | + glsr_log()->error( $response->get_error_message() ); |
|
115 | 115 | return static::RECAPTCHA_FAILED; |
116 | 116 | } |
117 | - $response = json_decode(wp_remote_retrieve_body($response)); |
|
118 | - if (!empty($response->success)) { |
|
119 | - return boolval($response->success) |
|
117 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
118 | + if( !empty($response->success) ) { |
|
119 | + return boolval( $response->success ) |
|
120 | 120 | ? static::RECAPTCHA_VALID |
121 | 121 | : static::RECAPTCHA_INVALID; |
122 | 122 | } |
123 | - foreach ($response->{'error-codes'} as $error) { |
|
124 | - glsr_log()->error('reCAPTCHA error: '.$error); |
|
123 | + foreach( $response->{'error-codes'} as $error ) { |
|
124 | + glsr_log()->error( 'reCAPTCHA error: '.$error ); |
|
125 | 125 | } |
126 | 126 | return static::RECAPTCHA_INVALID; |
127 | 127 | } |
@@ -129,34 +129,34 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - protected function getValidationRules(array $request) |
|
132 | + protected function getValidationRules( array $request ) |
|
133 | 133 | { |
134 | 134 | $rules = array_intersect_key( |
135 | - apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request), |
|
136 | - array_flip($this->getOption('settings.submissions.required', [])) |
|
135 | + apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
|
136 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
137 | 137 | ); |
138 | - $excluded = explode(',', glsr_get($request, 'excluded')); |
|
139 | - return array_diff_key($rules, array_flip($excluded)); |
|
138 | + $excluded = explode( ',', glsr_get( $request, 'excluded' ) ); |
|
139 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | 143 | * @return bool |
144 | 144 | */ |
145 | - protected function isRequestValid(array $request) |
|
145 | + protected function isRequestValid( array $request ) |
|
146 | 146 | { |
147 | - $rules = $this->getValidationRules($request); |
|
148 | - $errors = glsr(Validator::class)->validate($request, $rules); |
|
149 | - if (empty($errors)) { |
|
147 | + $rules = $this->getValidationRules( $request ); |
|
148 | + $errors = glsr( Validator::class )->validate( $request, $rules ); |
|
149 | + if( empty($errors) ) { |
|
150 | 150 | return true; |
151 | 151 | } |
152 | - $this->setSessionValues('errors', $errors); |
|
153 | - $this->setSessionValues('values', $request); |
|
152 | + $this->setSessionValues( 'errors', $errors ); |
|
153 | + $this->setSessionValues( 'values', $request ); |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | |
157 | - protected function setError($message, $loggedMessage = '') |
|
157 | + protected function setError( $message, $loggedMessage = '' ) |
|
158 | 158 | { |
159 | - $this->setSessionValues('errors', [], $loggedMessage); |
|
159 | + $this->setSessionValues( 'errors', [], $loggedMessage ); |
|
160 | 160 | $this->error = $message; |
161 | 161 | } |
162 | 162 | |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param string $loggedMessage |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - protected function setSessionValues($type, $value, $loggedMessage = '') |
|
169 | + protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
|
170 | 170 | { |
171 | - glsr()->sessionSet($this->form_id.$type, $value); |
|
172 | - if (!empty($loggedMessage)) { |
|
173 | - glsr_log()->warning($loggedMessage)->debug($this->request); |
|
171 | + glsr()->sessionSet( $this->form_id.$type, $value ); |
|
172 | + if( !empty($loggedMessage) ) { |
|
173 | + glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function validateAkismet() |
181 | 181 | { |
182 | - if (!empty($this->error)) { |
|
182 | + if( !empty($this->error) ) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | - if (!glsr(Akismet::class)->isSpam($this->request)) { |
|
185 | + if( !glsr( Akismet::class )->isSpam( $this->request ) ) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | - $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'), |
|
188 | + $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ), |
|
189 | 189 | 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' |
190 | 190 | ); |
191 | 191 | } |
@@ -195,18 +195,18 @@ discard block |
||
195 | 195 | */ |
196 | 196 | protected function validateBlacklist() |
197 | 197 | { |
198 | - if (!empty($this->error)) { |
|
198 | + if( !empty($this->error) ) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | - if (!glsr(Blacklist::class)->isBlacklisted($this->request)) { |
|
201 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | - $blacklistAction = $this->getOption('settings.submissions.blacklist.action'); |
|
205 | - if ('reject' != $blacklistAction) { |
|
204 | + $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
|
205 | + if( 'reject' != $blacklistAction ) { |
|
206 | 206 | $this->request['blacklisted'] = true; |
207 | 207 | return; |
208 | 208 | } |
209 | - $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'), |
|
209 | + $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ), |
|
210 | 210 | 'Blacklisted submission detected:' |
211 | 211 | ); |
212 | 212 | } |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function validateCustom() |
218 | 218 | { |
219 | - if (!empty($this->error)) { |
|
219 | + if( !empty($this->error) ) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | - $validated = apply_filters('site-reviews/validate/custom', true, $this->request); |
|
223 | - if (true === $validated) { |
|
222 | + $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
|
223 | + if( true === $validated ) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | - $errorMessage = is_string($validated) |
|
226 | + $errorMessage = is_string( $validated ) |
|
227 | 227 | ? $validated |
228 | - : __('The review submission failed. Please notify the site administrator.', 'site-reviews'); |
|
229 | - $this->setError($errorMessage); |
|
230 | - $this->setSessionValues('values', $this->request); |
|
228 | + : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
|
229 | + $this->setError( $errorMessage ); |
|
230 | + $this->setSessionValues( 'values', $this->request ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function validateHoneyPot() |
237 | 237 | { |
238 | - if (!empty($this->error)) { |
|
238 | + if( !empty($this->error) ) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | - if (empty($this->request['gotcha'])) { |
|
241 | + if( empty($this->request['gotcha']) ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | - $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'), |
|
244 | + $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ), |
|
245 | 245 | 'The Honeypot caught a bad submission:' |
246 | 246 | ); |
247 | 247 | } |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | */ |
252 | 252 | protected function validateReviewLimits() |
253 | 253 | { |
254 | - if (!empty($this->error)) { |
|
254 | + if( !empty($this->error) ) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | - if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) { |
|
257 | + if( !glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) { |
|
258 | 258 | return; |
259 | 259 | } |
260 | - $this->setError(__('You have already submitted a review.', 'site-reviews')); |
|
260 | + $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) ); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -265,35 +265,35 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function validateRecaptcha() |
267 | 267 | { |
268 | - if (!empty($this->error)) { |
|
268 | + if( !empty($this->error) ) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | $status = $this->getRecaptchaStatus(); |
272 | - if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) { |
|
272 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | - if (static::RECAPTCHA_EMPTY === $status) { |
|
276 | - $this->setSessionValues('recaptcha', 'unset'); |
|
275 | + if( static::RECAPTCHA_EMPTY === $status ) { |
|
276 | + $this->setSessionValues( 'recaptcha', 'unset' ); |
|
277 | 277 | $this->recaptchaIsUnset = true; |
278 | 278 | return; |
279 | 279 | } |
280 | - $this->setSessionValues('recaptcha', 'reset'); |
|
280 | + $this->setSessionValues( 'recaptcha', 'reset' ); |
|
281 | 281 | $errors = [ |
282 | - static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'), |
|
283 | - static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'), |
|
282 | + static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ), |
|
283 | + static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ), |
|
284 | 284 | ]; |
285 | - $this->setError($errors[$status]); |
|
285 | + $this->setError( $errors[$status] ); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function validateRequest(array $request) |
|
291 | + protected function validateRequest( array $request ) |
|
292 | 292 | { |
293 | - if (!$this->isRequestValid($request)) { |
|
294 | - $this->error = __('Please fix the submission errors.', 'site-reviews'); |
|
293 | + if( !$this->isRequestValid( $request ) ) { |
|
294 | + $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
|
295 | 295 | return $request; |
296 | 296 | } |
297 | - return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request); |
|
297 | + return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
|
298 | 298 | } |
299 | 299 | } |
@@ -13,26 +13,26 @@ discard block |
||
13 | 13 | * @return array |
14 | 14 | * @filter site-reviews/get/reviews/query |
15 | 15 | */ |
16 | - public function filterReviewsQuery(array $parameters, array $args) |
|
16 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
17 | 17 | { |
18 | - if ($authorId = get_current_user_id()) { |
|
18 | + if( $authorId = get_current_user_id() ) { |
|
19 | 19 | $parameters['author'] = $authorId; |
20 | 20 | } |
21 | 21 | $parameters['post_status'] = ['pending', 'publish']; |
22 | - return apply_filters('site-reviews/reviews-limits/query', $parameters, $args); |
|
22 | + return apply_filters( 'site-reviews/reviews-limits/query', $parameters, $args ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @return bool |
27 | 27 | */ |
28 | - public function hasReachedLimit(array $request = []) |
|
28 | + public function hasReachedLimit( array $request = [] ) |
|
29 | 29 | { |
30 | 30 | $this->request = $request; |
31 | - $method = glsr(Helper::class)->buildMethodName( |
|
32 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
31 | + $method = glsr( Helper::class )->buildMethodName( |
|
32 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
33 | 33 | ); |
34 | - return method_exists($this, $method) |
|
35 | - ? !call_user_func([$this, $method]) |
|
34 | + return method_exists( $this, $method ) |
|
35 | + ? !call_user_func( [$this, $method] ) |
|
36 | 36 | : false; |
37 | 37 | } |
38 | 38 | |
@@ -41,39 +41,39 @@ discard block |
||
41 | 41 | * @param string $whitelist |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function isWhitelisted($value, $whitelist) |
|
44 | + public function isWhitelisted( $value, $whitelist ) |
|
45 | 45 | { |
46 | - if (empty($whitelist)) { |
|
46 | + if( empty($whitelist) ) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
49 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param string $whitelistName |
54 | 54 | * @return string |
55 | 55 | */ |
56 | - protected function getWhitelist($whitelistName) |
|
56 | + protected function getWhitelist( $whitelistName ) |
|
57 | 57 | { |
58 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
58 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - protected function validate($key, $value, $addMetaQuery = true) |
|
64 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
65 | 65 | { |
66 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
66 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
67 | 67 | return true; |
68 | 68 | } |
69 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
70 | - $args = ['assigned_to' => glsr_get($this->request, 'assign_to')]; |
|
71 | - if ($addMetaQuery) { |
|
69 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
70 | + $args = ['assigned_to' => glsr_get( $this->request, 'assign_to' )]; |
|
71 | + if( $addMetaQuery ) { |
|
72 | 72 | $args[$key] = $value; |
73 | 73 | } |
74 | - $reviews = glsr_get_reviews($args); |
|
75 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
76 | - return 0 === count($reviews); |
|
74 | + $reviews = glsr_get_reviews( $args ); |
|
75 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
76 | + return 0 === count( $reviews ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function validateByEmail() |
83 | 83 | { |
84 | - glsr_log()->debug('Email is: '.glsr_get($this->request, 'email')); |
|
85 | - return $this->validate('email', glsr_get($this->request, 'email')); |
|
84 | + glsr_log()->debug( 'Email is: '.glsr_get( $this->request, 'email' ) ); |
|
85 | + return $this->validate( 'email', glsr_get( $this->request, 'email' ) ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function validateByIpAddress() |
92 | 92 | { |
93 | - glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address')); |
|
94 | - return $this->validate('ip_address', glsr_get($this->request, 'ip_address')); |
|
93 | + glsr_log()->debug( 'IP Address is: '.glsr_get( $this->request, 'ip_address' ) ); |
|
94 | + return $this->validate( 'ip_address', glsr_get( $this->request, 'ip_address' ) ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | protected function validateByUsername() |
101 | 101 | { |
102 | 102 | $user = wp_get_current_user(); |
103 | - if (!$user->exists()) { |
|
103 | + if( !$user->exists() ) { |
|
104 | 104 | return true; |
105 | 105 | } |
106 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
107 | - return $this->validate('username', $user->user_login, false); |
|
106 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
107 | + return $this->validate( 'username', $user->user_login, false ); |
|
108 | 108 | } |
109 | 109 | } |
@@ -1,7 +1,7 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description"> |
4 | - Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a target="_blank" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">documentation</a> first. |
|
4 | + Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a target="_blank" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">documentation</a> first. |
|
5 | 5 | </p> |
6 | 6 | <div class="is-fullwidth"> |
7 | 7 | <div class="glsr-flex-row glsr-has-2-columns"> |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function enqueueAssets() |
23 | 23 | { |
24 | - $command = new EnqueueAdminAssets([ |
|
24 | + $command = new EnqueueAdminAssets( [ |
|
25 | 25 | 'pointers' => [[ |
26 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
26 | + 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
|
27 | 27 | 'id' => 'glsr-pointer-pinned', |
28 | 28 | 'position' => [ |
29 | 29 | 'edge' => 'right', |
@@ -31,24 +31,24 @@ discard block |
||
31 | 31 | ], |
32 | 32 | 'screen' => Application::POST_TYPE, |
33 | 33 | 'target' => '#misc-pub-pinned', |
34 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
34 | + 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
|
35 | 35 | ]], |
36 | - ]); |
|
37 | - $this->execute($command); |
|
36 | + ] ); |
|
37 | + $this->execute( $command ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @return array |
42 | 42 | * @filter plugin_action_links_site-reviews/site-reviews.php |
43 | 43 | */ |
44 | - public function filterActionLinks(array $links) |
|
44 | + public function filterActionLinks( array $links ) |
|
45 | 45 | { |
46 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
47 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
48 | - ]); |
|
49 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
50 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
51 | - ]); |
|
46 | + $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [ |
|
47 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ), |
|
48 | + ] ); |
|
49 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
50 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
|
51 | + ] ); |
|
52 | 52 | return $links; |
53 | 53 | } |
54 | 54 | |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @return array |
59 | 59 | * @filter map_meta_cap |
60 | 60 | */ |
61 | - public function filterCreateCapability($capabilities, $capability) |
|
61 | + public function filterCreateCapability( $capabilities, $capability ) |
|
62 | 62 | { |
63 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
63 | + if( $capability == 'create_'.Application::POST_TYPE ) { |
|
64 | 64 | $capabilities[] = 'do_not_allow'; |
65 | 65 | } |
66 | 66 | return $capabilities; |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | * @return array |
72 | 72 | * @filter dashboard_glance_items |
73 | 73 | */ |
74 | - public function filterDashboardGlanceItems($items) |
|
74 | + public function filterDashboardGlanceItems( $items ) |
|
75 | 75 | { |
76 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
77 | - if (empty($postCount->publish)) { |
|
76 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
77 | + if( empty($postCount->publish) ) { |
|
78 | 78 | return $items; |
79 | 79 | } |
80 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
81 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
82 | - $items = glsr(Helper::class)->consolidateArray($items); |
|
83 | - $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts) |
|
84 | - ? glsr(Builder::class)->a($text, [ |
|
80 | + $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
|
81 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
82 | + $items = glsr( Helper::class )->consolidateArray( $items ); |
|
83 | + $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
|
84 | + ? glsr( Builder::class )->a( $text, [ |
|
85 | 85 | 'class' => 'glsr-review-count', |
86 | 86 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
87 | - ]) |
|
88 | - : glsr(Builder::class)->span($text, [ |
|
87 | + ] ) |
|
88 | + : glsr( Builder::class )->span( $text, [ |
|
89 | 89 | 'class' => 'glsr-review-count', |
90 | - ]); |
|
90 | + ] ); |
|
91 | 91 | return $items; |
92 | 92 | } |
93 | 93 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return array |
97 | 97 | * @filter mce_external_plugins |
98 | 98 | */ |
99 | - public function filterTinymcePlugins($plugins) |
|
99 | + public function filterTinymcePlugins( $plugins ) |
|
100 | 100 | { |
101 | - if (current_user_can('edit_posts') || current_user_can('edit_pages')) { |
|
102 | - $plugins = glsr(Helper::class)->consolidateArray($plugins); |
|
103 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
101 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
102 | + $plugins = glsr( Helper::class )->consolidateArray( $plugins ); |
|
103 | + $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
|
104 | 104 | } |
105 | 105 | return $plugins; |
106 | 106 | } |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function registerTinymcePopups() |
113 | 113 | { |
114 | - $command = new RegisterTinymcePopups([ |
|
115 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
116 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
117 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
118 | - ]); |
|
119 | - $this->execute($command); |
|
114 | + $command = new RegisterTinymcePopups( [ |
|
115 | + 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
|
116 | + 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
|
117 | + 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
|
118 | + ] ); |
|
119 | + $this->execute( $command ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | * @return void|null |
125 | 125 | * @action media_buttons |
126 | 126 | */ |
127 | - public function renderTinymceButton($editorId) |
|
127 | + public function renderTinymceButton( $editorId ) |
|
128 | 128 | { |
129 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
130 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
129 | + $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
|
130 | + if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | $shortcodes = []; |
134 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
134 | + foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
|
135 | 135 | $shortcodes[$shortcode] = $values; |
136 | 136 | } |
137 | - if (empty($shortcodes)) { |
|
137 | + if( empty($shortcodes) ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - glsr()->render('partials/editor/tinymce', [ |
|
140 | + glsr()->render( 'partials/editor/tinymce', [ |
|
141 | 141 | 'shortcodes' => $shortcodes, |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function routerClearConsole() |
149 | 149 | { |
150 | - glsr(Console::class)->clear(); |
|
151 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
150 | + glsr( Console::class )->clear(); |
|
151 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function routerFetchConsole() |
158 | 158 | { |
159 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
159 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @param bool $showNotice |
164 | 164 | * @return void |
165 | 165 | */ |
166 | - public function routerCountReviews($showNotice = true) |
|
166 | + public function routerCountReviews( $showNotice = true ) |
|
167 | 167 | { |
168 | - glsr(CountsManager::class)->countAll(); |
|
169 | - glsr(OptionManager::class)->set('last_review_count', current_time('timestamp')); |
|
170 | - if ($showNotice) { |
|
171 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
168 | + glsr( CountsManager::class )->countAll(); |
|
169 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
170 | + if( $showNotice ) { |
|
171 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function routerDownloadConsole() |
179 | 179 | { |
180 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
180 | + $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() ); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function routerDownloadSystemInfo() |
187 | 187 | { |
188 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
188 | + $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function routerExportSettings() |
195 | 195 | { |
196 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
196 | + $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() ); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -202,35 +202,35 @@ discard block |
||
202 | 202 | public function routerImportSettings() |
203 | 203 | { |
204 | 204 | $file = $_FILES['import-file']; |
205 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
206 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
205 | + if( UPLOAD_ERR_OK !== $file['error'] ) { |
|
206 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
207 | 207 | } |
208 | - if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) { |
|
209 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
208 | + if( 'application/json' !== $file['type'] || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
209 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
210 | 210 | } |
211 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
212 | - if (empty($settings)) { |
|
213 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
211 | + $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
|
212 | + if( empty($settings) ) { |
|
213 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
214 | 214 | } |
215 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
216 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
215 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
216 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | 220 | * @param int $errorCode |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - protected function getUploadError($errorCode) |
|
223 | + protected function getUploadError( $errorCode ) |
|
224 | 224 | { |
225 | 225 | $errors = [ |
226 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
227 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
228 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
229 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
230 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
231 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
232 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
226 | + UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ), |
|
227 | + UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ), |
|
228 | + UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ), |
|
229 | + UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ), |
|
230 | + UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ), |
|
231 | + UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
|
232 | + UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
|
233 | 233 | ]; |
234 | - return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
234 | + return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) ); |
|
235 | 235 | } |
236 | 236 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function getFromEmail() |
35 | 35 | { |
36 | - return glsr(OptionManager::class)->getWP('admin_email'); |
|
36 | + return glsr( OptionManager::class )->getWP( 'admin_email' ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function getFromName() |
43 | 43 | { |
44 | - return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
44 | + return wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES ); |
|
45 | 45 | } |
46 | 46 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description">We think you'll love the changes in this new release!</p> |
4 | 4 | <div class="is-fullwidth"> |
@@ -1,23 +1,23 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-welcome wrap about-wrap about-wrap-content"> |
4 | 4 | <h1>Welcome to <?= glsr()->name; ?></h1> |
5 | 5 | <div class="about-text">Site Reviews is a free WordPress review plugin with advanced features that makes it easy to manage reviews on your website. Follow the instructions below to get started!</div> |
6 | 6 | <div class="wp-badge">Version <?= glsr()->version; ?></div> |
7 | 7 | <p class="about-buttons"> |
8 | - <a class="button" href="<?= admin_url('edit.php?post_type=site-review&page=documentation'); ?>">Documentation</a> |
|
8 | + <a class="button" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation' ); ?>">Documentation</a> |
|
9 | 9 | <a class="button" href="https://wordpress.org/support/plugin/site-reviews/">Support</a> |
10 | 10 | <a target="_blank" class="button" href="https://www.facebook.com/sharer/sharer.php?u=https%3A//geminilabs.io/site-reviews"><span class="dashicons dashicons-facebook-alt"></span> Share</a> |
11 | 11 | <a target="_blank" class="button" href="https://twitter.com/intent/tweet?text=Site Reviews is a fantastic WordPress review plugin with advanced features that makes it easy to manage reviews on your website.&url=https://geminilabs.io/site-reviews&hashtags=WordPress,reviewplugins,"><span class="dashicons dashicons-twitter"></span> Tweet</a> |
12 | 12 | </p> |
13 | 13 | <nav class="glsr-nav-tab-wrapper nav-tab-wrapper"> |
14 | - <?php foreach ($tabs as $id => $title) : ?> |
|
14 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
15 | 15 | <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a> |
16 | 16 | <?php endforeach; ?> |
17 | 17 | </nav> |
18 | - <?php foreach ($tabs as $id => $title) : ?> |
|
18 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
19 | 19 | <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>"> |
20 | - <?php $template->render('pages/welcome/'.$id, $data); ?> |
|
20 | + <?php $template->render( 'pages/welcome/'.$id, $data ); ?> |
|
21 | 21 | </div> |
22 | 22 | <?php endforeach; ?> |
23 | 23 | <input type="hidden" name="_active_tab"> |