@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | 'class' => 'widefat', |
21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
22 | 22 | 'name' => 'title', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | if( count( glsr()->reviewTypes ) > 1 ) { |
25 | 25 | $this->renderField( 'select', [ |
26 | 26 | 'class' => 'widefat', |
27 | 27 | 'label' => __( 'Which type of review would you like to use?', 'site-reviews' ), |
28 | 28 | 'name' => 'type', |
29 | 29 | 'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes, |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | } |
32 | - if( !empty( $terms )) { |
|
32 | + if( !empty($terms) ) { |
|
33 | 33 | $this->renderField( 'select', [ |
34 | 34 | 'class' => 'widefat', |
35 | 35 | 'label' => __( 'Limit summary to this category', 'site-reviews' ), |
36 | 36 | 'name' => 'category', |
37 | 37 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | } |
40 | 40 | $this->renderField( 'text', [ |
41 | 41 | 'class' => 'widefat', |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
44 | 44 | 'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ), |
45 | 45 | 'name' => 'assigned_to', |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | $this->renderField( 'text', [ |
48 | 48 | 'class' => 'widefat', |
49 | 49 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
50 | 50 | 'name' => 'class', |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | $this->renderField( 'checkbox', [ |
53 | 53 | 'name' => 'hide', |
54 | 54 | 'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | if( !empty( $sessions )) { |
151 | 151 | $now = time(); |
152 | 152 | foreach( $sessions as $session ) { |
153 | - if( $now <= $session->expiration )continue; |
|
153 | + if( $now <= $session->expiration ) { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $expiredSessions[] = $session->name; |
155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
193 | 195 | */ |
194 | 196 | protected function setCookie() |
195 | 197 | { |
196 | - if( headers_sent() )return; |
|
198 | + if( headers_sent() ) { |
|
199 | + return; |
|
200 | + } |
|
197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
82 | 82 | } |
83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
92 | 92 | { |
93 | 93 | $key = sanitize_key( $key ); |
94 | - $value = isset( $this->sessionData[$key] ) |
|
94 | + $value = isset($this->sessionData[$key]) |
|
95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
96 | 96 | : $fallback; |
97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
98 | - unset( $this->sessionData[$key] ); |
|
97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
98 | + unset($this->sessionData[$key]); |
|
99 | 99 | $this->updateSession(); |
100 | 100 | } |
101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function deleteSession() |
130 | 130 | { |
131 | 131 | delete_option( $this->getSessionId() ); |
132 | - delete_option( $this->getSessionId( 'expires' )); |
|
132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function generateSessionId() |
139 | 139 | { |
140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | protected function getExpiredSessions( $limit ) |
148 | 148 | { |
149 | 149 | $expiredSessions = []; |
150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
151 | - if( !empty( $sessions )) { |
|
150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
151 | + if( !empty($sessions) ) { |
|
152 | 152 | $now = time(); |
153 | 153 | foreach( $sessions as $session ) { |
154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function getSessionId( $separator = '' ) |
167 | 167 | { |
168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | if( headers_sent() )return; |
198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
201 | 201 | } |
202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function updateSession() |
216 | 216 | { |
217 | - if( false === get_option( $this->getSessionId() )) { |
|
217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
218 | 218 | return $this->createSession(); |
219 | 219 | } |
220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -175,8 +175,12 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty( $this->error )) { |
|
179 | + return; |
|
180 | + } |
|
181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
182 | + return; |
|
183 | + } |
|
180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function validateBlacklist() |
188 | 192 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
193 | + if( !empty( $this->error )) { |
|
194 | + return; |
|
195 | + } |
|
196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 200 | if( $blacklistAction == 'reject' ) { |
193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
202 | 210 | */ |
203 | 211 | protected function validateCustom() |
204 | 212 | { |
205 | - if( !empty( $this->error ))return; |
|
213 | + if( !empty( $this->error )) { |
|
214 | + return; |
|
215 | + } |
|
206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | - if( $validated === true )return; |
|
217 | + if( $validated === true ) { |
|
218 | + return; |
|
219 | + } |
|
208 | 220 | $this->setSessionValues( 'errors', [] ); |
209 | 221 | $this->setSessionValues( 'values', $this->request ); |
210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
217 | 229 | */ |
218 | 230 | protected function validateHoneyPot() |
219 | 231 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
232 | + if( !empty( $this->error )) { |
|
233 | + return; |
|
234 | + } |
|
235 | + if( empty( $this->request['gotcha'] )) { |
|
236 | + return; |
|
237 | + } |
|
222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
228 | 244 | */ |
229 | 245 | protected function validateRecaptcha() |
230 | 246 | { |
231 | - if( !empty( $this->error ))return; |
|
247 | + if( !empty( $this->error )) { |
|
248 | + return; |
|
249 | + } |
|
232 | 250 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
252 | + return; |
|
253 | + } |
|
234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 256 | $this->recaptchaIsUnset = true; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->validateBlacklist(); |
68 | 68 | $this->validateAkismet(); |
69 | 69 | $this->validateRecaptcha(); |
70 | - if( !empty( $this->error )) { |
|
70 | + if( !empty($this->error) ) { |
|
71 | 71 | $this->setSessionValues( 'message', $this->error ); |
72 | 72 | } |
73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
92 | 92 | return static::RECAPTCHA_DISABLED; |
93 | 93 | } |
94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
96 | 96 | ? static::RECAPTCHA_EMPTY |
97 | 97 | : static::RECAPTCHA_FAILED; |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function getRecaptchaTokenStatus() |
106 | 106 | { |
107 | - $endpoint = add_query_arg([ |
|
107 | + $endpoint = add_query_arg( [ |
|
108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
109 | 109 | 'response' => $this->request['_recaptcha-token'], |
110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
113 | 113 | glsr_log()->error( $response->get_error_message() ); |
114 | 114 | return static::RECAPTCHA_FAILED; |
115 | 115 | } |
116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
117 | - if( !empty( $response->success )) { |
|
116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
117 | + if( !empty($response->success) ) { |
|
118 | 118 | return boolval( $response->success ) |
119 | 119 | ? static::RECAPTCHA_VALID |
120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | { |
133 | 133 | $rules = array_intersect_key( |
134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
136 | 136 | ); |
137 | - $excluded = explode( ',', glsr_get( $request, 'excluded' )); |
|
138 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
137 | + $excluded = explode( ',', glsr_get( $request, 'excluded' ) ); |
|
138 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | $rules = $this->getValidationRules( $request ); |
147 | 147 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
148 | - if( empty( $errors )) { |
|
148 | + if( empty($errors) ) { |
|
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | $this->setSessionValues( 'errors', $errors ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
163 | 163 | { |
164 | 164 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
165 | - if( !empty( $loggedMessage )) { |
|
165 | + if( !empty($loggedMessage) ) { |
|
166 | 166 | glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
167 | 167 | } |
168 | 168 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function validateAkismet() |
174 | 174 | { |
175 | - if( !empty( $this->error ))return; |
|
176 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
175 | + if( !empty($this->error) )return; |
|
176 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
177 | 177 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
178 | 178 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
179 | 179 | } |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function validateBlacklist() |
185 | 185 | { |
186 | - if( !empty( $this->error ))return; |
|
187 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
186 | + if( !empty($this->error) )return; |
|
187 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
188 | 188 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
189 | 189 | if( $blacklistAction == 'reject' ) { |
190 | 190 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -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/custom', 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 | $status = $this->getRecaptchaStatus(); |
230 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
230 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
231 | 231 | if( $status == static::RECAPTCHA_EMPTY ) { |
232 | 232 | $this->setSessionValues( 'recaptcha', 'unset' ); |
233 | 233 | $this->recaptchaIsUnset = true; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | protected function validateRequest( array $request ) |
249 | 249 | { |
250 | - if( !$this->isRequestValid( $request )) { |
|
250 | + if( !$this->isRequestValid( $request ) ) { |
|
251 | 251 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
252 | 252 | return $request; |
253 | 253 | } |
@@ -60,7 +60,9 @@ discard block |
||
60 | 60 | public function catchFatalError() |
61 | 61 | { |
62 | 62 | $error = error_get_last(); |
63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
64 | + return; |
|
65 | + } |
|
64 | 66 | glsr_log()->error( $error['message'] ); |
65 | 67 | } |
66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $filePaths[] = $this->path( $view ); |
112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 115 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
116 | + if( !file_exists( $file )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | return $file; |
116 | 120 | } |
117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
215 | 219 | */ |
216 | 220 | public function scheduleCronJob() |
217 | 221 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
223 | + return; |
|
224 | + } |
|
219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 226 | } |
221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
256 | 262 | || $data['action'] != 'update' |
257 | 263 | || $data['type'] != 'plugin' |
258 | - )return; |
|
264 | + ) { |
|
265 | + return; |
|
266 | + } |
|
259 | 267 | $this->upgrade(); |
260 | 268 | } |
261 | 269 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | static::$instance = $this; |
36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
37 | 37 | $plugin = get_file_data( $this->file, [ |
38 | 38 | 'languages' => 'Domain Path', |
39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $constant = $className.'::'.$property; |
87 | 87 | return defined( $constant ) |
88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
89 | 89 | : ''; |
90 | 90 | } |
91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function file( $view ) |
105 | 105 | { |
106 | - $view.= '.php'; |
|
106 | + $view .= '.php'; |
|
107 | 107 | $filePaths = []; |
108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
110 | 110 | } |
111 | 111 | $filePaths[] = $this->path( $view ); |
112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 113 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
114 | + if( !file_exists( $file ) )continue; |
|
115 | 115 | return $file; |
116 | 116 | } |
117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getDefaults() |
123 | 123 | { |
124 | - if( empty( $this->defaults )) { |
|
124 | + if( empty($this->defaults) ) { |
|
125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
126 | 126 | $this->upgrade(); |
127 | 127 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'addons' => 'install_plugins', |
138 | 138 | 'settings' => 'manage_options', |
139 | 139 | ]; |
140 | - return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' )); |
|
140 | + return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public function hasPermission( $page = '' ) |
147 | 147 | { |
148 | 148 | $isAdmin = $this->isAdmin(); |
149 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->getPermission( $page ))); |
|
149 | + return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) )); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | { |
175 | 175 | $path = plugin_dir_path( $this->file ); |
176 | 176 | if( !$realpath ) { |
177 | - $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file )); |
|
177 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
178 | 178 | } |
179 | 179 | $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
180 | 180 | return apply_filters( 'site-reviews/path', $path, $file ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
207 | 207 | $this->reviewTypes = wp_parse_args( $types, [ |
208 | 208 | 'local' => __( 'Local', 'site-reviews' ), |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | { |
218 | 218 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
219 | 219 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
220 | - if( !file_exists( $file )) { |
|
220 | + if( !file_exists( $file ) ) { |
|
221 | 221 | glsr_log()->error( 'File not found: '.$file ); |
222 | 222 | return; |
223 | 223 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function scheduleCronJob() |
233 | 233 | { |
234 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
234 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
235 | 235 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
236 | 236 | } |
237 | 237 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function unscheduleCronJob() |
251 | 251 | { |
252 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
252 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function url( $path = '' ) |
283 | 283 | { |
284 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
284 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
285 | 285 | return apply_filters( 'site-reviews/url', $url, $path ); |
286 | 286 | } |
287 | 287 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) { |
36 | 36 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
37 | 37 | // @see https://developers.google.com/search/docs/data-types/review |
38 | - if( $review->review_type != 'local' )continue; |
|
38 | + if( $review->review_type != 'local' ) { |
|
39 | + continue; |
|
40 | + } |
|
39 | 41 | $reviews[] = $this->buildReview( $review ); |
40 | 42 | } |
41 | 43 | if( !empty( $reviews )) { |
@@ -80,7 +82,9 @@ discard block |
||
80 | 82 | */ |
81 | 83 | public function render() |
82 | 84 | { |
83 | - if( empty( glsr()->schemas ))return; |
|
85 | + if( empty( glsr()->schemas )) { |
|
86 | + return; |
|
87 | + } |
|
84 | 88 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
85 | 89 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
86 | 90 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -132,7 +136,9 @@ discard block |
||
132 | 136 | { |
133 | 137 | foreach( $values as $value ) { |
134 | 138 | $option = $this->getSchemaOptionValue( $value ); |
135 | - if( empty( $option ))continue; |
|
139 | + if( empty( $option )) { |
|
140 | + continue; |
|
141 | + } |
|
136 | 142 | $schema->$value( $option ); |
137 | 143 | } |
138 | 144 | return $schema; |
@@ -242,7 +248,9 @@ discard block |
||
242 | 248 | if( $value != $fallback ) { |
243 | 249 | return $value; |
244 | 250 | } |
245 | - if( !is_single() && !is_page() )return; |
|
251 | + if( !is_single() && !is_page() ) { |
|
252 | + return; |
|
253 | + } |
|
246 | 254 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
247 | 255 | if( method_exists( $this, $method )) { |
248 | 256 | return $this->$method(); |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | if( $review->review_type != 'local' )continue; |
39 | 39 | $reviews[] = $this->buildReview( $review ); |
40 | 40 | } |
41 | - if( !empty( $reviews )) { |
|
41 | + if( !empty($reviews) ) { |
|
42 | 42 | array_walk( $reviews, function( &$review ) { |
43 | - unset( $review['@context'] ); |
|
44 | - unset( $review['itemReviewed'] ); |
|
43 | + unset($review['@context']); |
|
44 | + unset($review['itemReviewed']); |
|
45 | 45 | }); |
46 | 46 | $schema['review'] = $reviews; |
47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function buildSummary( $args = null ) |
56 | 56 | { |
57 | - if( is_array( $args )) { |
|
57 | + if( is_array( $args ) ) { |
|
58 | 58 | $this->args = $args; |
59 | 59 | } |
60 | 60 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | $schema = method_exists( $this, $buildSummary ) |
63 | 63 | ? $this->$buildSummary() |
64 | 64 | : $this->buildSummaryForCustom(); |
65 | - if( !empty( $count )) { |
|
65 | + if( !empty($count) ) { |
|
66 | 66 | $schema->aggregateRating( |
67 | 67 | $this->getSchemaType( 'AggregateRating' ) |
68 | 68 | ->ratingValue( $this->getRatingValue() ) |
69 | 69 | ->reviewCount( $count ) |
70 | - ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class )) |
|
71 | - ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class )) |
|
70 | + ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) ) |
|
71 | + ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) ) |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | $schema = $schema->toArray(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function render() |
82 | 82 | { |
83 | - if( empty( glsr()->schemas ))return; |
|
83 | + if( empty(glsr()->schemas) )return; |
|
84 | 84 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
85 | 85 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
86 | 86 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
87 | - )); |
|
87 | + ) ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $schemas = glsr()->schemas; |
96 | 96 | $schemas[] = $schema; |
97 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
97 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | protected function buildReview( $review ) |
105 | 105 | { |
106 | 106 | $schema = $this->getSchemaType( 'Review' ) |
107 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
107 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
108 | 108 | $schema->name( $review->title ); |
109 | 109 | }) |
110 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
110 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
111 | 111 | $schema->reviewBody( $review->content ); |
112 | 112 | }) |
113 | - ->datePublished(( new DateTime( $review->date ))) |
|
114 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
115 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
116 | - if( !empty( $review->rating )) { |
|
113 | + ->datePublished( (new DateTime( $review->date )) ) |
|
114 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
115 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
116 | + if( !empty($review->rating) ) { |
|
117 | 117 | $schema->reviewRating( |
118 | 118 | $this->getSchemaType( 'Rating' ) |
119 | 119 | ->ratingValue( $review->rating ) |
120 | - ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class )) |
|
121 | - ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class )) |
|
120 | + ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) ) |
|
121 | + ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) ) |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | foreach( $values as $value ) { |
134 | 134 | $option = $this->getSchemaOptionValue( $value ); |
135 | - if( empty( $option ))continue; |
|
135 | + if( empty($option) )continue; |
|
136 | 136 | $schema->$value( $option ); |
137 | 137 | } |
138 | 138 | return $schema; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
147 | 147 | 'description', 'image', 'name', 'url', |
148 | - ]); |
|
148 | + ] ); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
157 | 157 | 'address', 'priceRange', 'telephone', |
158 | - ]); |
|
158 | + ] ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' ); |
167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [ |
168 | 168 | 'highPrice', 'lowPrice', 'price', 'priceCurrency', |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | return $this->buildSummaryForCustom() |
171 | - ->doIf( !empty( $offers->getProperties() ), function( $schema ) use( $offers ) { |
|
171 | + ->doIf( !empty($offers->getProperties()), function( $schema ) use($offers) { |
|
172 | 172 | $schema->offers( $offers ); |
173 | 173 | }) |
174 | 174 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function getRatingCounts() |
181 | 181 | { |
182 | - if( !isset( $this->ratingCounts )) { |
|
182 | + if( !isset($this->ratingCounts) ) { |
|
183 | 183 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args ); |
184 | 184 | } |
185 | 185 | return $this->ratingCounts; |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | protected function getSchemaOption( $option, $fallback ) |
202 | 202 | { |
203 | 203 | $option = strtolower( $option ); |
204 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
204 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
205 | 205 | return $schemaOption; |
206 | 206 | } |
207 | 207 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
208 | - if( is_array( $setting )) { |
|
208 | + if( is_array( $setting ) ) { |
|
209 | 209 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
210 | 210 | } |
211 | - return !empty( $setting ) |
|
211 | + return !empty($setting) |
|
212 | 212 | ? $setting |
213 | 213 | : $fallback; |
214 | 214 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $setting = wp_parse_args( $setting, [ |
223 | 223 | 'custom' => '', |
224 | 224 | 'default' => $fallback, |
225 | - ]); |
|
225 | + ] ); |
|
226 | 226 | return $setting['default'] != 'custom' |
227 | 227 | ? $setting['default'] |
228 | 228 | : $setting['custom']; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | if( !is_single() && !is_page() )return; |
243 | 243 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
244 | - if( method_exists( $this, $method )) { |
|
244 | + if( method_exists( $this, $method ) ) { |
|
245 | 245 | return $this->$method(); |
246 | 246 | } |
247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function getSchemaType( $type = null ) |
254 | 254 | { |
255 | - if( !is_string( $type )) { |
|
255 | + if( !is_string( $type ) ) { |
|
256 | 256 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
257 | 257 | } |
258 | 258 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | protected function getThingDescription() |
268 | 268 | { |
269 | 269 | $post = get_post(); |
270 | - if( !( $post instanceof WP_Post )) { |
|
270 | + if( !($post instanceof WP_Post) ) { |
|
271 | 271 | return ''; |
272 | 272 | } |
273 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
274 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
273 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
274 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function __construct( array $values = [] ) |
16 | 16 | { |
17 | 17 | $this->values = $values; |
18 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
18 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __toString() |
35 | 35 | { |
36 | - if( empty( $this->values ))return; |
|
36 | + if( empty($this->values) )return; |
|
37 | 37 | return glsr( Template::class )->build( 'templates/review', [ |
38 | 38 | 'context' => $this->values, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | } |
41 | 41 | } |
@@ -33,7 +33,9 @@ |
||
33 | 33 | */ |
34 | 34 | public function __toString() |
35 | 35 | { |
36 | - if( empty( $this->values ))return; |
|
36 | + if( empty( $this->values )) { |
|
37 | + return; |
|
38 | + } |
|
37 | 39 | return glsr( Template::class )->build( 'templates/review', [ |
38 | 40 | 'context' => $this->values, |
39 | 41 | ]); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->results = $reviews; |
32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function build( array $args = [] ) |
70 | 70 | { |
71 | - if( empty( $this->ID )) { |
|
71 | + if( empty($this->ID) ) { |
|
72 | 72 | return new ReviewHtml; |
73 | 73 | } |
74 | 74 | $partial = glsr( SiteReviewsPartial::class ); |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function offsetGet( $key ) |
94 | 94 | { |
95 | - if( property_exists( $this, $key )) { |
|
95 | + if( property_exists( $this, $key ) ) { |
|
96 | 96 | return $this->$key; |
97 | 97 | } |
98 | - if( array_key_exists( $key, (array)$this->custom )) { |
|
98 | + if( array_key_exists( $key, (array)$this->custom ) ) { |
|
99 | 99 | return $this->custom[$key]; |
100 | 100 | } |
101 | 101 | return null; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function offsetSet( $key, $value ) |
110 | 110 | { |
111 | - if( property_exists( $this, $key )) { |
|
111 | + if( property_exists( $this, $key ) ) { |
|
112 | 112 | $this->$key = $value; |
113 | 113 | return; |
114 | 114 | } |
115 | - if( !is_array( $this->custom )) { |
|
115 | + if( !is_array( $this->custom ) ) { |
|
116 | 116 | $this->custom = array_filter( (array)$this->custom ); |
117 | 117 | } |
118 | 118 | $this->custom[$key] = $value; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | 'review_type' => 'local', |
158 | 158 | ]; |
159 | 159 | $meta = array_filter( |
160 | - array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))), |
|
160 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
161 | 161 | 'strlen' |
162 | 162 | ); |
163 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
163 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
164 | 164 | $this->modified = $this->isModified( $properties ); |
165 | 165 | array_walk( $properties, function( $value, $key ) { |
166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
166 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
167 | 167 | $this->$key = maybe_unserialize( $value ); |
168 | 168 | }); |
169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | protected function setTermIds( WP_Post $post ) |
175 | 175 | { |
176 | 176 | $this->term_ids = []; |
177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
177 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
178 | 178 | foreach( $terms as $term ) { |
179 | 179 | $this->term_ids[] = $term->term_id; |
180 | 180 | } |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct( WP_Post $post ) |
38 | 38 | { |
39 | - if( $post->post_type != Application::POST_TYPE )return; |
|
39 | + if( $post->post_type != Application::POST_TYPE ) { |
|
40 | + return; |
|
41 | + } |
|
40 | 42 | $this->content = $post->post_content; |
41 | 43 | $this->date = $post->post_date; |
42 | 44 | $this->ID = intval( $post->ID ); |
@@ -163,7 +165,9 @@ discard block |
||
163 | 165 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
164 | 166 | $this->modified = $this->isModified( $properties ); |
165 | 167 | array_walk( $properties, function( $value, $key ) { |
166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
168 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
169 | + return; |
|
170 | + } |
|
167 | 171 | $this->$key = maybe_unserialize( $value ); |
168 | 172 | }); |
169 | 173 | } |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | protected function setTermIds( WP_Post $post ) |
175 | 179 | { |
176 | 180 | $this->term_ids = []; |
177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
181 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
182 | + return; |
|
183 | + } |
|
178 | 184 | foreach( $terms as $term ) { |
179 | 185 | $this->term_ids[] = $term->term_id; |
180 | 186 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function routerChangeStatus( array $request ) |
24 | 24 | { |
25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | public function routerClearConsole() |
32 | 32 | { |
33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
34 | - wp_send_json_success([ |
|
34 | + wp_send_json_success( [ |
|
35 | 35 | 'console' => glsr( Console::class )->get(), |
36 | 36 | 'notices' => glsr( Notice::class )->get(), |
37 | - ]); |
|
37 | + ] ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | public function routerCountReviews() |
44 | 44 | { |
45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
46 | - wp_send_json_success([ |
|
46 | + wp_send_json_success( [ |
|
47 | 47 | 'notices' => glsr( Notice::class )->get(), |
48 | - ]); |
|
48 | + ] ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | $shortcode = $request['shortcode']; |
57 | 57 | $response = false; |
58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
60 | - if( !empty( $data['errors'] )) { |
|
60 | + if( !empty($data['errors']) ) { |
|
61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
62 | 62 | } |
63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | public function routerFetchConsole() |
78 | 78 | { |
79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
80 | - wp_send_json_success([ |
|
80 | + wp_send_json_success( [ |
|
81 | 81 | 'console' => glsr( Console::class )->get(), |
82 | 82 | 'notices' => glsr( Notice::class )->get(), |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | public function routerSearchPosts( array $request ) |
90 | 90 | { |
91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
92 | - wp_send_json_success([ |
|
92 | + wp_send_json_success( [ |
|
93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
94 | 94 | 'items' => $results, |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function routerSearchTranslations( array $request ) |
102 | 102 | { |
103 | - if( empty( $request['exclude'] )) { |
|
103 | + if( empty($request['exclude']) ) { |
|
104 | 104 | $request['exclude'] = []; |
105 | 105 | } |
106 | 106 | $results = glsr( Translation::class ) |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | ->exclude() |
109 | 109 | ->exclude( $request['exclude'] ) |
110 | 110 | ->renderResults(); |
111 | - wp_send_json_success([ |
|
111 | + wp_send_json_success( [ |
|
112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
113 | 113 | 'items' => $results, |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function routerSubmitReview( array $request ) |
121 | 121 | { |
122 | 122 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
123 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
123 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
124 | 124 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
125 | 125 | $data = [ |
126 | 126 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function routerTogglePinned( array $request ) |
142 | 142 | { |
143 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
144 | - wp_send_json_success([ |
|
143 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
144 | + wp_send_json_success( [ |
|
145 | 145 | 'notices' => glsr( Notice::class )->get(), |
146 | 146 | 'pinned' => $isPinned, |
147 | - ]); |
|
147 | + ] ); |
|
148 | 148 | } |
149 | 149 | } |