@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] ); |
36 | - $this->email = count( array_intersect( ['admin', 'custom'], $types )) > 0; |
|
36 | + $this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0; |
|
37 | 37 | $this->slack = in_array( 'slack', $types ); |
38 | 38 | $this->types = $types; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty($this->types) )return; |
|
47 | 47 | $this->review = $review; |
48 | 48 | $args = [ |
49 | 49 | 'link' => $this->getLink(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function buildEmail( array $args ) |
60 | 60 | { |
61 | - return glsr( Email::class )->compose([ |
|
61 | + return glsr( Email::class )->compose( [ |
|
62 | 62 | 'to' => $this->getEmailAddresses(), |
63 | 63 | 'subject' => $args['title'], |
64 | 64 | 'template' => 'email-notification', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'review_rating' => $this->review->rating, |
72 | 72 | 'review_title' => $this->review->title, |
73 | 73 | ], |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'button_url' => $args['link'], |
84 | 84 | 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
85 | 85 | 'pretext' => $args['title'], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | protected function getEmailAddresses() |
93 | 93 | { |
94 | 94 | $emails = []; |
95 | - if( in_array( 'admin', $this->types )) { |
|
95 | + if( in_array( 'admin', $this->types ) ) { |
|
96 | 96 | $emails[] = get_option( 'admin_email' ); |
97 | 97 | } |
98 | - if( in_array( 'author', $this->types )) { |
|
99 | - $assignedPost = get_post( intval( $this->review->assigned_to )); |
|
98 | + if( in_array( 'author', $this->types ) ) { |
|
99 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
100 | 100 | if( $assignedPost instanceof WP_Post ) { |
101 | 101 | $this->email = true; |
102 | - $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author )); |
|
102 | + $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) ); |
|
103 | 103 | } |
104 | 104 | } |
105 | - if( in_array( 'custom', $this->types )) { |
|
105 | + if( in_array( 'custom', $this->types ) ) { |
|
106 | 106 | $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
107 | 107 | $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails ); |
108 | 108 | $customEmails = explode( ',', $customEmails ); |
109 | 109 | $emails = array_merge( $emails, $customEmails ); |
110 | 110 | } |
111 | - $emails = array_filter( array_keys( array_flip( $emails ))); |
|
111 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
112 | 112 | return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
113 | 113 | } |
114 | 114 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getTitle() |
127 | 127 | { |
128 | - $assignedTitle = get_the_title( intval( $this->review->assigned_to )); |
|
128 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
129 | 129 | $title = _nx( |
130 | 130 | 'New %s-star review', |
131 | 131 | 'New %s-star review of: %s', |
132 | - intval( empty( $assignedTitle )), |
|
132 | + intval( empty($assignedTitle) ), |
|
133 | 133 | 'This string differs depending on whether or not the review has been assigned to a post.', |
134 | 134 | 'site-reviews' |
135 | 135 | ); |
136 | 136 | $title = sprintf( '[%s] %s', |
137 | - wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ), |
|
137 | + wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ), |
|
138 | 138 | sprintf( $title, $this->review->rating, $assignedTitle ) |
139 | 139 | ); |
140 | 140 | return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $email = $this->buildEmail( $args ); |
149 | 149 | if( !$this->email )return; |
150 | - if( empty( $email->to )) { |
|
150 | + if( empty($email->to) ) { |
|
151 | 151 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 152 | return; |
153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | if( !$this->slack )return; |
165 | 165 | $notification = $this->buildSlackNotification( $args ); |
166 | 166 | $result = $notification->send(); |
167 | - if( is_wp_error( $result )) { |
|
167 | + if( is_wp_error( $result ) ) { |
|
168 | 168 | $notification->review = null; |
169 | 169 | glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
170 | 170 | } |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty( $this->types )) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | $this->review = $review; |
48 | 50 | $args = [ |
49 | 51 | 'link' => $this->getLink(), |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | protected function sendToEmail( array $args ) |
147 | 149 | { |
148 | 150 | $email = $this->buildEmail( $args ); |
149 | - if( !$this->email )return; |
|
151 | + if( !$this->email ) { |
|
152 | + return; |
|
153 | + } |
|
150 | 154 | if( empty( $email->to )) { |
151 | 155 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
161 | 165 | */ |
162 | 166 | protected function sendToSlack( array $args ) |
163 | 167 | { |
164 | - if( !$this->slack )return; |
|
168 | + if( !$this->slack ) { |
|
169 | + return; |
|
170 | + } |
|
165 | 171 | $notification = $this->buildSlackNotification( $args ); |
166 | 172 | $result = $notification->send(); |
167 | 173 | if( is_wp_error( $result )) { |
@@ -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,12 +132,12 @@ 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 = isset( $request['excluded'] ) |
|
137 | + $excluded = isset($request['excluded']) |
|
138 | 138 | ? explode( ',', $request['excluded'] ) |
139 | 139 | : []; |
140 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
140 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $rules = $this->getValidationRules( $request ); |
149 | 149 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
150 | - if( empty( $errors )) { |
|
150 | + if( empty($errors) ) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | $this->setSessionValues( 'errors', $errors ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
165 | 165 | { |
166 | 166 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
167 | - if( !empty( $loggedMessage )) { |
|
167 | + if( !empty($loggedMessage) ) { |
|
168 | 168 | glsr_log()->warning( $loggedMessage ); |
169 | 169 | glsr_log()->warning( $this->request ); |
170 | 170 | } |
@@ -175,8 +175,8 @@ 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) )return; |
|
179 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
180 | 180 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 181 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 182 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function validateBlacklist() |
188 | 188 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
189 | + if( !empty($this->error) )return; |
|
190 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
191 | 191 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 192 | if( $blacklistAction == 'reject' ) { |
193 | 193 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function validateCustom() |
204 | 204 | { |
205 | - if( !empty( $this->error ))return; |
|
205 | + if( !empty($this->error) )return; |
|
206 | 206 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | 207 | if( $validated === true )return; |
208 | 208 | $this->setSessionValues( 'errors', [] ); |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function validateHoneyPot() |
219 | 219 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
220 | + if( !empty($this->error) )return; |
|
221 | + if( empty($this->request['gotcha']) )return; |
|
222 | 222 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 223 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 224 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function validateRecaptcha() |
230 | 230 | { |
231 | - if( !empty( $this->error ))return; |
|
231 | + if( !empty($this->error) )return; |
|
232 | 232 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
233 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
234 | 234 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 235 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 236 | $this->recaptchaIsUnset = true; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function validateRequest( array $request ) |
252 | 252 | { |
253 | - if( !$this->isRequestValid( $request )) { |
|
253 | + if( !$this->isRequestValid( $request ) ) { |
|
254 | 254 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
255 | 255 | return $request; |
256 | 256 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function callbackRegisterSettings( $input ) |
19 | 19 | { |
20 | - if( !is_array( $input )) { |
|
20 | + if( !is_array( $input ) ) { |
|
21 | 21 | $input = ['settings' => []]; |
22 | 22 | } |
23 | 23 | if( key( $input ) == 'settings' ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $options = $this->sanitizeSubmissions( $input, $options ); |
27 | 27 | $options = $this->sanitizeTranslations( $input, $options ); |
28 | 28 | if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
29 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
29 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
30 | 30 | } |
31 | 31 | return $options; |
32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
44 | - ]); |
|
44 | + ] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if( trim( $inputForm['notification_message'] ) == '' ) { |
57 | 57 | $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message']; |
58 | 58 | } |
59 | - $options['settings']['general']['notifications'] = isset( $inputForm['notifications'] ) |
|
59 | + $options['settings']['general']['notifications'] = isset($inputForm['notifications']) |
|
60 | 60 | ? $inputForm['notifications'] |
61 | 61 | : []; |
62 | 62 | return $options; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function sanitizeSubmissions( array $input, array $options ) |
69 | 69 | { |
70 | 70 | $inputForm = $input['settings']['submissions']; |
71 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
71 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
72 | 72 | ? $inputForm['required'] |
73 | 73 | : []; |
74 | 74 | return $options; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected function sanitizeTranslations( array $input, array $options ) |
81 | 81 | { |
82 | - if( isset( $input['settings']['strings'] )) { |
|
83 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
82 | + if( isset($input['settings']['strings']) ) { |
|
83 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
84 | 84 | $allowedTags = [ |
85 | 85 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
86 | 86 | 'span' => ['class' => []], |
87 | 87 | ]; |
88 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
89 | - if( isset( $string['s2'] )) { |
|
88 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
89 | + if( isset($string['s2']) ) { |
|
90 | 90 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
91 | 91 | } |
92 | - if( isset( $string['p2'] )) { |
|
92 | + if( isset($string['p2']) ) { |
|
93 | 93 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
94 | 94 | } |
95 | 95 | }); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | protected function isPolylangActiveAndSupported() |
104 | 104 | { |
105 | 105 | if( !glsr( Polylang::class )->isActive() ) { |
106 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
106 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | else if( !glsr( Polylang::class )->isSupported() ) { |
110 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
110 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | return true; |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | public function __construct( $input ) |
32 | 32 | { |
33 | 33 | $this->request = $input; |
34 | - $this->ajax_request = isset( $input['_ajax_request'] ); |
|
34 | + $this->ajax_request = isset($input['_ajax_request']); |
|
35 | 35 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
36 | - $this->author = sanitize_text_field( $this->getUser( 'name' )); |
|
36 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
37 | 37 | $this->avatar = $this->getAvatar(); |
38 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
39 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
40 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
38 | + $this->blacklisted = isset($input['blacklisted']); |
|
39 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
40 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
41 | 41 | $this->custom = $this->getCustom(); |
42 | 42 | $this->date = $this->getDate( 'date' ); |
43 | - $this->email = sanitize_email( $this->getUser( 'email' )); |
|
44 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
43 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
44 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
45 | 45 | $this->ip_address = $this->get( 'ip_address' ); |
46 | - $this->post_id = intval( $this->get( '_post_id' )); |
|
47 | - $this->rating = intval( $this->get( 'rating' )); |
|
46 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
47 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
48 | 48 | $this->referer = $this->get( '_referer' ); |
49 | - $this->response = sanitize_textarea_field( $this->get( 'response' )); |
|
50 | - $this->terms = !empty( $input['terms'] ); |
|
51 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
52 | - $this->url = esc_url_raw( $this->get( 'url' )); |
|
49 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
50 | + $this->terms = !empty($input['terms']); |
|
51 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
52 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function get( $key ) |
60 | 60 | { |
61 | - return isset( $this->request[$key] ) |
|
61 | + return isset($this->request[$key]) |
|
62 | 62 | ? (string)$this->request[$key] |
63 | 63 | : ''; |
64 | 64 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $avatar = $this->get( 'avatar' ); |
72 | 72 | return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED ) |
73 | - ? (string)get_avatar_url( $this->get( 'email' )) |
|
73 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
74 | 74 | : $avatar; |
75 | 75 | } |
76 | 76 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
88 | 88 | $custom = $this->request; |
89 | 89 | foreach( $unset as $value ) { |
90 | - unset( $custom[$value] ); |
|
90 | + unset($custom[$value]); |
|
91 | 91 | } |
92 | 92 | return $custom; |
93 | 93 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function getDate( $key ) |
100 | 100 | { |
101 | - $date = strtotime( $this->get( $key )); |
|
101 | + $date = strtotime( $this->get( $key ) ); |
|
102 | 102 | if( $date === false ) { |
103 | 103 | $date = time(); |
104 | 104 | } |
105 | - return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date )); |
|
105 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | protected function getUser( $key ) |
113 | 113 | { |
114 | 114 | $value = $this->get( $key ); |
115 | - if( empty( $value )) { |
|
115 | + if( empty($value) ) { |
|
116 | 116 | $user = wp_get_current_user(); |
117 | 117 | $userValues = [ |
118 | 118 | 'email' => 'user_email', |
119 | 119 | 'name' => 'display_name', |
120 | 120 | ]; |
121 | - if( $user->exists() && array_key_exists( $key, $userValues )) { |
|
121 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
122 | 122 | return $user->{$userValues[$key]}; |
123 | 123 | } |
124 | 124 | } |
@@ -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 = 'static::'.$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 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function hasPermission() |
135 | 135 | { |
136 | 136 | $isAdmin = $this->isAdmin(); |
137 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
137 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
191 | 191 | $this->reviewTypes = wp_parse_args( $types, [ |
192 | 192 | 'local' => __( 'Local', 'site-reviews' ), |
193 | - ]); |
|
193 | + ] ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
203 | 203 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
204 | - if( !file_exists( $file )) { |
|
204 | + if( !file_exists( $file ) ) { |
|
205 | 205 | glsr_log()->error( 'File not found: '.$file ); |
206 | 206 | return; |
207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function scheduleCronJob() |
217 | 217 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
218 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
219 | 219 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 220 | } |
221 | 221 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function unscheduleCronJob() |
235 | 235 | { |
236 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
236 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function url( $path = '' ) |
267 | 267 | { |
268 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
268 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
269 | 269 | return apply_filters( 'site-reviews/url', $url, $path ); |
270 | 270 | } |
271 | 271 | } |
@@ -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 |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
109 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + if( !array_key_exists( $instance->tag, $this->fields ) )return; |
|
109 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
110 | 110 | $key = $instance->tag.'_'.$args['type']; |
111 | - $classes = !isset( $this->fields[$key] ) |
|
111 | + $classes = !isset($this->fields[$key]) |
|
112 | 112 | ? $this->fields[$instance->tag] |
113 | 113 | : $this->fields[$key]; |
114 | 114 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $args = wp_parse_args( $instance->args, [ |
143 | 143 | 'is_public' => false, |
144 | 144 | 'is_raw' => false, |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
147 | 147 | return false; |
148 | 148 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 97 | } |
94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
105 | 109 | */ |
106 | 110 | protected function customize( Builder $instance ) |
107 | 111 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
113 | + return; |
|
114 | + } |
|
109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
110 | 116 | $key = $instance->tag.'_'.$args['type']; |
111 | 117 | $classes = !isset( $this->fields[$key] ) |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $this->reviews = $reviews; |
31 | 31 | $this->navigation = glsr( Partial::class )->build( 'pagination', [ |
32 | 32 | 'total' => $maxPageCount, |
33 | - ]); |
|
34 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
33 | + ] ); |
|
34 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'navigation' => $this->getNavigation(), |
58 | 58 | 'reviews' => implode( PHP_EOL, $this->reviews ), |
59 | 59 | ], |
60 | - ]); |
|
60 | + ] ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $defaults[] = 'glsr-ajax-pagination'; |
73 | 73 | } |
74 | 74 | $classes = explode( ' ', $this->args['class'] ); |
75 | - $classes = array_unique( array_merge( $defaults, $classes )); |
|
75 | + $classes = array_unique( array_merge( $defaults, $classes ) ); |
|
76 | 76 | return implode( ' ', $classes ); |
77 | 77 | } |
78 | 78 |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | foreach( $this->reviews as $index => $review ) { |
88 | 88 | $renderedReviews[] = glsr( Template::class )->build( 'templates/review', [ |
89 | 89 | 'context' => $this->buildReview( $review )->values, |
90 | - ]); |
|
90 | + ] ); |
|
91 | 91 | } |
92 | 92 | return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args ); |
93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function generateSchema() |
99 | 99 | { |
100 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
100 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
101 | 101 | glsr( Schema::class )->store( |
102 | 102 | glsr( Schema::class )->build( $this->args ) |
103 | 103 | ); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function isHidden( $key, $path = '' ) |
112 | 112 | { |
113 | - $isOptionEnabled = !empty( $path ) |
|
113 | + $isOptionEnabled = !empty($path) |
|
114 | 114 | ? $this->isOptionEnabled( $path ) |
115 | 115 | : true; |
116 | 116 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function buildOptionAssignedTo( $key, $value ) |
125 | 125 | { |
126 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
126 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
127 | 127 | $post = glsr( Polylang::class )->getPost( $value ); |
128 | - if( !( $post instanceof WP_Post ))return; |
|
128 | + if( !($post instanceof WP_Post) )return; |
|
129 | 129 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
130 | 130 | 'href' => get_the_permalink( $post->ID ), |
131 | - ]); |
|
131 | + ] ); |
|
132 | 132 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
133 | 133 | return '<span>'.$assignedTo.'</span>'; |
134 | 134 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function buildOptionAuthor( $key, $value ) |
142 | 142 | { |
143 | - if( $this->isHidden( $key ))return; |
|
143 | + if( $this->isHidden( $key ) )return; |
|
144 | 144 | return '<span>'.$value.'</span>'; |
145 | 145 | } |
146 | 146 | |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function buildOptionAvatar( $key, $value ) |
153 | 153 | { |
154 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
154 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
155 | 155 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
156 | - return glsr( Builder::class )->img([ |
|
156 | + return glsr( Builder::class )->img( [ |
|
157 | 157 | 'height' => $size, |
158 | 158 | 'src' => $this->generateAvatar( $value ), |
159 | 159 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
160 | 160 | 'width' => $size, |
161 | - ]); |
|
161 | + ] ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | protected function buildOptionContent( $key, $value ) |
170 | 170 | { |
171 | 171 | $text = $this->normalizeText( $value ); |
172 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
172 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
173 | 173 | return '<p>'.$text.'</p>'; |
174 | 174 | } |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function buildOptionDate( $key, $value ) |
182 | 182 | { |
183 | - if( $this->isHidden( $key ))return; |
|
183 | + if( $this->isHidden( $key ) )return; |
|
184 | 184 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
185 | 185 | if( $dateFormat == 'relative' ) { |
186 | 186 | $date = glsr( Date::class )->relative( $value ); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $format = $dateFormat == 'custom' |
190 | 190 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
191 | 191 | : (string)get_option( 'date_format' ); |
192 | - $date = date_i18n( $format, strtotime( $value )); |
|
192 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
193 | 193 | } |
194 | 194 | return '<span>'.$date.'</span>'; |
195 | 195 | } |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | */ |
202 | 202 | protected function buildOptionRating( $key, $value ) |
203 | 203 | { |
204 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
204 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
205 | 205 | return glsr( Partial::class )->build( 'star-rating', [ |
206 | 206 | 'rating' => $value, |
207 | - ]); |
|
207 | + ] ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function buildOptionResponse( $key, $value ) |
216 | 216 | { |
217 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
218 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
217 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
218 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
219 | 219 | $text = $this->normalizeText( $value ); |
220 | 220 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
221 | 221 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function buildOptionTitle( $key, $value ) |
232 | 232 | { |
233 | - if( $this->isHidden( $key ))return; |
|
234 | - if( empty( $value )) { |
|
233 | + if( $this->isHidden( $key ) )return; |
|
234 | + if( empty($value) ) { |
|
235 | 235 | $value = __( 'No Title', 'site-reviews' ); |
236 | 236 | } |
237 | 237 | return '<h3>'.$value.'</h3>'; |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | return $avatarUrl; |
248 | 248 | } |
249 | 249 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
250 | - if( empty( $authorIdOrEmail )) { |
|
250 | + if( empty($authorIdOrEmail) ) { |
|
251 | 251 | $authorIdOrEmail = $this->current->email; |
252 | 252 | } |
253 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
253 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
254 | 254 | return $newAvatar; |
255 | 255 | } |
256 | 256 | return $avatarUrl; |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | */ |
263 | 263 | protected function getExcerpt( $text ) |
264 | 264 | { |
265 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
265 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
266 | 266 | $split = extension_loaded( 'intl' ) |
267 | 267 | ? $this->getExcerptIntlSplit( $text, $limit ) |
268 | 268 | : $this->getExcerptSplit( $text, $limit ); |
269 | 269 | $hiddenText = substr( $text, $split ); |
270 | - if( !empty( $hiddenText )) { |
|
270 | + if( !empty($hiddenText) ) { |
|
271 | 271 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
272 | 272 | 'class' => 'glsr-hidden glsr-hidden-text', |
273 | 273 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
274 | 274 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
275 | - ]); |
|
276 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
275 | + ] ); |
|
276 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
277 | 277 | } |
278 | 278 | return nl2br( $text ); |
279 | 279 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
289 | 289 | $words->setText( $text ); |
290 | 290 | $count = 0; |
291 | - foreach( $words as $offset ){ |
|
291 | + foreach( $words as $offset ) { |
|
292 | 292 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
293 | 293 | $count++; |
294 | 294 | if( $count != $limit )continue; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | protected function getExcerptSplit( $text, $limit ) |
306 | 306 | { |
307 | 307 | if( str_word_count( $text, 0 ) > $limit ) { |
308 | - $words = array_keys( str_word_count( $text, 2 )); |
|
308 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
309 | 309 | return $words[$limit]; |
310 | 310 | } |
311 | 311 | return strlen( $text ); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function getOption( $path, $fallback = '' ) |
320 | 320 | { |
321 | - if( array_key_exists( $path, $this->options )) { |
|
321 | + if( array_key_exists( $path, $this->options ) ) { |
|
322 | 322 | return $this->options[$path]; |
323 | 323 | } |
324 | 324 | return $fallback; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function isHiddenOrEmpty( $key, $value ) |
333 | 333 | { |
334 | - return $this->isHidden( $key ) || empty( $value ); |
|
334 | + return $this->isHidden( $key ) || empty($value); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -350,10 +350,10 @@ discard block |
||
350 | 350 | protected function normalizeText( $text ) |
351 | 351 | { |
352 | 352 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
353 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
353 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
354 | 354 | $text = str_replace( ']]>', ']]>', $text ); |
355 | 355 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
356 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
356 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
357 | 357 | $text = $this->getExcerpt( $text ); |
358 | 358 | } |
359 | 359 | return wptexturize( $text ); |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | protected function wrap( array &$renderedFields, Review $review ) |
366 | 366 | { |
367 | 367 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
368 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
368 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
369 | 369 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
370 | - if( empty( $value ))return; |
|
370 | + if( empty($value) )return; |
|
371 | 371 | $value = glsr( Builder::class )->div( $value, [ |
372 | 372 | 'class' => 'glsr-review-'.$key, |
373 | - ]); |
|
373 | + ] ); |
|
374 | 374 | }); |
375 | 375 | } |
376 | 376 | } |
@@ -69,7 +69,9 @@ discard block |
||
69 | 69 | $field = method_exists( $this, $method ) |
70 | 70 | ? $this->$method( $key, $value ) |
71 | 71 | : apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review ); |
72 | - if( $field === false )continue; |
|
72 | + if( $field === false ) { |
|
73 | + continue; |
|
74 | + } |
|
73 | 75 | $renderedFields[$key] = $field; |
74 | 76 | } |
75 | 77 | $this->wrap( $renderedFields, $review ); |
@@ -97,7 +99,9 @@ discard block |
||
97 | 99 | */ |
98 | 100 | public function generateSchema() |
99 | 101 | { |
100 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
102 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
103 | + return; |
|
104 | + } |
|
101 | 105 | glsr( Schema::class )->store( |
102 | 106 | glsr( Schema::class )->build( $this->args ) |
103 | 107 | ); |
@@ -123,9 +127,13 @@ discard block |
||
123 | 127 | */ |
124 | 128 | protected function buildOptionAssignedTo( $key, $value ) |
125 | 129 | { |
126 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
130 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
131 | + return; |
|
132 | + } |
|
127 | 133 | $post = glsr( Polylang::class )->getPost( $value ); |
128 | - if( !( $post instanceof WP_Post ))return; |
|
134 | + if( !( $post instanceof WP_Post )) { |
|
135 | + return; |
|
136 | + } |
|
129 | 137 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
130 | 138 | 'href' => get_the_permalink( $post->ID ), |
131 | 139 | ]); |
@@ -140,7 +148,9 @@ discard block |
||
140 | 148 | */ |
141 | 149 | protected function buildOptionAuthor( $key, $value ) |
142 | 150 | { |
143 | - if( $this->isHidden( $key ))return; |
|
151 | + if( $this->isHidden( $key )) { |
|
152 | + return; |
|
153 | + } |
|
144 | 154 | return '<span>'.$value.'</span>'; |
145 | 155 | } |
146 | 156 | |
@@ -151,7 +161,9 @@ discard block |
||
151 | 161 | */ |
152 | 162 | protected function buildOptionAvatar( $key, $value ) |
153 | 163 | { |
154 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
164 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
165 | + return; |
|
166 | + } |
|
155 | 167 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
156 | 168 | return glsr( Builder::class )->img([ |
157 | 169 | 'height' => $size, |
@@ -169,7 +181,9 @@ discard block |
||
169 | 181 | protected function buildOptionContent( $key, $value ) |
170 | 182 | { |
171 | 183 | $text = $this->normalizeText( $value ); |
172 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
184 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
185 | + return; |
|
186 | + } |
|
173 | 187 | return '<p>'.$text.'</p>'; |
174 | 188 | } |
175 | 189 | |
@@ -180,7 +194,9 @@ discard block |
||
180 | 194 | */ |
181 | 195 | protected function buildOptionDate( $key, $value ) |
182 | 196 | { |
183 | - if( $this->isHidden( $key ))return; |
|
197 | + if( $this->isHidden( $key )) { |
|
198 | + return; |
|
199 | + } |
|
184 | 200 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
185 | 201 | if( $dateFormat == 'relative' ) { |
186 | 202 | $date = glsr( Date::class )->relative( $value ); |
@@ -201,7 +217,9 @@ discard block |
||
201 | 217 | */ |
202 | 218 | protected function buildOptionRating( $key, $value ) |
203 | 219 | { |
204 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
220 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
221 | + return; |
|
222 | + } |
|
205 | 223 | return glsr( Partial::class )->build( 'star-rating', [ |
206 | 224 | 'rating' => $value, |
207 | 225 | ]); |
@@ -214,7 +232,9 @@ discard block |
||
214 | 232 | */ |
215 | 233 | protected function buildOptionResponse( $key, $value ) |
216 | 234 | { |
217 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
235 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
236 | + return; |
|
237 | + } |
|
218 | 238 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
219 | 239 | $text = $this->normalizeText( $value ); |
220 | 240 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -230,7 +250,9 @@ discard block |
||
230 | 250 | */ |
231 | 251 | protected function buildOptionTitle( $key, $value ) |
232 | 252 | { |
233 | - if( $this->isHidden( $key ))return; |
|
253 | + if( $this->isHidden( $key )) { |
|
254 | + return; |
|
255 | + } |
|
234 | 256 | if( empty( $value )) { |
235 | 257 | $value = __( 'No Title', 'site-reviews' ); |
236 | 258 | } |
@@ -289,9 +311,13 @@ discard block |
||
289 | 311 | $words->setText( $text ); |
290 | 312 | $count = 0; |
291 | 313 | foreach( $words as $offset ){ |
292 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
314 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
315 | + continue; |
|
316 | + } |
|
293 | 317 | $count++; |
294 | - if( $count != $limit )continue; |
|
318 | + if( $count != $limit ) { |
|
319 | + continue; |
|
320 | + } |
|
295 | 321 | return $offset; |
296 | 322 | } |
297 | 323 | return strlen( $text ); |
@@ -367,7 +393,9 @@ discard block |
||
367 | 393 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
368 | 394 | array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
369 | 395 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
370 | - if( empty( $value ))return; |
|
396 | + if( empty( $value )) { |
|
397 | + return; |
|
398 | + } |
|
371 | 399 | $value = glsr( Builder::class )->div( $value, [ |
372 | 400 | 'class' => 'glsr-review-'.$key, |
373 | 401 | ]); |
@@ -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 | ]); |