@@ -35,7 +35,9 @@ |
||
35 | 35 | */ |
36 | 36 | public function compose( Review $review, array $notification ) |
37 | 37 | { |
38 | - if( empty( $this->endpoint ))return; |
|
38 | + if( empty( $this->endpoint )) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
40 | 42 | $this->review = $review; |
41 | 43 | $notification = [ |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function compose( Review $review, array $notification ) |
37 | 37 | { |
38 | - if( empty( $this->endpoint ))return; |
|
38 | + if( empty($this->endpoint) )return; |
|
39 | 39 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
40 | 40 | $this->review = $review; |
41 | 41 | $notification = [ |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function send() |
60 | 60 | { |
61 | - if( empty( $this->endpoint )) { |
|
61 | + if( empty($this->endpoint) ) { |
|
62 | 62 | return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
63 | 63 | } |
64 | 64 | return wp_remote_post( $this->endpoint, [ |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'redirection' => 5, |
71 | 71 | 'sslverify' => false, |
72 | 72 | 'timeout' => 45, |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function buildAuthorField() |
92 | 92 | { |
93 | - $email = !empty( $this->review->email ) |
|
93 | + $email = !empty($this->review->email) |
|
94 | 94 | ? '<'.$this->review->email.'>' |
95 | 95 | : ''; |
96 | 96 | $author = trim( rtrim( $this->review->author ).' '.$email ); |
97 | - return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))]; |
|
97 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function buildContentField() |
104 | 104 | { |
105 | - return !empty( $this->review->content ) |
|
105 | + return !empty($this->review->content) |
|
106 | 106 | ? ['value' => $this->review->content] |
107 | 107 | : []; |
108 | 108 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | protected function buildStarsField() |
128 | 128 | { |
129 | 129 | $solidStars = str_repeat( '★', $this->review->rating ); |
130 | - $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating )); |
|
130 | + $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ) ); |
|
131 | 131 | $stars = $solidStars.$emptyStars; |
132 | 132 | $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, Rating::MAX_RATING ); |
133 | 133 | return ['title' => $stars]; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function buildTitleField() |
140 | 140 | { |
141 | - return !empty( $this->review->title ) |
|
141 | + return !empty($this->review->title) |
|
142 | 142 | ? ['title' => $this->review->title] |
143 | 143 | : []; |
144 | 144 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'response' => $this->buildResponse(), |
66 | 66 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
67 | 67 | ], |
68 | - ]); |
|
68 | + ] ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'context' => [ |
78 | 78 | 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
79 | 79 | ], |
80 | - ]); |
|
80 | + ] ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | protected function buildRecaptcha() |
87 | 87 | { |
88 | 88 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
89 | - return glsr( Builder::class )->div([ |
|
89 | + return glsr( Builder::class )->div( [ |
|
90 | 90 | 'class' => 'glsr-recaptcha-holder', |
91 | 91 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
92 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
92 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
93 | 93 | 'data-size' => 'invisible', |
94 | - ]); |
|
94 | + ] ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function buildResponse() |
101 | 101 | { |
102 | - $classes = !empty( $this->errors ) |
|
102 | + $classes = !empty($this->errors) |
|
103 | 103 | ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
104 | 104 | : ''; |
105 | 105 | return glsr( Template::class )->build( 'templates/form/response', [ |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | 'class' => $classes, |
108 | 108 | 'message' => wpautop( $this->message ), |
109 | 109 | ], |
110 | - 'has_errors' => !empty( $this->errors ), |
|
111 | - ]); |
|
110 | + 'has_errors' => !empty($this->errors), |
|
111 | + ] ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'context' => [ |
121 | 121 | 'text' => __( 'Submit your review', 'site-reviews' ), |
122 | 122 | ], |
123 | - ]); |
|
123 | + ] ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $fields = array_merge( |
140 | 140 | $this->getHiddenFields(), |
141 | 141 | [$this->getHoneypotField()], |
142 | - $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )) |
|
142 | + $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ) |
|
143 | 143 | ); |
144 | 144 | return $fields; |
145 | 145 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function getLoginText() |
151 | 151 | { |
152 | - $loginLink = glsr( Builder::class )->a([ |
|
153 | - 'href' => wp_login_url( strval( get_permalink() )), |
|
152 | + $loginLink = glsr( Builder::class )->a( [ |
|
153 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
154 | 154 | 'text' => __( 'logged in', 'site-reviews' ), |
155 | - ]); |
|
155 | + ] ); |
|
156 | 156 | return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
157 | 157 | } |
158 | 158 | |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | protected function getRegisterText() |
163 | 163 | { |
164 | 164 | if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return; |
165 | - $registerLink = glsr( Builder::class )->a([ |
|
165 | + $registerLink = glsr( Builder::class )->a( [ |
|
166 | 166 | 'href' => wp_registration_url(), |
167 | 167 | 'text' => __( 'register', 'site-reviews' ), |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
170 | 170 | } |
171 | 171 | |
@@ -177,27 +177,27 @@ discard block |
||
177 | 177 | $fields = [[ |
178 | 178 | 'name' => 'action', |
179 | 179 | 'value' => 'submit-review', |
180 | - ],[ |
|
180 | + ], [ |
|
181 | 181 | 'name' => 'assign_to', |
182 | 182 | 'value' => $this->args['assign_to'], |
183 | - ],[ |
|
183 | + ], [ |
|
184 | 184 | 'name' => 'category', |
185 | 185 | 'value' => $this->args['category'], |
186 | - ],[ |
|
186 | + ], [ |
|
187 | 187 | 'name' => 'excluded', |
188 | 188 | 'value' => $this->args['excluded'], // @todo should default to "[]" |
189 | - ],[ |
|
189 | + ], [ |
|
190 | 190 | 'name' => 'form_id', |
191 | 191 | 'value' => $this->args['id'], |
192 | - ],[ |
|
192 | + ], [ |
|
193 | 193 | 'name' => 'nonce', |
194 | 194 | 'value' => wp_create_nonce( 'submit-review' ), |
195 | - ],[ |
|
195 | + ], [ |
|
196 | 196 | 'name' => 'referer', |
197 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
197 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
198 | 198 | ]]; |
199 | 199 | return array_map( function( $field ) { |
200 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
200 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
201 | 201 | }, $fields ); |
202 | 202 | } |
203 | 203 | |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function getHoneypotField() |
208 | 208 | { |
209 | - return new Field([ |
|
209 | + return new Field( [ |
|
210 | 210 | 'name' => 'gotcha', |
211 | 211 | 'type' => 'honeypot', |
212 | - ]); |
|
212 | + ] ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function normalizeFieldErrors( Field &$field ) |
219 | 219 | { |
220 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
220 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
221 | 221 | $field->field['errors'] = $this->errors[$field->field['path']]; |
222 | 222 | } |
223 | 223 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function normalizeFieldRequired( Field &$field ) |
228 | 228 | { |
229 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
229 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
230 | 230 | $field->field['required'] = true; |
231 | 231 | } |
232 | 232 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | */ |
250 | 250 | protected function normalizeFieldValue( Field &$field ) |
251 | 251 | { |
252 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
253 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
252 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
253 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
254 | 254 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
255 | 255 | } |
256 | 256 | else { |
@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function buildRecaptcha() |
87 | 87 | { |
88 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
88 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
89 | + return; |
|
90 | + } |
|
89 | 91 | return glsr( Builder::class )->div([ |
90 | 92 | 'class' => 'glsr-recaptcha-holder', |
91 | 93 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
@@ -161,7 +163,9 @@ discard block |
||
161 | 163 | */ |
162 | 164 | protected function getRegisterText() |
163 | 165 | { |
164 | - if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return; |
|
166 | + if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' ) { |
|
167 | + return; |
|
168 | + } |
|
165 | 169 | $registerLink = glsr( Builder::class )->a([ |
166 | 170 | 'href' => wp_registration_url(), |
167 | 171 | 'text' => __( 'register', 'site-reviews' ), |
@@ -217,7 +221,9 @@ discard block |
||
217 | 221 | */ |
218 | 222 | protected function normalizeFieldErrors( Field &$field ) |
219 | 223 | { |
220 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
224 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
225 | + return; |
|
226 | + } |
|
221 | 227 | $field->field['errors'] = $this->errors[$field->field['path']]; |
222 | 228 | } |
223 | 229 | |
@@ -226,7 +232,9 @@ discard block |
||
226 | 232 | */ |
227 | 233 | protected function normalizeFieldRequired( Field &$field ) |
228 | 234 | { |
229 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
235 | + if( !in_array( $field->field['path'], $this->required )) { |
|
236 | + return; |
|
237 | + } |
|
230 | 238 | $field->field['required'] = true; |
231 | 239 | } |
232 | 240 | |
@@ -249,7 +257,9 @@ discard block |
||
249 | 257 | */ |
250 | 258 | protected function normalizeFieldValue( Field &$field ) |
251 | 259 | { |
252 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
260 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
261 | + return; |
|
262 | + } |
|
253 | 263 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
254 | 264 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
255 | 265 | } |
@@ -3,61 +3,61 @@ |
||
3 | 3 | defined( 'WPINC' ) || die; |
4 | 4 | |
5 | 5 | add_action( 'site-reviews/local/review/submitted', function() { |
6 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
6 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
7 | 7 | glsr_log()->notice( 'The "site-reviews/local/review/submitted/message" hook has been deprecated.' ); |
8 | 8 | } |
9 | 9 | }); |
10 | 10 | |
11 | 11 | add_filter( 'site-reviews/create/review-values', function( $values ) { |
12 | - if( has_filter( 'site-reviews/local/review' )) { |
|
12 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
13 | 13 | glsr_log()->notice( 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.' ); |
14 | 14 | } |
15 | 15 | return $values; |
16 | 16 | }); |
17 | 17 | |
18 | 18 | add_filter( 'site-reviews/get/defaults', function( $defaults ) { |
19 | - if( has_filter( 'site-reviews/addon/defaults' )) { |
|
19 | + if( has_filter( 'site-reviews/addon/defaults' ) ) { |
|
20 | 20 | glsr_log()->notice( 'The "site-reviews/addon/defaults" hook has been deprecated. Please use the "site-reviews/get/defaults" hook instead.' ); |
21 | 21 | } |
22 | 22 | return $defaults; |
23 | 23 | }); |
24 | 24 | |
25 | 25 | add_filter( 'site-reviews/rating/average', function( $average ) { |
26 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
26 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
27 | 27 | glsr_log()->notice( 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.' ); |
28 | 28 | } |
29 | 29 | return $average; |
30 | 30 | }); |
31 | 31 | |
32 | 32 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
33 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
33 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
34 | 34 | glsr_log()->notice( 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.' ); |
35 | 35 | } |
36 | 36 | return $ranking; |
37 | 37 | }); |
38 | 38 | |
39 | 39 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
40 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
40 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
41 | 41 | glsr_log()->notice( 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' ); |
42 | 42 | } |
43 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
43 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
44 | 44 | glsr_log()->notice( 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' ); |
45 | 45 | } |
46 | 46 | return $review; |
47 | 47 | }); |
48 | 48 | |
49 | 49 | add_filter( 'site-reviews/review/build/after', function( $review ) { |
50 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
50 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
51 | 51 | glsr_log()->notice( 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' ); |
52 | 52 | } |
53 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
53 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
54 | 54 | glsr_log()->notice( 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' ); |
55 | 55 | } |
56 | 56 | return $review; |
57 | 57 | }); |
58 | 58 | |
59 | 59 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
60 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
60 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
61 | 61 | glsr_log()->notice( 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.' ); |
62 | 62 | } |
63 | 63 | return $variables; |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | public function fields() |
14 | 14 | { |
15 | 15 | return [[ |
16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
17 | 17 | 'minWidth' => 320, |
18 | 18 | 'type' => 'container', |
19 | - ],[ |
|
19 | + ], [ |
|
20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
21 | 21 | 'name' => 'title', |
22 | 22 | 'tooltip' => esc_attr__( 'Enter a custom shortcode heading.', 'site-reviews' ), |
23 | 23 | 'type' => 'textbox', |
24 | - ],[ |
|
24 | + ], [ |
|
25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
26 | 26 | 'maxLength' => 5, |
27 | 27 | 'name' => 'count', |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | 'text' => '10', |
30 | 30 | 'tooltip' => esc_attr__( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
31 | 31 | 'type' => 'textbox', |
32 | - ],[ |
|
32 | + ], [ |
|
33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
34 | 34 | 'name' => 'rating', |
35 | 35 | 'options' => [ |
36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
41 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
42 | 42 | ], |
43 | 43 | 'tooltip' => esc_attr__( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
44 | 44 | 'type' => 'listbox', |
45 | - ],[ |
|
45 | + ], [ |
|
46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
47 | 47 | 'name' => 'pagination', |
48 | 48 | 'options' => [ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'name' => 'assigned_to', |
61 | 61 | 'tooltip' => esc_attr__( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
62 | 62 | 'type' => 'textbox', |
63 | - ],[ |
|
63 | + ], [ |
|
64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
65 | 65 | 'name' => 'schema', |
66 | 66 | 'options' => [ |
@@ -69,49 +69,49 @@ discard block |
||
69 | 69 | ], |
70 | 70 | 'tooltip' => esc_attr__( 'Rich snippets are disabled by default.', 'site-reviews' ), |
71 | 71 | 'type' => 'listbox', |
72 | - ],[ |
|
72 | + ], [ |
|
73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
74 | 74 | 'name' => 'class', |
75 | 75 | 'tooltip' => esc_attr__( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
76 | 76 | 'type' => 'textbox', |
77 | - ],[ |
|
77 | + ], [ |
|
78 | 78 | 'columns' => 2, |
79 | 79 | 'items' => [[ |
80 | 80 | 'name' => 'hide_assigned_to', |
81 | 81 | 'text' => esc_html__( 'Assigned To', 'site-reviews' ), |
82 | 82 | 'tooltip' => esc_attr__( 'Hide the assigned to link?', 'site-reviews' ), |
83 | 83 | 'type' => 'checkbox', |
84 | - ],[ |
|
84 | + ], [ |
|
85 | 85 | 'name' => 'hide_author', |
86 | 86 | 'text' => esc_html__( 'Author', 'site-reviews' ), |
87 | 87 | 'tooltip' => esc_attr__( 'Hide the review author?', 'site-reviews' ), |
88 | 88 | 'type' => 'checkbox', |
89 | - ],[ |
|
89 | + ], [ |
|
90 | 90 | 'name' => 'hide_avatar', |
91 | 91 | 'text' => esc_html__( 'Avatar', 'site-reviews' ), |
92 | 92 | 'tooltip' => esc_attr__( 'Hide the reviewer avatar if shown?', 'site-reviews' ), |
93 | 93 | 'type' => 'checkbox', |
94 | - ],[ |
|
94 | + ], [ |
|
95 | 95 | 'name' => 'hide_content', |
96 | 96 | 'text' => esc_html__( 'Content', 'site-reviews' ), |
97 | 97 | 'tooltip' => esc_attr__( 'Hide the review content?', 'site-reviews' ), |
98 | 98 | 'type' => 'checkbox', |
99 | - ],[ |
|
99 | + ], [ |
|
100 | 100 | 'name' => 'hide_date', |
101 | 101 | 'text' => esc_html__( 'Date', 'site-reviews' ), |
102 | 102 | 'tooltip' => esc_attr__( 'Hide the review date?', 'site-reviews' ), |
103 | 103 | 'type' => 'checkbox', |
104 | - ],[ |
|
104 | + ], [ |
|
105 | 105 | 'name' => 'hide_rating', |
106 | 106 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
107 | 107 | 'tooltip' => esc_attr__( 'Hide the review rating?', 'site-reviews' ), |
108 | 108 | 'type' => 'checkbox', |
109 | - ],[ |
|
109 | + ], [ |
|
110 | 110 | 'name' => 'hide_response', |
111 | 111 | 'text' => esc_html__( 'Response', 'site-reviews' ), |
112 | 112 | 'tooltip' => esc_attr__( 'Hide the review response?', 'site-reviews' ), |
113 | 113 | 'type' => 'checkbox', |
114 | - ],[ |
|
114 | + ], [ |
|
115 | 115 | 'name' => 'hide_title', |
116 | 116 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
117 | 117 | 'tooltip' => esc_attr__( 'Hide the review title?', 'site-reviews' ), |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
122 | 122 | 'spacing' => 5, |
123 | 123 | 'type' => 'container', |
124 | - ],[ |
|
124 | + ], [ |
|
125 | 125 | 'hidden' => true, |
126 | 126 | 'name' => 'id', |
127 | 127 | 'type' => 'textbox', |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function getTerms() |
135 | 135 | { |
136 | 136 | $terms = glsr( Database::class )->getTerms(); |
137 | - if( empty( $terms )) { |
|
137 | + if( empty($terms) ) { |
|
138 | 138 | return []; |
139 | 139 | } |
140 | 140 | return [ |
@@ -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 )) { |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function isBlacklisted( array $review ) |
13 | 13 | { |
14 | - $target = implode( "\n", array_filter([ |
|
14 | + $target = implode( "\n", array_filter( [ |
|
15 | 15 | $review['name'], |
16 | 16 | $review['content'], |
17 | 17 | $review['email'], |
18 | 18 | $review['ip_address'], |
19 | 19 | $review['title'], |
20 | - ])); |
|
20 | + ] ) ); |
|
21 | 21 | return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted', |
22 | 22 | $this->check( $target ), |
23 | 23 | $review |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function check( $target ) |
32 | 32 | { |
33 | - $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' )); |
|
34 | - if( empty( $blacklist )) { |
|
33 | + $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) ); |
|
34 | + if( empty($blacklist) ) { |
|
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | $lines = explode( "\n", $blacklist ); |
38 | 38 | foreach( (array)$lines as $line ) { |
39 | 39 | $line = trim( $line ); |
40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
41 | - $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
|
42 | - if( preg_match( $pattern, $target )) { |
|
40 | + if( empty($line) || 256 < strlen( $line ) )continue; |
|
41 | + $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) ); |
|
42 | + if( preg_match( $pattern, $target ) ) { |
|
43 | 43 | return true; |
44 | 44 | } |
45 | 45 | } |
@@ -37,7 +37,9 @@ |
||
37 | 37 | $lines = explode( "\n", $blacklist ); |
38 | 38 | foreach( (array)$lines as $line ) { |
39 | 39 | $line = trim( $line ); |
40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
40 | + if( empty( $line ) || 256 < strlen( $line )) { |
|
41 | + continue; |
|
42 | + } |
|
41 | 43 | $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
42 | 44 | if( preg_match( $pattern, $target )) { |
43 | 45 | return true; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | public function __get( $key ) |
21 | 21 | { |
22 | - if( array_key_exists( $key, $this->values )) { |
|
22 | + if( array_key_exists( $key, $this->values ) ) { |
|
23 | 23 | return $this->values[$key]; |
24 | 24 | } |
25 | 25 | return ''; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'navigation' => $navigation, |
57 | 57 | ], |
58 | 58 | 'reviews' => $this->buildReviews(), |
59 | - ]); |
|
59 | + ] ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $reviewValues = []; |
83 | 83 | foreach( $review as $key => $value ) { |
84 | 84 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
85 | - if( !method_exists( $this, $method ))continue; |
|
85 | + if( !method_exists( $this, $method ) )continue; |
|
86 | 86 | $reviewValues[$key] = $this->$method( $key, $value ); |
87 | 87 | } |
88 | 88 | $reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues ); |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function buildOptionAssignedTo( $key, $value ) |
98 | 98 | { |
99 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
100 | - $post = get_post( intval( $value )); |
|
101 | - if( !( $post instanceof WP_Post ))return; |
|
99 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
100 | + $post = get_post( intval( $value ) ); |
|
101 | + if( !($post instanceof WP_Post) )return; |
|
102 | 102 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
103 | 103 | 'href' => get_the_permalink( $post->ID ), |
104 | - ]); |
|
104 | + ] ); |
|
105 | 105 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
106 | 106 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function buildOptionAuthor( $key, $value ) |
115 | 115 | { |
116 | - if( $this->isHidden( $key ))return; |
|
116 | + if( $this->isHidden( $key ) )return; |
|
117 | 117 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars' ) |
118 | 118 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
119 | 119 | : ''; |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildOptionAvatar( $key, $value ) |
129 | 129 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
130 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
131 | 131 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
132 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
132 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
133 | 133 | 'src' => $this->generateAvatar( $value ), |
134 | 134 | 'height' => $size, |
135 | 135 | 'width' => $size, |
136 | - ])); |
|
136 | + ] ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | protected function buildOptionContent( $key, $value ) |
145 | 145 | { |
146 | 146 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
147 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
148 | 148 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 149 | } |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function buildOptionDate( $key, $value ) |
157 | 157 | { |
158 | - if( $this->isHidden( $key ))return; |
|
158 | + if( $this->isHidden( $key ) )return; |
|
159 | 159 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 160 | if( $dateFormat == 'relative' ) { |
161 | 161 | $date = glsr( Date::class )->relative( $value ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $format = $dateFormat == 'custom' |
165 | 165 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
166 | 166 | : (string)get_option( 'date_format' ); |
167 | - $date = date_i18n( $format, strtotime( $value )); |
|
167 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
168 | 168 | } |
169 | 169 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
170 | 170 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function buildOptionRating( $key, $value ) |
178 | 178 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
179 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
180 | 180 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
181 | 181 | 'rating' => $value, |
182 | - ]); |
|
182 | + ] ); |
|
183 | 183 | return $this->wrap( $key, $rating ); |
184 | 184 | } |
185 | 185 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | protected function buildOptionResponse( $key, $value ) |
192 | 192 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
194 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
194 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
195 | 195 | $text = $this->normalizeText( $value ); |
196 | 196 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
197 | 197 | return $this->wrap( $key, |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function buildOptionTitle( $key, $value ) |
209 | 209 | { |
210 | - if( $this->isHidden( $key ))return; |
|
211 | - if( empty( $value )) { |
|
210 | + if( $this->isHidden( $key ) )return; |
|
211 | + if( empty($value) ) { |
|
212 | 212 | $value = __( 'No Title', 'site-reviews' ); |
213 | 213 | } |
214 | 214 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | return $avatarUrl; |
226 | 226 | } |
227 | 227 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
228 | - if( empty( $authorIdOrEmail )) { |
|
228 | + if( empty($authorIdOrEmail) ) { |
|
229 | 229 | $authorIdOrEmail = $review->email; |
230 | 230 | } |
231 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
231 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
232 | 232 | return $newAvatar; |
233 | 233 | } |
234 | 234 | return $avatarUrl; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function generateSchema() |
241 | 241 | { |
242 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
242 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
243 | 243 | glsr( Schema::class )->store( |
244 | 244 | glsr( Schema::class )->build( $this->args ) |
245 | 245 | ); |
@@ -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 isHidden( $key, $path = '' ) |
333 | 333 | { |
334 | - $isOptionEnabled = !empty( $path ) |
|
334 | + $isOptionEnabled = !empty($path) |
|
335 | 335 | ? $this->isOptionEnabled( $path ) |
336 | 336 | : true; |
337 | 337 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | protected function isHiddenOrEmpty( $key, $value ) |
346 | 346 | { |
347 | - return $this->isHidden( $key ) || empty( $value ); |
|
347 | + return $this->isHidden( $key ) || empty($value); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | protected function normalizeText( $text ) |
364 | 364 | { |
365 | 365 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
366 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
366 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
367 | 367 | $text = str_replace( ']]>', ']]>', $text ); |
368 | 368 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
369 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
369 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
370 | 370 | $text = $this->getExcerpt( $text ); |
371 | 371 | } |
372 | 372 | return wptexturize( $text ); |
@@ -381,6 +381,6 @@ discard block |
||
381 | 381 | { |
382 | 382 | return glsr( Builder::class )->div( $value, [ |
383 | 383 | 'class' => 'glsr-review-'.$key, |
384 | - ]); |
|
384 | + ] ); |
|
385 | 385 | } |
386 | 386 | } |
@@ -82,7 +82,9 @@ discard block |
||
82 | 82 | $reviewValues = []; |
83 | 83 | foreach( $review as $key => $value ) { |
84 | 84 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
85 | - if( !method_exists( $this, $method ))continue; |
|
85 | + if( !method_exists( $this, $method )) { |
|
86 | + continue; |
|
87 | + } |
|
86 | 88 | $reviewValues[$key] = $this->$method( $key, $value ); |
87 | 89 | } |
88 | 90 | $reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues ); |
@@ -96,9 +98,13 @@ discard block |
||
96 | 98 | */ |
97 | 99 | protected function buildOptionAssignedTo( $key, $value ) |
98 | 100 | { |
99 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
101 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
102 | + return; |
|
103 | + } |
|
100 | 104 | $post = get_post( intval( $value )); |
101 | - if( !( $post instanceof WP_Post ))return; |
|
105 | + if( !( $post instanceof WP_Post )) { |
|
106 | + return; |
|
107 | + } |
|
102 | 108 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
103 | 109 | 'href' => get_the_permalink( $post->ID ), |
104 | 110 | ]); |
@@ -113,7 +119,9 @@ discard block |
||
113 | 119 | */ |
114 | 120 | protected function buildOptionAuthor( $key, $value ) |
115 | 121 | { |
116 | - if( $this->isHidden( $key ))return; |
|
122 | + if( $this->isHidden( $key )) { |
|
123 | + return; |
|
124 | + } |
|
117 | 125 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars' ) |
118 | 126 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
119 | 127 | : ''; |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | */ |
128 | 136 | protected function buildOptionAvatar( $key, $value ) |
129 | 137 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
138 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
139 | + return; |
|
140 | + } |
|
131 | 141 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
132 | 142 | return $this->wrap( $key, glsr( Builder::class )->img([ |
133 | 143 | 'src' => $this->generateAvatar( $value ), |
@@ -144,7 +154,9 @@ discard block |
||
144 | 154 | protected function buildOptionContent( $key, $value ) |
145 | 155 | { |
146 | 156 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
157 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
158 | + return; |
|
159 | + } |
|
148 | 160 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 161 | } |
150 | 162 | |
@@ -155,7 +167,9 @@ discard block |
||
155 | 167 | */ |
156 | 168 | protected function buildOptionDate( $key, $value ) |
157 | 169 | { |
158 | - if( $this->isHidden( $key ))return; |
|
170 | + if( $this->isHidden( $key )) { |
|
171 | + return; |
|
172 | + } |
|
159 | 173 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 174 | if( $dateFormat == 'relative' ) { |
161 | 175 | $date = glsr( Date::class )->relative( $value ); |
@@ -176,7 +190,9 @@ discard block |
||
176 | 190 | */ |
177 | 191 | protected function buildOptionRating( $key, $value ) |
178 | 192 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
194 | + return; |
|
195 | + } |
|
180 | 196 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
181 | 197 | 'rating' => $value, |
182 | 198 | ]); |
@@ -190,7 +206,9 @@ discard block |
||
190 | 206 | */ |
191 | 207 | protected function buildOptionResponse( $key, $value ) |
192 | 208 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
209 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
210 | + return; |
|
211 | + } |
|
194 | 212 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
195 | 213 | $text = $this->normalizeText( $value ); |
196 | 214 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -207,7 +225,9 @@ discard block |
||
207 | 225 | */ |
208 | 226 | protected function buildOptionTitle( $key, $value ) |
209 | 227 | { |
210 | - if( $this->isHidden( $key ))return; |
|
228 | + if( $this->isHidden( $key )) { |
|
229 | + return; |
|
230 | + } |
|
211 | 231 | if( empty( $value )) { |
212 | 232 | $value = __( 'No Title', 'site-reviews' ); |
213 | 233 | } |
@@ -239,7 +259,9 @@ discard block |
||
239 | 259 | */ |
240 | 260 | protected function generateSchema() |
241 | 261 | { |
242 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
262 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
263 | + return; |
|
264 | + } |
|
243 | 265 | glsr( Schema::class )->store( |
244 | 266 | glsr( Schema::class )->build( $this->args ) |
245 | 267 | ); |
@@ -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 ); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | 'avatar' => '', |
18 | 18 | 'content' => '', |
19 | 19 | 'custom' => '', |
20 | - 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' )), |
|
20 | + 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ), |
|
21 | 21 | 'email' => '', |
22 | 22 | 'ip_address' => '', |
23 | 23 | 'pinned' => false, |