@@ -31,7 +31,7 @@ |
||
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | 33 | if( $diff > $timePeriod[0] )continue; |
34 | - $unit = intval( floor( $diff / $timePeriod[1] )); |
|
34 | + $unit = intval( floor( $diff / $timePeriod[1] ) ); |
|
35 | 35 | $relativeDates = [ |
36 | 36 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
37 | 37 | _n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ), |
@@ -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' )), true ), |
|
121 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
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' ) ), true ), |
|
121 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
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 $value; |
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 | } |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() |
35 | 35 | { |
36 | - if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE )) { |
|
37 | - $cookie = explode( '||', stripslashes( $cookieId )); |
|
36 | + if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ) ) { |
|
37 | + $cookie = explode( '||', stripslashes( $cookieId ) ); |
|
38 | 38 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
39 | 39 | $this->expiryTimestamp = absint( $cookie[1] ); |
40 | 40 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | 80 | global $wpdb; |
81 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
81 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
82 | 82 | $wpdb->query( |
83 | 83 | "DELETE FROM {$wpdb->options} WHERE option_name IN ('{$expiredSessions}')" |
84 | 84 | ); |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | public function get( $key, $fallback = '', $unset = false ) |
95 | 95 | { |
96 | 96 | $key = sanitize_key( $key ); |
97 | - $value = isset( $this->sessionData[$key] ) |
|
97 | + $value = isset($this->sessionData[$key]) |
|
98 | 98 | ? maybe_unserialize( $this->sessionData[$key] ) |
99 | 99 | : $fallback; |
100 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
101 | - unset( $this->sessionData[$key] ); |
|
100 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
101 | + unset($this->sessionData[$key]); |
|
102 | 102 | $this->updateSession(); |
103 | 103 | } |
104 | 104 | return $value; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | protected function deleteSession() |
133 | 133 | { |
134 | 134 | delete_option( $this->getSessionId() ); |
135 | - delete_option( $this->getSessionId( 'expires' )); |
|
135 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function generateSessionId() |
142 | 142 | { |
143 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
143 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | global $wpdb; |
153 | 153 | $expiredSessions = []; |
154 | 154 | $sessions = $wpdb->get_results( |
155 | - "SELECT option_name AS name, option_value AS expiration " . |
|
156 | - "FROM {$wpdb->options} " . |
|
157 | - "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " . |
|
158 | - "ORDER BY option_value ASC " . |
|
155 | + "SELECT option_name AS name, option_value AS expiration ". |
|
156 | + "FROM {$wpdb->options} ". |
|
157 | + "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' ". |
|
158 | + "ORDER BY option_value ASC ". |
|
159 | 159 | "LIMIT 0, ".absint( $limit ) |
160 | 160 | ); |
161 | - if( !empty( $sessions )) { |
|
161 | + if( !empty($sessions) ) { |
|
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | 164 | if( $now <= $session->expiration )continue; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function getSessionId( $separator = '' ) |
177 | 177 | { |
178 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
178 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | if( headers_sent() )return; |
208 | 208 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
209 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
210 | 210 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
211 | 211 | } |
212 | 212 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function updateSession() |
226 | 226 | { |
227 | - if( false === get_option( $this->getSessionId() )) { |
|
227 | + if( false === get_option( $this->getSessionId() ) ) { |
|
228 | 228 | $this->createSession(); |
229 | 229 | } |
230 | 230 | else { |
@@ -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,14 +93,14 @@ discard block |
||
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | $recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' ); |
96 | - if( empty( $recaptchaResponse )) { |
|
96 | + if( empty($recaptchaResponse) ) { |
|
97 | 97 | return null; //if response is empty we need to return null |
98 | 98 | } |
99 | 99 | if( $integration == 'custom' ) { |
100 | 100 | return $this->isRecaptchaValid( $recaptchaResponse ); |
101 | 101 | } |
102 | 102 | if( $integration == 'invisible-recaptcha' ) { |
103 | - return boolval( apply_filters( 'google_invre_is_valid_request_filter', true )); |
|
103 | + return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) ); |
|
104 | 104 | } |
105 | 105 | return false; |
106 | 106 | } |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function isRecaptchaValid( $recaptchaResponse ) |
112 | 112 | { |
113 | - $endpoint = add_query_arg([ |
|
113 | + $endpoint = add_query_arg( [ |
|
114 | 114 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
115 | 115 | 'response' => $recaptchaResponse, |
116 | 116 | 'secret' => glsr( OptionManager::class )->get( 'settings.reviews-form.recaptcha.secret' ), |
117 | 117 | ], 'https://www.google.com/recaptcha/api/siteverify' ); |
118 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
118 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
119 | 119 | glsr_log()->error( $response->get_error_message() ); |
120 | 120 | return false; |
121 | 121 | } |
122 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
123 | - if( !empty( $response->success )) { |
|
122 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
123 | + if( !empty($response->success) ) { |
|
124 | 124 | return boolval( $response->success ); |
125 | 125 | } |
126 | 126 | $errorCodes = [ |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | $rules = $this->getValidationRules( $request ); |
145 | 145 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
146 | - if( empty( $errors )) { |
|
146 | + if( empty($errors) ) { |
|
147 | 147 | return true; |
148 | 148 | } |
149 | 149 | $this->setSessionValues( 'errors', $errors ); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
161 | 161 | { |
162 | 162 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
163 | - if( !empty( $loggedMessage )) { |
|
163 | + if( !empty($loggedMessage) ) { |
|
164 | 164 | glsr_log()->warning( $loggedMessage ); |
165 | 165 | glsr_log()->warning( $this->request ); |
166 | 166 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | */ |
172 | 172 | protected function validateAkismet() |
173 | 173 | { |
174 | - if( !empty( $this->error ))return; |
|
175 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
174 | + if( !empty($this->error) )return; |
|
175 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
176 | 176 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
177 | 177 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
178 | 178 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function validateBlacklist() |
184 | 184 | { |
185 | - if( !empty( $this->error ))return; |
|
186 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
185 | + if( !empty($this->error) )return; |
|
186 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
187 | 187 | $blacklistAction = glsr( OptionManager::class )->get( 'settings.reviews-form.blacklist.action' ); |
188 | 188 | if( $blacklistAction == 'unapprove' ) { |
189 | 189 | $this->request['blacklisted'] = true; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function validateCustom() |
201 | 201 | { |
202 | - if( !empty( $this->error ))return; |
|
202 | + if( !empty($this->error) )return; |
|
203 | 203 | $validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request ); |
204 | 204 | if( $validated === true )return; |
205 | 205 | $this->setSessionValues( 'errors', [] ); |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function validateHoneyPot() |
216 | 216 | { |
217 | - if( !empty( $this->error ))return; |
|
218 | - if( empty( $this->request['gotcha'] ))return; |
|
217 | + if( !empty($this->error) )return; |
|
218 | + if( empty($this->request['gotcha']) )return; |
|
219 | 219 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
220 | 220 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
221 | 221 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function validateRecaptcha() |
227 | 227 | { |
228 | - if( !empty( $this->error ))return; |
|
228 | + if( !empty($this->error) )return; |
|
229 | 229 | $isValid = $this->isRecaptchaResponseValid(); |
230 | - if( is_null( $isValid )) { |
|
230 | + if( is_null( $isValid ) ) { |
|
231 | 231 | $this->setSessionValues( 'recaptcha', true ); |
232 | 232 | $this->recaptchaIsUnset = true; |
233 | 233 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function renderFilters( $postType ) |
16 | 16 | { |
17 | 17 | if( $postType !== Application::POST_TYPE )return; |
18 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
18 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
19 | 19 | $status = 'publish'; |
20 | 20 | } |
21 | 21 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | protected function buildColumnAssignedTo( $postId ) |
46 | 46 | { |
47 | 47 | $post = get_post( glsr( Database::class )->getReviewMeta( $postId )->assigned_to ); |
48 | - if( !( $post instanceof WP_Post ) || $post->post_status != 'publish' ) { |
|
48 | + if( !($post instanceof WP_Post) || $post->post_status != 'publish' ) { |
|
49 | 49 | return '—'; |
50 | 50 | } |
51 | 51 | return glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
52 | 52 | 'href' => (string)get_the_permalink( $post->ID ), |
53 | - ]); |
|
53 | + ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | return glsr( Html::class )->buildPartial( 'star-rating', [ |
72 | 72 | 'rating' => glsr( Database::class )->getReviewMeta( $postId )->rating, |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $pinned = glsr( Database::class )->getReviewMeta( $postId )->pinned |
83 | 83 | ? ' pinned' |
84 | 84 | : ''; |
85 | - return glsr( Builder::class )->i([ |
|
85 | + return glsr( Builder::class )->i( [ |
|
86 | 86 | 'class' => trim( 'dashicons dashicons-sticky '.$pinned ), |
87 | 87 | 'data-id' => $postId, |
88 | - ]); |
|
88 | + ] ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | protected function buildColumnType( $postId ) |
96 | 96 | { |
97 | 97 | $reviewMeta = glsr( Database::class )->getReviewMeta( $postId ); |
98 | - return isset( glsr()->reviewTypes[$reviewMeta->review_type] ) |
|
98 | + return isset(glsr()->reviewTypes[$reviewMeta->review_type]) |
|
99 | 99 | ? glsr()->reviewTypes[$reviewMeta->review_type] |
100 | 100 | : $reviewMeta->review_type; |
101 | 101 | } |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function renderFilterRatings( $ratings ) |
108 | 108 | { |
109 | - if( empty( $ratings ) |
|
109 | + if( empty($ratings) |
|
110 | 110 | || apply_filters( 'site-reviews/disable/filter/ratings', false ) |
111 | 111 | )return; |
112 | - $ratings = array_flip( array_reverse( $ratings )); |
|
112 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
113 | 113 | array_walk( $ratings, function( &$value, $key ) { |
114 | 114 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
115 | 115 | $value = sprintf( $label, $key ); |
116 | 116 | }); |
117 | 117 | $ratings = [__( 'All ratings', 'site-reviews' )] + $ratings; |
118 | - printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' )); |
|
118 | + printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' ) ); |
|
119 | 119 | glsr( Html::class )->renderPartial( 'filterby', [ |
120 | 120 | 'name' => 'rating', |
121 | 121 | 'values' => $ratings, |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | { |
131 | 131 | if( count( glsr()->reviewTypes ) < 2 )return; |
132 | 132 | $reviewTypes = ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes; |
133 | - printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' )); |
|
133 | + printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' ) ); |
|
134 | 134 | glsr( Html::class )->renderPartial( 'filterby', [ |
135 | 135 | 'name' => 'review_type', |
136 | 136 | 'options' => $reviewTypes, |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | } |
139 | 139 | } |
@@ -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 ) { |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function approve() |
23 | 23 | { |
24 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
25 | - wp_update_post([ |
|
24 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
25 | + wp_update_post( [ |
|
26 | 26 | 'ID' => $postId, |
27 | 27 | 'post_status' => 'publish', |
28 | - ]); |
|
28 | + ] ); |
|
29 | 29 | wp_safe_redirect( wp_get_referer() ); |
30 | 30 | exit; |
31 | 31 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | { |
55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
57 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
58 | 58 | $value = $columns[$key]; |
59 | 59 | } |
60 | - if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
|
61 | - unset( $postTypeColumns['review_type'] ); |
|
60 | + if( count( glsr( Database::class )->getReviewsMeta( 'type' ) ) < 2 ) { |
|
61 | + unset($postTypeColumns['review_type']); |
|
62 | 62 | } |
63 | 63 | return array_filter( $postTypeColumns, 'strlen' ); |
64 | 64 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
85 | 85 | return $actions; |
86 | 86 | } |
87 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
87 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
88 | 88 | $rowActions = [ |
89 | 89 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
90 | 90 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | admin_url( 'post.php?post='.$post->ID.'&action='.$key ), |
98 | 98 | $key.'-review_'.$post->ID |
99 | 99 | ), |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | } |
102 | 102 | return $actions; |
103 | 103 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | public function filterSortableColumns( array $columns ) |
110 | 110 | { |
111 | 111 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
112 | - unset( $postTypeColumns['cb'] ); |
|
112 | + unset($postTypeColumns['cb']); |
|
113 | 113 | foreach( $postTypeColumns as $key => $value ) { |
114 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
114 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
115 | 115 | $columns[$key] = $key; |
116 | 116 | } |
117 | 117 | return $columns; |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
131 | 131 | { |
132 | - if( $this->canModifyTranslation( $domain )) { |
|
132 | + if( $this->canModifyTranslation( $domain ) ) { |
|
133 | 133 | $strings = [ |
134 | 134 | 'Published' => __( 'Approved', 'site-reviews' ), |
135 | 135 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
136 | 136 | ]; |
137 | 137 | foreach( $strings as $search => $replace ) { |
138 | 138 | if( strpos( $single, $search ) === false )continue; |
139 | - $translation = $this->getTranslation([ |
|
139 | + $translation = $this->getTranslation( [ |
|
140 | 140 | 'number' => $number, |
141 | 141 | 'plural' => str_replace( $search, $replace, $plural ), |
142 | 142 | 'single' => str_replace( $search, $replace, $single ), |
143 | - ]); |
|
143 | + ] ); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | return $translation; |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function saveBulkEditFields( $postId ) |
188 | 188 | { |
189 | - if( !current_user_can( 'edit_posts' ))return; |
|
189 | + if( !current_user_can( 'edit_posts' ) )return; |
|
190 | 190 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
191 | - if( $assignedTo && get_post( $assignedTo )) { |
|
191 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
192 | 192 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
193 | 193 | } |
194 | 194 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function setQueryForColumn( WP_Query $query ) |
201 | 201 | { |
202 | - if( !$this->hasPermission( $query ))return; |
|
202 | + if( !$this->hasPermission( $query ) )return; |
|
203 | 203 | $this->setMetaQuery( $query, [ |
204 | 204 | 'rating', 'review_type', |
205 | - ]); |
|
205 | + ] ); |
|
206 | 206 | $this->setOrderby( $query ); |
207 | 207 | } |
208 | 208 | |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function unapprove() |
214 | 214 | { |
215 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
216 | - wp_update_post([ |
|
215 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
216 | + wp_update_post( [ |
|
217 | 217 | 'ID' => $postId, |
218 | 218 | 'post_status' => 'pending', |
219 | - ]); |
|
219 | + ] ); |
|
220 | 220 | wp_safe_redirect( wp_get_referer() ); |
221 | 221 | exit; |
222 | 222 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'single' => '', |
246 | 246 | 'text' => '', |
247 | 247 | ]; |
248 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
248 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
249 | 249 | $translations = get_translations_for_domain( Application::ID ); |
250 | 250 | return $args->text |
251 | 251 | ? $translations->translate( $args->text ) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
271 | 271 | { |
272 | 272 | foreach( $metaKeys as $key ) { |
273 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
273 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
274 | 274 | $metaQuery = (array)$query->get( 'meta_query' ); |
275 | 275 | $metaQuery[] = [ |
276 | 276 | 'key' => $key, |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | { |
288 | 288 | $orderby = $query->get( 'orderby' ); |
289 | 289 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
290 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
291 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
290 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
291 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
292 | 292 | $query->set( 'meta_key', $orderby ); |
293 | 293 | $query->set( 'orderby', 'meta_value' ); |
294 | 294 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $translations = $this->getTranslations(); |
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( !isset( $this->entries )) { |
|
46 | + if( !isset($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->getTranslations(); |
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 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | $args = $this->normalizeTranslationArgs( $args ); |
267 | 267 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
268 | - if( empty( $strings )) { |
|
268 | + if( empty($strings) ) { |
|
269 | 269 | return $original; |
270 | 270 | } |
271 | 271 | $string = current( $strings ); |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | */ |
281 | 281 | protected function getEntryString( array $entry, $key ) |
282 | 282 | { |
283 | - return isset( $entry[$key] ) |
|
284 | - ? implode( '', (array) $entry[$key] ) |
|
283 | + return isset($entry[$key]) |
|
284 | + ? implode( '', (array)$entry[$key] ) |
|
285 | 285 | : ''; |
286 | 286 | } |
287 | 287 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | protected function getTranslations() |
292 | 292 | { |
293 | 293 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
294 | - return isset( $settings['translations'] ) |
|
295 | - ? $this->normalizeSettings( (array) $settings['translations'] ) |
|
294 | + return isset($settings['translations']) |
|
295 | + ? $this->normalizeSettings( (array)$settings['translations'] ) |
|
296 | 296 | : []; |
297 | 297 | } |
298 | 298 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | protected function getTranslationStrings( $single, $plural ) |
305 | 305 | { |
306 | - return array_filter( $this->getTranslations(), function( $string ) use( $single, $plural ) { |
|
306 | + return array_filter( $this->getTranslations(), function( $string ) use($single, $plural) { |
|
307 | 307 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
308 | 308 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
309 | 309 | }); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $keys = [ |
318 | 318 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
319 | 319 | ]; |
320 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
320 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
321 | 321 | foreach( $keys as $key ) { |
322 | 322 | $entry = $this->normalizeEntryString( $entry, $key ); |
323 | 323 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function normalizeEntryString( array $entry, $key ) |
333 | 333 | { |
334 | - if( isset( $entry[$key] )) { |
|
334 | + if( isset($entry[$key]) ) { |
|
335 | 335 | $entry[$key] = $this->getEntryString( $entry, $key ); |
336 | 336 | } |
337 | 337 | return $entry; |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
346 | 346 | $strings = array_filter( $strings, 'is_array' ); |
347 | 347 | foreach( $strings as &$string ) { |
348 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
348 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
349 | 349 | $string = wp_parse_args( $string, $defaultString ); |
350 | 350 | } |
351 | 351 | return array_filter( $strings, function( $string ) { |
352 | - return !empty( $string['id'] ); |
|
352 | + return !empty($string['id']); |
|
353 | 353 | }); |
354 | 354 | } |
355 | 355 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | protected function translatePlural( $domain, array $string, array $args ) |
375 | 375 | { |
376 | - if( !empty( $string['p2'] )) { |
|
376 | + if( !empty($string['p2']) ) { |
|
377 | 377 | $args['plural'] = $string['p2']; |
378 | 378 | } |
379 | 379 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | protected function translateSingle( $domain, array $string, array $args ) |
392 | 392 | { |
393 | - if( !empty( $string['s2'] )) { |
|
393 | + if( !empty($string['s2']) ) { |
|
394 | 394 | $args['single'] = $string['s2']; |
395 | 395 | } |
396 | 396 | return get_translations_for_domain( $domain )->translate( |