@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | { |
26 | 26 | sort( $termIds ); |
27 | 27 | sort( $oldTermIds ); |
28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
29 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ) )return; |
|
29 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
30 | 30 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
31 | - if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
|
31 | + if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms ) ) { |
|
32 | 32 | glsr( CountsManager::class )->decreaseTermCounts( $review ); |
33 | 33 | } |
34 | - if( $review->term_ids = array_diff( $termIds, $ignoredTerms )) { |
|
34 | + if( $review->term_ids = array_diff( $termIds, $ignoredTerms ) ) { |
|
35 | 35 | glsr( CountsManager::class )->increaseTermCounts( $review ); |
36 | 36 | } |
37 | 37 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function onAfterCreate( $postData, $meta, $postId ) |
47 | 47 | { |
48 | - if( !$this->isReviewPostId( $postId ))return; |
|
49 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
48 | + if( !$this->isReviewPostId( $postId ) )return; |
|
49 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
50 | 50 | glsr( CountsManager::class )->increase( $review ); |
51 | 51 | } |
52 | 52 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function onBeforeDelete( $postId ) |
59 | 59 | { |
60 | - if( !$this->isReviewPostId( $postId ))return; |
|
61 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
60 | + if( !$this->isReviewPostId( $postId ) )return; |
|
61 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
62 | 62 | glsr( CountsManager::class )->decrease( $review ); |
63 | 63 | } |
64 | 64 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if( !$this->isReviewPostId( $postId ) |
76 | 76 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
77 | 77 | )return; |
78 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
78 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
79 | 79 | if( $review->$metaKey == $metaValue )return; |
80 | 80 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
81 | 81 | call_user_func( [$this, $method], $review, $metaValue ); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
124 | 124 | { |
125 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
126 | - $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
|
125 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ) )return; |
|
126 | + $review = glsr( ReviewManager::class )->single( get_post( $post->ID ) ); |
|
127 | 127 | if( $post->post_status == 'publish' ) { |
128 | 128 | glsr( CountsManager::class )->increase( $review ); |
129 | 129 | } |
@@ -12,12 +12,12 @@ |
||
12 | 12 | */ |
13 | 13 | public function build( array $args = [] ) |
14 | 14 | { |
15 | - require_once( ABSPATH.'wp-admin/includes/template.php' ); |
|
15 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
16 | 16 | ob_start(); |
17 | 17 | wp_star_rating( $args ); |
18 | 18 | $stars = ob_get_clean(); |
19 | 19 | return glsr( Builder::class )->div( $stars, [ |
20 | 20 | 'class' => 'glsr-stars', |
21 | - ]); |
|
21 | + ] ); |
|
22 | 22 | } |
23 | 23 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if( strpos( $message, '%s' ) === false ) { |
29 | 29 | return $message; |
30 | 30 | } |
31 | - return preg_replace_callback( '/(%s)/', function() use( &$parameters ) { |
|
31 | + return preg_replace_callback( '/(%s)/', function() use(&$parameters) { |
|
32 | 32 | foreach( $parameters as $key => $value ) { |
33 | 33 | return array_shift( $parameters ); |
34 | 34 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | public function validateRequired( $value ) |
114 | 114 | { |
115 | 115 | return is_null( $value ) |
116 | - || ( is_string( $value ) && trim( $value ) === '' ) |
|
117 | - || ( is_array( $value ) && count( $value ) < 1 ) |
|
116 | + || (is_string( $value ) && trim( $value ) === '') |
|
117 | + || (is_array( $value ) && count( $value ) < 1) |
|
118 | 118 | ? false |
119 | 119 | : true; |
120 | 120 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function all() |
30 | 30 | { |
31 | - if( empty( $this->options )) { |
|
31 | + if( empty($this->options) ) { |
|
32 | 32 | $this->reset(); |
33 | 33 | } |
34 | 34 | return $this->options; |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $options = $this->all(); |
46 | 46 | $pointer = &$options; |
47 | 47 | foreach( $keys as $key ) { |
48 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
48 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) )continue; |
|
49 | 49 | $pointer = &$pointer[$key]; |
50 | 50 | } |
51 | - unset( $pointer[$last] ); |
|
51 | + unset($pointer[$last]); |
|
52 | 52 | return $this->set( $options ); |
53 | 53 | } |
54 | 54 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | glsr( DefaultsManager::class )->defaults() |
81 | 81 | ); |
82 | 82 | array_walk( $options, function( &$value ) { |
83 | - if( !is_string( $value ))return; |
|
84 | - $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
|
83 | + if( !is_string( $value ) )return; |
|
84 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
85 | 85 | }); |
86 | 86 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function isRecaptchaEnabled() |
93 | 93 | { |
94 | 94 | $integration = $this->get( 'settings.submissions.recaptcha.integration' ); |
95 | - return $integration == 'all' || ( $integration == 'guest' && !is_user_logged_in() ); |
|
95 | + return $integration == 'all' || ($integration == 'guest' && !is_user_logged_in()); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public function reset() |
102 | 102 | { |
103 | 103 | $options = get_option( static::databaseKey(), [] ); |
104 | - if( !is_array( $options ) || empty( $options )) { |
|
104 | + if( !is_array( $options ) || empty($options) ) { |
|
105 | 105 | delete_option( static::databaseKey() ); |
106 | 106 | $options = wp_parse_args( glsr()->defaults, ['settings' => []] ); |
107 | 107 | } |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function set( $pathOrOptions, $value = '' ) |
117 | 117 | { |
118 | - if( is_string( $pathOrOptions )) { |
|
118 | + if( is_string( $pathOrOptions ) ) { |
|
119 | 119 | $pathOrOptions = glsr( Helper::class )->setPathValue( $pathOrOptions, $value, $this->all() ); |
120 | 120 | } |
121 | - if( $result = update_option( static::databaseKey(), (array)$pathOrOptions )) { |
|
121 | + if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) { |
|
122 | 122 | $this->reset(); |
123 | 123 | } |
124 | 124 | return $result; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $instance = new static; |
68 | 68 | $instance->setTagFromMethod( $method ); |
69 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
69 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
70 | 70 | $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
71 | 71 | do_action_ref_array( 'site-reviews/builder', [&$instance] ); |
72 | 72 | $generatedTag = in_array( $instance->tag, $tags ) |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | 'render' => 'is_bool', |
91 | 91 | 'tag' => 'is_string', |
92 | 92 | ]; |
93 | - if( !isset( $properties[$property] ) |
|
94 | - || empty( array_filter( [$value], $properties[$property] )) |
|
93 | + if( !isset($properties[$property]) |
|
94 | + || empty(array_filter( [$value], $properties[$property] )) |
|
95 | 95 | )return; |
96 | 96 | $this->$property = $value; |
97 | 97 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getClosingTag() |
103 | 103 | { |
104 | - if( empty( $this->tag ))return; |
|
104 | + if( empty($this->tag) )return; |
|
105 | 105 | return '</'.$this->tag.'>'; |
106 | 106 | } |
107 | 107 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getOpeningTag() |
112 | 112 | { |
113 | - if( empty( $this->tag ))return; |
|
114 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
113 | + if( empty($this->tag) )return; |
|
114 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
115 | 115 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
116 | 116 | } |
117 | 117 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function raw( array $field ) |
122 | 122 | { |
123 | - unset( $field['label'] ); |
|
124 | - return $this->{$field['type']}( $field ); |
|
123 | + unset($field['label']); |
|
124 | + return $this->{$field['type']}($field); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | protected function buildCustomField() |
131 | 131 | { |
132 | 132 | $className = $this->getCustomFieldClassName(); |
133 | - if( class_exists( $className )) { |
|
133 | + if( class_exists( $className ) ) { |
|
134 | 134 | return (new $className( $this ))->build(); |
135 | 135 | } |
136 | 136 | glsr_log()->error( 'Field missing: '.$className ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function buildDefaultTag( $text = '' ) |
143 | 143 | { |
144 | - if( empty( $text )) { |
|
144 | + if( empty($text) ) { |
|
145 | 145 | $text = $this->args['text']; |
146 | 146 | } |
147 | 147 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function buildFieldDescription() |
154 | 154 | { |
155 | - if( empty( $this->args['description'] ))return; |
|
155 | + if( empty($this->args['description']) )return; |
|
156 | 156 | if( $this->args['is_widget'] ) { |
157 | 157 | return $this->small( $this->args['description'] ); |
158 | 158 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function buildFormInput() |
166 | 166 | { |
167 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
168 | - if( isset( $this->args['multiple'] )) { |
|
169 | - $this->args['name'].= '[]'; |
|
167 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
168 | + if( isset($this->args['multiple']) ) { |
|
169 | + $this->args['name'] .= '[]'; |
|
170 | 170 | } |
171 | 171 | return $this->buildFormLabel().$this->getOpeningTag(); |
172 | 172 | } |
173 | - return empty( $this->args['options'] ) |
|
173 | + return empty($this->args['options']) |
|
174 | 174 | ? $this->buildFormInputChoice() |
175 | 175 | : $this->buildFormInputMultiChoice(); |
176 | 176 | } |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function buildFormInputChoice() |
182 | 182 | { |
183 | - if( !empty( $this->args['text'] )) { |
|
183 | + if( !empty($this->args['text']) ) { |
|
184 | 184 | $this->args['label'] = $this->args['text']; |
185 | 185 | } |
186 | 186 | if( !$this->args['is_public'] ) { |
187 | - return $this->buildFormLabel([ |
|
187 | + return $this->buildFormLabel( [ |
|
188 | 188 | 'class' => 'glsr-'.$this->args['type'].'-label', |
189 | 189 | 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>', |
190 | - ]); |
|
190 | + ] ); |
|
191 | 191 | } |
192 | - return $this->getOpeningTag().$this->buildFormLabel([ |
|
192 | + return $this->getOpeningTag().$this->buildFormLabel( [ |
|
193 | 193 | 'class' => 'glsr-'.$this->args['type'].'-label', |
194 | 194 | 'text' => $this->args['label'].'<span></span>', |
195 | - ]); |
|
195 | + ] ); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | protected function buildFormInputMultiChoice() |
202 | 202 | { |
203 | 203 | if( $this->args['type'] == 'checkbox' ) { |
204 | - $this->args['name'].= '[]'; |
|
204 | + $this->args['name'] .= '[]'; |
|
205 | 205 | } |
206 | 206 | $index = 0; |
207 | - $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use( &$index ) { |
|
207 | + $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use(&$index) { |
|
208 | 208 | return $carry.$this->li( $this->{$this->args['type']}([ |
209 | 209 | 'checked' => in_array( $key, (array)$this->args['value'] ), |
210 | 210 | 'id' => $this->args['id'].'-'.$index++, |
211 | 211 | 'name' => $this->args['name'], |
212 | 212 | 'text' => $this->args['options'][$key], |
213 | 213 | 'value' => $key, |
214 | - ])); |
|
214 | + ]) ); |
|
215 | 215 | }); |
216 | 216 | return $this->ul( $options, [ |
217 | 217 | 'class' => $this->args['class'], |
218 | 218 | 'id' => $this->args['id'], |
219 | - ]); |
|
219 | + ] ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function buildFormLabel( array $customArgs = [] ) |
226 | 226 | { |
227 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
227 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
228 | 228 | return $this->label( wp_parse_args( $customArgs, [ |
229 | 229 | 'for' => $this->args['id'], |
230 | 230 | 'is_public' => $this->args['is_public'], |
231 | 231 | 'text' => $this->args['label'], |
232 | 232 | 'type' => $this->args['type'], |
233 | - ])); |
|
233 | + ] ) ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | protected function buildFormSelectOptions() |
248 | 248 | { |
249 | 249 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
250 | - return $carry.$this->option([ |
|
250 | + return $carry.$this->option( [ |
|
251 | 251 | 'selected' => $this->args['value'] == $key, |
252 | 252 | 'text' => $this->args['options'][$key], |
253 | 253 | 'value' => $key, |
254 | - ]); |
|
254 | + ] ); |
|
255 | 255 | }); |
256 | 256 | } |
257 | 257 | |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | protected function buildTag() |
270 | 270 | { |
271 | 271 | $this->mergeArgsWithRequiredDefaults(); |
272 | - if( in_array( $this->tag, static::TAGS_SINGLE )) { |
|
272 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
273 | 273 | return $this->getOpeningTag(); |
274 | 274 | } |
275 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
275 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
276 | 276 | return $this->buildDefaultTag(); |
277 | 277 | } |
278 | 278 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | protected function mergeArgsWithRequiredDefaults() |
293 | 293 | { |
294 | 294 | $className = $this->getCustomFieldClassName(); |
295 | - if( class_exists( $className )) { |
|
295 | + if( class_exists( $className ) ) { |
|
296 | 296 | $this->args = array_merge( |
297 | 297 | wp_parse_args( $this->args, $className::defaults() ), |
298 | 298 | $className::required() |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | */ |
308 | 308 | protected function normalize( ...$params ) |
309 | 309 | { |
310 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
310 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
311 | 311 | $this->setNameOrTextAttributeForTag( $params[0] ); |
312 | 312 | } |
313 | - if( is_array( $params[0] )) { |
|
313 | + if( is_array( $params[0] ) ) { |
|
314 | 314 | $this->args += $params[0]; |
315 | 315 | } |
316 | - else if( is_array( $params[1] )) { |
|
316 | + else if( is_array( $params[1] ) ) { |
|
317 | 317 | $this->args += $params[1]; |
318 | 318 | } |
319 | - if( !isset( $this->args['is_public'] )) { |
|
319 | + if( !isset($this->args['is_public']) ) { |
|
320 | 320 | $this->args['is_public'] = false; |
321 | 321 | } |
322 | 322 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | protected function setTagFromMethod( $method ) |
341 | 341 | { |
342 | 342 | $this->tag = strtolower( $method ); |
343 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
343 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
344 | 344 | $this->args['type'] = $this->tag; |
345 | 345 | $this->tag = 'input'; |
346 | 346 | } |
@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | public function routeAdminPostRequest() |
18 | 18 | { |
19 | 19 | $request = $this->getRequest(); |
20 | - if( !$this->isValidPostRequest( $request ))return; |
|
20 | + if( !$this->isValidPostRequest( $request ) )return; |
|
21 | 21 | check_admin_referer( $request['action'] ); |
22 | 22 | $this->routeRequest( 'admin', $request['action'], $request ); |
23 | 23 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | { |
42 | 42 | if( is_admin() )return; |
43 | 43 | $request = $this->getRequest(); |
44 | - if( !$this->isValidPostRequest( $request ))return; |
|
45 | - if( !$this->isValidPublicNonce( $request ))return; |
|
44 | + if( !$this->isValidPostRequest( $request ) )return; |
|
45 | + if( !$this->isValidPublicNonce( $request ) )return; |
|
46 | 46 | $this->routeRequest( 'public', $request['action'], $request ); |
47 | 47 | } |
48 | 48 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | protected function checkAjaxNonce( array $request ) |
53 | 53 | { |
54 | 54 | if( !is_user_logged_in() )return; |
55 | - if( !isset( $request['nonce'] )) { |
|
55 | + if( !isset($request['nonce']) ) { |
|
56 | 56 | $this->sendAjaxError( 'request is missing a nonce', $request ); |
57 | 57 | } |
58 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
58 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
59 | 59 | $this->sendAjaxError( 'request failed the nonce check', $request, 403 ); |
60 | 60 | } |
61 | 61 | } |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function checkAjaxRequest( array $request ) |
67 | 67 | { |
68 | - if( !isset( $request['action'] )) { |
|
68 | + if( !isset($request['action']) ) { |
|
69 | 69 | $this->sendAjaxError( 'request must include an action', $request ); |
70 | 70 | } |
71 | - if( empty( $request['ajax_request'] )) { |
|
71 | + if( empty($request['ajax_request']) ) { |
|
72 | 72 | $this->sendAjaxError( 'request is invalid', $request ); |
73 | 73 | } |
74 | 74 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function isValidPostRequest( array $request = [] ) |
97 | 97 | { |
98 | - return !empty( $request['action'] ) && empty( $request['ajax_request'] ); |
|
98 | + return !empty($request['action']) && empty($request['ajax_request']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function isValidPublicNonce( array $request ) |
105 | 105 | { |
106 | - if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
106 | + if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
107 | 107 | glsr_log()->error( 'nonce check failed for public request' )->debug( $request ); |
108 | 108 | return false; |
109 | 109 | } |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | protected function routeRequest( $type, $action, array $request = [] ) |
119 | 119 | { |
120 | 120 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
121 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
121 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
122 | 122 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
123 | 123 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
124 | 124 | do_action( $actionHook, $action, $request ); |
125 | - if( is_callable( [$controller, $method] )) { |
|
125 | + if( is_callable( [$controller, $method] ) ) { |
|
126 | 126 | call_user_func( [$controller, $method], $request ); |
127 | 127 | return; |
128 | 128 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | glsr_log()->error( $error )->debug( $request ); |
142 | 142 | glsr_log( $_POST ); |
143 | 143 | glsr( Notice::class )->addError( __( 'There was an error (try refreshing the page).', 'site-reviews' ).' <code>'.$error.'</code>' ); |
144 | - wp_send_json_error([ |
|
144 | + wp_send_json_error( [ |
|
145 | 145 | 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
146 | 146 | 'notices' => glsr( Notice::class )->get(), |
147 | 147 | 'error' => $error, |
148 | - ]); |
|
148 | + ] ); |
|
149 | 149 | } |
150 | 150 | } |
@@ -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 | } |