@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | * @param array $args |
62 | 62 | * @return string|void |
63 | 63 | */ |
64 | - public function __call($method, $args) |
|
64 | + public function __call( $method, $args ) |
|
65 | 65 | { |
66 | 66 | $instance = new static(); |
67 | - $instance->setTagFromMethod($method); |
|
68 | - call_user_func_array([$instance, 'normalize'], $args += ['', '']); |
|
69 | - $tags = array_merge(static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT); |
|
70 | - do_action_ref_array('site-reviews/builder', [$instance]); |
|
71 | - $generatedTag = in_array($instance->tag, $tags) |
|
67 | + $instance->setTagFromMethod( $method ); |
|
68 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
69 | + $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
|
70 | + do_action_ref_array( 'site-reviews/builder', [$instance] ); |
|
71 | + $generatedTag = in_array( $instance->tag, $tags ) |
|
72 | 72 | ? $instance->buildTag() |
73 | 73 | : $instance->buildCustomField(); |
74 | - $generatedTag = apply_filters('site-reviews/builder/result', $generatedTag, $instance); |
|
75 | - if (!$this->render) { |
|
74 | + $generatedTag = apply_filters( 'site-reviews/builder/result', $generatedTag, $instance ); |
|
75 | + if( !$this->render ) { |
|
76 | 76 | return $generatedTag; |
77 | 77 | } |
78 | 78 | echo $generatedTag; |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | * @param mixed $value |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public function __set($property, $value) |
|
86 | + public function __set( $property, $value ) |
|
87 | 87 | { |
88 | 88 | $properties = [ |
89 | 89 | 'args' => 'is_array', |
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 | ) { |
96 | 96 | return; |
97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getClosingTag() |
105 | 105 | { |
106 | - if (empty($this->tag)) { |
|
106 | + if( empty($this->tag) ) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | return '</'.$this->tag.'>'; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getOpeningTag() |
116 | 116 | { |
117 | - if (empty($this->tag)) { |
|
117 | + if( empty($this->tag) ) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - $attributes = glsr(Attributes::class)->{$this->tag}($this->args)->toString(); |
|
121 | - return '<'.trim($this->tag.' '.$attributes).'>'; |
|
120 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
121 | + return '<'.trim( $this->tag.' '.$attributes ).'>'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getTag() |
128 | 128 | { |
129 | - if (in_array($this->tag, static::TAGS_SINGLE)) { |
|
129 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
130 | 130 | return $this->getOpeningTag(); |
131 | 131 | } |
132 | - if (!in_array($this->tag, static::TAGS_FORM)) { |
|
132 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
133 | 133 | return $this->buildDefaultTag(); |
134 | 134 | } |
135 | - return call_user_func([$this, 'buildForm'.ucfirst($this->tag)]).$this->buildFieldDescription(); |
|
135 | + return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function raw(array $field) |
|
141 | + public function raw( array $field ) |
|
142 | 142 | { |
143 | 143 | unset($field['label']); |
144 | 144 | return $this->{$field['type']}($field); |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | protected function buildCustomField() |
151 | 151 | { |
152 | 152 | $className = $this->getCustomFieldClassName(); |
153 | - if (class_exists($className)) { |
|
154 | - return (new $className($this))->build(); |
|
153 | + if( class_exists( $className ) ) { |
|
154 | + return (new $className( $this ))->build(); |
|
155 | 155 | } |
156 | - glsr_log()->error('Field missing: '.$className); |
|
156 | + glsr_log()->error( 'Field missing: '.$className ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @return string|void |
161 | 161 | */ |
162 | - protected function buildDefaultTag($text = '') |
|
162 | + protected function buildDefaultTag( $text = '' ) |
|
163 | 163 | { |
164 | - if (empty($text)) { |
|
164 | + if( empty($text) ) { |
|
165 | 165 | $text = $this->args['text']; |
166 | 166 | } |
167 | 167 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function buildFieldDescription() |
174 | 174 | { |
175 | - if (empty($this->args['description'])) { |
|
175 | + if( empty($this->args['description']) ) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | - if ($this->args['is_widget']) { |
|
179 | - return $this->small($this->args['description']); |
|
178 | + if( $this->args['is_widget'] ) { |
|
179 | + return $this->small( $this->args['description'] ); |
|
180 | 180 | } |
181 | - return $this->p($this->args['description'], ['class' => 'description']); |
|
181 | + return $this->p( $this->args['description'], ['class' => 'description'] ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function buildFormInput() |
188 | 188 | { |
189 | - if (!in_array($this->args['type'], ['checkbox', 'radio'])) { |
|
190 | - if (isset($this->args['multiple'])) { |
|
191 | - $this->args['name'].= '[]'; |
|
189 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
190 | + if( isset($this->args['multiple']) ) { |
|
191 | + $this->args['name'] .= '[]'; |
|
192 | 192 | } |
193 | 193 | return $this->buildFormLabel().$this->getOpeningTag(); |
194 | 194 | } |
@@ -202,19 +202,19 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function buildFormInputChoice() |
204 | 204 | { |
205 | - if (!empty($this->args['text'])) { |
|
205 | + if( !empty($this->args['text']) ) { |
|
206 | 206 | $this->args['label'] = $this->args['text']; |
207 | 207 | } |
208 | - if (!$this->args['is_public']) { |
|
209 | - return $this->buildFormLabel([ |
|
208 | + if( !$this->args['is_public'] ) { |
|
209 | + return $this->buildFormLabel( [ |
|
210 | 210 | 'class' => 'glsr-'.$this->args['type'].'-label', |
211 | 211 | 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>', |
212 | - ]); |
|
212 | + ] ); |
|
213 | 213 | } |
214 | - return $this->getOpeningTag().$this->buildFormLabel([ |
|
214 | + return $this->getOpeningTag().$this->buildFormLabel( [ |
|
215 | 215 | 'class' => 'glsr-'.$this->args['type'].'-label', |
216 | 216 | 'text' => $this->args['label'].'<span></span>', |
217 | - ]); |
|
217 | + ] ); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -222,39 +222,39 @@ discard block |
||
222 | 222 | */ |
223 | 223 | protected function buildFormInputMultiChoice() |
224 | 224 | { |
225 | - if ('checkbox' == $this->args['type']) { |
|
226 | - $this->args['name'].= '[]'; |
|
225 | + if( 'checkbox' == $this->args['type'] ) { |
|
226 | + $this->args['name'] .= '[]'; |
|
227 | 227 | } |
228 | 228 | $index = 0; |
229 | - $options = array_reduce(array_keys($this->args['options']), function ($carry, $key) use (&$index) { |
|
230 | - return $carry.$this->li($this->{$this->args['type']}([ |
|
231 | - 'checked' => in_array($key, (array) $this->args['value']), |
|
229 | + $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use (&$index) { |
|
230 | + return $carry.$this->li( $this->{$this->args['type']}([ |
|
231 | + 'checked' => in_array( $key, (array)$this->args['value'] ), |
|
232 | 232 | 'id' => $this->args['id'].'-'.$index++, |
233 | 233 | 'name' => $this->args['name'], |
234 | 234 | 'text' => $this->args['options'][$key], |
235 | 235 | 'value' => $key, |
236 | - ])); |
|
236 | + ]) ); |
|
237 | 237 | }); |
238 | - return $this->ul($options, [ |
|
238 | + return $this->ul( $options, [ |
|
239 | 239 | 'class' => $this->args['class'], |
240 | 240 | 'id' => $this->args['id'], |
241 | - ]); |
|
241 | + ] ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | 245 | * @return void|string |
246 | 246 | */ |
247 | - protected function buildFormLabel(array $customArgs = []) |
|
247 | + protected function buildFormLabel( array $customArgs = [] ) |
|
248 | 248 | { |
249 | - if (empty($this->args['label']) || 'hidden' == $this->args['type']) { |
|
249 | + if( empty($this->args['label']) || 'hidden' == $this->args['type'] ) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | - return $this->label(wp_parse_args($customArgs, [ |
|
252 | + return $this->label( wp_parse_args( $customArgs, [ |
|
253 | 253 | 'for' => $this->args['id'], |
254 | 254 | 'is_public' => $this->args['is_public'], |
255 | 255 | 'text' => $this->args['label'], |
256 | 256 | 'type' => $this->args['type'], |
257 | - ])); |
|
257 | + ] ) ); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | protected function buildFormSelect() |
264 | 264 | { |
265 | - return $this->buildFormLabel().$this->buildDefaultTag($this->buildFormSelectOptions()); |
|
265 | + return $this->buildFormLabel().$this->buildDefaultTag( $this->buildFormSelectOptions() ); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | */ |
271 | 271 | protected function buildFormSelectOptions() |
272 | 272 | { |
273 | - return array_reduce(array_keys($this->args['options']), function ($carry, $key) { |
|
274 | - return $carry.$this->option([ |
|
275 | - 'selected' => $this->args['value'] === (string) $key, |
|
273 | + return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
|
274 | + return $carry.$this->option( [ |
|
275 | + 'selected' => $this->args['value'] === (string)$key, |
|
276 | 276 | 'text' => $this->args['options'][$key], |
277 | 277 | 'value' => $key, |
278 | - ]); |
|
278 | + ] ); |
|
279 | 279 | }); |
280 | 280 | } |
281 | 281 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function buildFormTextarea() |
286 | 286 | { |
287 | - return $this->buildFormLabel().$this->buildDefaultTag($this->args['value']); |
|
287 | + return $this->buildFormLabel().$this->buildDefaultTag( $this->args['value'] ); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function getCustomFieldClassName() |
303 | 303 | { |
304 | - $classname = Helper::buildClassName($this->tag, __NAMESPACE__.'\Fields'); |
|
305 | - return apply_filters('site-reviews/builder/field/'.$this->tag, $classname); |
|
304 | + $classname = Helper::buildClassName( $this->tag, __NAMESPACE__.'\Fields' ); |
|
305 | + return apply_filters( 'site-reviews/builder/field/'.$this->tag, $classname ); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -311,27 +311,27 @@ discard block |
||
311 | 311 | protected function mergeArgsWithRequiredDefaults() |
312 | 312 | { |
313 | 313 | $className = $this->getCustomFieldClassName(); |
314 | - if (class_exists($className)) { |
|
315 | - $this->args = $className::merge($this->args); |
|
314 | + if( class_exists( $className ) ) { |
|
315 | + $this->args = $className::merge( $this->args ); |
|
316 | 316 | } |
317 | - $this->args = glsr(BuilderDefaults::class)->merge($this->args); |
|
317 | + $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @param string|array ...$params |
322 | 322 | * @return void |
323 | 323 | */ |
324 | - protected function normalize(...$params) |
|
324 | + protected function normalize( ...$params ) |
|
325 | 325 | { |
326 | - if (is_string($params[0]) || is_numeric($params[0])) { |
|
327 | - $this->setNameOrTextAttributeForTag($params[0]); |
|
326 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
327 | + $this->setNameOrTextAttributeForTag( $params[0] ); |
|
328 | 328 | } |
329 | - if (is_array($params[0])) { |
|
329 | + if( is_array( $params[0] ) ) { |
|
330 | 330 | $this->args += $params[0]; |
331 | - } elseif (is_array($params[1])) { |
|
331 | + } elseif( is_array( $params[1] ) ) { |
|
332 | 332 | $this->args += $params[1]; |
333 | 333 | } |
334 | - if (!isset($this->args['is_public'])) { |
|
334 | + if( !isset($this->args['is_public']) ) { |
|
335 | 335 | $this->args['is_public'] = false; |
336 | 336 | } |
337 | 337 | } |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * @param string $value |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - protected function setNameOrTextAttributeForTag($value) |
|
343 | + protected function setNameOrTextAttributeForTag( $value ) |
|
344 | 344 | { |
345 | - $attribute = in_array($this->tag, static::TAGS_FORM) |
|
345 | + $attribute = in_array( $this->tag, static::TAGS_FORM ) |
|
346 | 346 | ? 'name' |
347 | 347 | : 'text'; |
348 | 348 | $this->args[$attribute] = $value; |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | * @param string $method |
353 | 353 | * @return void |
354 | 354 | */ |
355 | - protected function setTagFromMethod($method) |
|
355 | + protected function setTagFromMethod( $method ) |
|
356 | 356 | { |
357 | - $this->tag = strtolower($method); |
|
358 | - if (in_array($this->tag, static::INPUT_TYPES)) { |
|
357 | + $this->tag = strtolower( $method ); |
|
358 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
359 | 359 | $this->args['type'] = $this->tag; |
360 | 360 | $this->tag = 'input'; |
361 | 361 | } |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * @param bool $single |
19 | 19 | * @return mixed |
20 | 20 | */ |
21 | - public function get($postId, $key, $single = true) |
|
21 | + public function get( $postId, $key, $single = true ) |
|
22 | 22 | { |
23 | - $key = Str::prefix('_', $key); |
|
24 | - return get_post_meta(intval($postId), $key, $single); |
|
23 | + $key = Str::prefix( '_', $key ); |
|
24 | + return get_post_meta( intval( $postId ), $key, $single ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param string $assignedTo |
30 | 30 | * @return void|WP_Post |
31 | 31 | */ |
32 | - public function getAssignedToPost($postId, $assignedTo = '') |
|
32 | + public function getAssignedToPost( $postId, $assignedTo = '' ) |
|
33 | 33 | { |
34 | - if (empty($assignedTo)) { |
|
35 | - $assignedTo = $this->get($postId, 'assigned_to'); |
|
34 | + if( empty($assignedTo) ) { |
|
35 | + $assignedTo = $this->get( $postId, 'assigned_to' ); |
|
36 | 36 | } |
37 | - if (empty($assignedTo)) { |
|
37 | + if( empty($assignedTo) ) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | - $assignedPost = get_post($assignedTo); |
|
41 | - if ($assignedPost instanceof WP_Post && $assignedPost->ID != $postId) { |
|
40 | + $assignedPost = get_post( $assignedTo ); |
|
41 | + if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
|
42 | 42 | return $assignedPost; |
43 | 43 | } |
44 | 44 | } |
@@ -48,25 +48,25 @@ discard block |
||
48 | 48 | * @param string $metaValue |
49 | 49 | * @return array|int |
50 | 50 | */ |
51 | - public function getReviewCount($metaKey = '', $metaValue = '') |
|
51 | + public function getReviewCount( $metaKey = '', $metaValue = '' ) |
|
52 | 52 | { |
53 | - if (!$metaKey) { |
|
54 | - return (array) wp_count_posts(Application::POST_TYPE); |
|
53 | + if( !$metaKey ) { |
|
54 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
55 | 55 | } |
56 | - $counts = glsr(Cache::class)->getReviewCountsFor($metaKey); |
|
57 | - if (!$metaValue) { |
|
56 | + $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
|
57 | + if( !$metaValue ) { |
|
58 | 58 | return $counts; |
59 | 59 | } |
60 | - return Arr::get($counts, $metaValue, 0); |
|
60 | + return Arr::get( $counts, $metaValue, 0 ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param string $metaReviewType |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - public function getReviewIdsByType($metaReviewType) |
|
67 | + public function getReviewIdsByType( $metaReviewType ) |
|
68 | 68 | { |
69 | - return glsr(SqlQueries::class)->getReviewIdsByType($metaReviewType); |
|
69 | + return glsr( SqlQueries::class )->getReviewIdsByType( $metaReviewType ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | * @param string $status |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function getReviewsMeta($key, $status = 'publish') |
|
77 | + public function getReviewsMeta( $key, $status = 'publish' ) |
|
78 | 78 | { |
79 | - return glsr(SqlQueries::class)->getReviewsMeta($key, $status); |
|
79 | + return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @param string $field |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public function getTermIds(array $values, $field) |
|
86 | + public function getTermIds( array $values, $field ) |
|
87 | 87 | { |
88 | 88 | $termIds = []; |
89 | - foreach ($values as $value) { |
|
90 | - $term = get_term_by($field, $value, Application::TAXONOMY); |
|
91 | - if (!isset($term->term_id)) { |
|
89 | + foreach( $values as $value ) { |
|
90 | + $term = get_term_by( $field, $value, Application::TAXONOMY ); |
|
91 | + if( !isset($term->term_id) ) { |
|
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | $termIds[] = $term->term_id; |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function getTerms(array $args = []) |
|
102 | + public function getTerms( array $args = [] ) |
|
103 | 103 | { |
104 | - $args = wp_parse_args($args, [ |
|
104 | + $args = wp_parse_args( $args, [ |
|
105 | 105 | 'count' => false, |
106 | 106 | 'fields' => 'id=>name', |
107 | 107 | 'hide_empty' => false, |
108 | 108 | 'taxonomy' => Application::TAXONOMY, |
109 | - ]); |
|
110 | - $terms = get_terms($args); |
|
111 | - if (is_wp_error($terms)) { |
|
112 | - glsr_log()->error($terms->get_error_message()); |
|
109 | + ] ); |
|
110 | + $terms = get_terms( $args ); |
|
111 | + if( is_wp_error( $terms ) ) { |
|
112 | + glsr_log()->error( $terms->get_error_message() ); |
|
113 | 113 | return []; |
114 | 114 | } |
115 | 115 | return $terms; |
@@ -119,36 +119,36 @@ discard block |
||
119 | 119 | * @param string $searchTerm |
120 | 120 | * @return void|string |
121 | 121 | */ |
122 | - public function searchPosts($searchTerm) |
|
122 | + public function searchPosts( $searchTerm ) |
|
123 | 123 | { |
124 | 124 | $args = [ |
125 | 125 | 'post_status' => 'publish', |
126 | 126 | 'post_type' => 'any', |
127 | 127 | ]; |
128 | - if (is_numeric($searchTerm)) { |
|
128 | + if( is_numeric( $searchTerm ) ) { |
|
129 | 129 | $args['post__in'] = [$searchTerm]; |
130 | 130 | } else { |
131 | 131 | $args['orderby'] = 'relevance'; |
132 | 132 | $args['posts_per_page'] = 10; |
133 | 133 | $args['s'] = $searchTerm; |
134 | 134 | } |
135 | - $queryBuilder = glsr(QueryBuilder::class); |
|
136 | - add_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2); |
|
137 | - $search = new WP_Query($args); |
|
138 | - remove_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500); |
|
139 | - if (!$search->have_posts()) { |
|
135 | + $queryBuilder = glsr( QueryBuilder::class ); |
|
136 | + add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
|
137 | + $search = new WP_Query( $args ); |
|
138 | + remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
|
139 | + if( !$search->have_posts() ) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | $results = ''; |
143 | - while ($search->have_posts()) { |
|
143 | + while( $search->have_posts() ) { |
|
144 | 144 | $search->the_post(); |
145 | 145 | ob_start(); |
146 | - glsr()->render('partials/editor/search-result', [ |
|
146 | + glsr()->render( 'partials/editor/search-result', [ |
|
147 | 147 | 'ID' => get_the_ID(), |
148 | - 'permalink' => esc_url((string) get_permalink()), |
|
149 | - 'title' => esc_attr(get_the_title()), |
|
150 | - ]); |
|
151 | - $results.= ob_get_clean(); |
|
148 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
149 | + 'title' => esc_attr( get_the_title() ), |
|
150 | + ] ); |
|
151 | + $results .= ob_get_clean(); |
|
152 | 152 | } |
153 | 153 | wp_reset_postdata(); |
154 | 154 | return $results; |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | * @param mixed $value |
161 | 161 | * @return int|bool |
162 | 162 | */ |
163 | - public function set($postId, $key, $value) |
|
163 | + public function set( $postId, $key, $value ) |
|
164 | 164 | { |
165 | - $key = Str::prefix('_', $key); |
|
166 | - return update_post_meta($postId, $key, $value); |
|
165 | + $key = Str::prefix( '_', $key ); |
|
166 | + return update_post_meta( $postId, $key, $value ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param mixed $value |
173 | 173 | * @return int|bool |
174 | 174 | */ |
175 | - public function update($postId, $key, $value) |
|
175 | + public function update( $postId, $key, $value ) |
|
176 | 176 | { |
177 | - return $this->set($postId, $key, $value); |
|
177 | + return $this->set( $postId, $key, $value ); |
|
178 | 178 | } |
179 | 179 | } |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | * Build a WP_Query meta_query/tax_query. |
17 | 17 | * @return array |
18 | 18 | */ |
19 | - public function buildQuery(array $keys = [], array $values = []) |
|
19 | + public function buildQuery( array $keys = [], array $values = [] ) |
|
20 | 20 | { |
21 | 21 | $queries = []; |
22 | - foreach ($keys as $key) { |
|
23 | - if (!array_key_exists($key, $values)) { |
|
22 | + foreach( $keys as $key ) { |
|
23 | + if( !array_key_exists( $key, $values ) ) { |
|
24 | 24 | continue; |
25 | 25 | } |
26 | - $methodName = Helper::buildMethodName($key, __FUNCTION__); |
|
27 | - if (!method_exists($this, $methodName)) { |
|
26 | + $methodName = Helper::buildMethodName( $key, __FUNCTION__ ); |
|
27 | + if( !method_exists( $this, $methodName ) ) { |
|
28 | 28 | continue; |
29 | 29 | } |
30 | - $query = call_user_func([$this, $methodName], $values[$key]); |
|
31 | - if (is_array($query)) { |
|
30 | + $query = call_user_func( [$this, $methodName], $values[$key] ); |
|
31 | + if( is_array( $query ) ) { |
|
32 | 32 | $queries[] = $query; |
33 | 33 | } |
34 | 34 | } |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - public function buildSqlLines(array $values, array $conditions) |
|
41 | + public function buildSqlLines( array $values, array $conditions ) |
|
42 | 42 | { |
43 | 43 | $string = ''; |
44 | - $values = array_filter($values); |
|
45 | - foreach ($conditions as $key => $value) { |
|
46 | - if (!isset($values[$key])) { |
|
44 | + $values = array_filter( $values ); |
|
45 | + foreach( $conditions as $key => $value ) { |
|
46 | + if( !isset($values[$key]) ) { |
|
47 | 47 | continue; |
48 | 48 | } |
49 | - $values[$key] = implode(',', (array) $values[$key]); |
|
50 | - $string.= Str::contains($value, '%s') |
|
51 | - ? sprintf($value, strval($values[$key])) |
|
49 | + $values[$key] = implode( ',', (array)$values[$key] ); |
|
50 | + $string .= Str::contains( $value, '%s' ) |
|
51 | + ? sprintf( $value, strval( $values[$key] ) ) |
|
52 | 52 | : $value; |
53 | 53 | } |
54 | 54 | return $string; |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param string $sprintfFormat |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public function buildSqlOr($values, $sprintfFormat) |
|
63 | + public function buildSqlOr( $values, $sprintfFormat ) |
|
64 | 64 | { |
65 | - if (!is_array($values)) { |
|
66 | - $values = explode(',', $values); |
|
65 | + if( !is_array( $values ) ) { |
|
66 | + $values = explode( ',', $values ); |
|
67 | 67 | } |
68 | - $values = array_filter(array_map('trim', (array) $values)); |
|
69 | - $values = array_map(function ($value) use ($sprintfFormat) { |
|
70 | - return sprintf($sprintfFormat, $value); |
|
71 | - }, $values); |
|
72 | - return implode(' OR ', $values); |
|
68 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
69 | + $values = array_map( function( $value ) use ($sprintfFormat) { |
|
70 | + return sprintf( $sprintfFormat, $value ); |
|
71 | + }, $values ); |
|
72 | + return implode( ' OR ', $values ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | * @filter posts_search |
81 | 81 | */ |
82 | - public function filterSearchByTitle($search, WP_Query $query) |
|
82 | + public function filterSearchByTitle( $search, WP_Query $query ) |
|
83 | 83 | { |
84 | - if (empty($search) || empty($query->get('search_terms'))) { |
|
84 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
85 | 85 | return $search; |
86 | 86 | } |
87 | 87 | global $wpdb; |
88 | - $n = empty($query->get('exact')) |
|
88 | + $n = empty($query->get( 'exact' )) |
|
89 | 89 | ? '%' |
90 | 90 | : ''; |
91 | 91 | $search = []; |
92 | - foreach ((array) $query->get('search_terms') as $term) { |
|
93 | - $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n); |
|
92 | + foreach( (array)$query->get( 'search_terms' ) as $term ) { |
|
93 | + $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n ); |
|
94 | 94 | } |
95 | - if (!is_user_logged_in()) { |
|
95 | + if( !is_user_logged_in() ) { |
|
96 | 96 | $search[] = "{$wpdb->posts}.post_password = ''"; |
97 | 97 | } |
98 | - return ' AND '.implode(' AND ', $search); |
|
98 | + return ' AND '.implode( ' AND ', $search ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param bool $isEnabled |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public function getPaged($isEnabled = true) |
|
106 | + public function getPaged( $isEnabled = true ) |
|
107 | 107 | { |
108 | 108 | return $isEnabled |
109 | - ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR')))) |
|
109 | + ? max( 1, intval( filter_input( INPUT_GET, glsr()->constant( 'PAGED_QUERY_VAR' ) ) ) ) |
|
110 | 110 | : 1; |
111 | 111 | } |
112 | 112 | |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $value |
115 | 115 | * @return void|array |
116 | 116 | */ |
117 | - protected function buildQueryAssignedTo($value) |
|
117 | + protected function buildQueryAssignedTo( $value ) |
|
118 | 118 | { |
119 | - if (!empty($value)) { |
|
120 | - $postIds = Arr::convertStringToArray($value, 'is_numeric'); |
|
119 | + if( !empty($value) ) { |
|
120 | + $postIds = Arr::convertStringToArray( $value, 'is_numeric' ); |
|
121 | 121 | return [ |
122 | 122 | 'compare' => 'IN', |
123 | 123 | 'key' => '_assigned_to', |
124 | - 'value' => glsr(Multilingual::class)->getPostIds($postIds), |
|
124 | + 'value' => glsr( Multilingual::class )->getPostIds( $postIds ), |
|
125 | 125 | ]; |
126 | 126 | } |
127 | 127 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param array $value |
131 | 131 | * @return void|array |
132 | 132 | */ |
133 | - protected function buildQueryCategory($value) |
|
133 | + protected function buildQueryCategory( $value ) |
|
134 | 134 | { |
135 | - if (!empty($value)) { |
|
135 | + if( !empty($value) ) { |
|
136 | 136 | return [ |
137 | 137 | 'field' => 'term_id', |
138 | 138 | 'taxonomy' => Application::TAXONOMY, |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string $value |
146 | 146 | * @return void|array |
147 | 147 | */ |
148 | - protected function buildQueryEmail($value) |
|
148 | + protected function buildQueryEmail( $value ) |
|
149 | 149 | { |
150 | - if (!empty($value)) { |
|
150 | + if( !empty($value) ) { |
|
151 | 151 | return [ |
152 | 152 | 'key' => '_email', |
153 | 153 | 'value' => $value, |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * @param string $value |
160 | 160 | * @return void|array |
161 | 161 | */ |
162 | - protected function buildQueryIpAddress($value) |
|
162 | + protected function buildQueryIpAddress( $value ) |
|
163 | 163 | { |
164 | - if (!empty($value)) { |
|
164 | + if( !empty($value) ) { |
|
165 | 165 | return [ |
166 | 166 | 'key' => '_ip_address', |
167 | 167 | 'value' => $value, |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | * @param string $value |
174 | 174 | * @return void|array |
175 | 175 | */ |
176 | - protected function buildQueryRating($value) |
|
176 | + protected function buildQueryRating( $value ) |
|
177 | 177 | { |
178 | - if (is_numeric($value) |
|
179 | - && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) { |
|
178 | + if( is_numeric( $value ) |
|
179 | + && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) { |
|
180 | 180 | return [ |
181 | 181 | 'compare' => '>=', |
182 | 182 | 'key' => '_rating', |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * @param string $value |
190 | 190 | * @return void|array |
191 | 191 | */ |
192 | - protected function buildQueryType($value) |
|
192 | + protected function buildQueryType( $value ) |
|
193 | 193 | { |
194 | - if (!in_array($value, ['', 'all'])) { |
|
194 | + if( !in_array( $value, ['', 'all'] ) ) { |
|
195 | 195 | return [ |
196 | 196 | 'key' => '_review_type', |
197 | 197 | 'value' => $value, |
@@ -21,29 +21,29 @@ discard block |
||
21 | 21 | * @param array $args |
22 | 22 | * @return |
23 | 23 | */ |
24 | - public function __call($method, $args = []) |
|
24 | + public function __call( $method, $args = [] ) |
|
25 | 25 | { |
26 | - if ($this->isIntegrated() && method_exists($this->integration, $method)) { |
|
27 | - return call_user_func_array([$this->integration, $method], $args); |
|
26 | + if( $this->isIntegrated() && method_exists( $this->integration, $method ) ) { |
|
27 | + return call_user_func_array( [$this->integration, $method], $args ); |
|
28 | 28 | } |
29 | - return Arr::get($args, 0, false); |
|
29 | + return Arr::get( $args, 0, false ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @param string $integration |
34 | 34 | * @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml |
35 | 35 | */ |
36 | - public function getIntegration($integration = '') |
|
36 | + public function getIntegration( $integration = '' ) |
|
37 | 37 | { |
38 | - if (empty($integration)) { |
|
39 | - $integration = glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
38 | + if( empty($integration) ) { |
|
39 | + $integration = glsr( OptionManager::class )->get( 'settings.general.multilingual' ); |
|
40 | 40 | } |
41 | - if (!empty($integration)) { |
|
42 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst($integration); |
|
43 | - if (class_exists($integrationClass)) { |
|
44 | - return glsr($integrationClass); |
|
41 | + if( !empty($integration) ) { |
|
42 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst( $integration ); |
|
43 | + if( class_exists( $integrationClass ) ) { |
|
44 | + return glsr( $integrationClass ); |
|
45 | 45 | } |
46 | - glsr_log()->error($integrationClass.' does not exist'); |
|
46 | + glsr_log()->error( $integrationClass.' does not exist' ); |
|
47 | 47 | } |
48 | 48 | return false; |
49 | 49 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function isIntegrated() |
55 | 55 | { |
56 | - if (!empty($this->integration)) { |
|
56 | + if( !empty($this->integration) ) { |
|
57 | 57 | return true; |
58 | 58 | } |
59 | - if ($integration = $this->getIntegration()) { |
|
59 | + if( $integration = $this->getIntegration() ) { |
|
60 | 60 | $this->integration = $integration; |
61 | 61 | return true; |
62 | 62 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<p><?= sprintf(__('Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews'), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>'); ?></p> |
|
3 | +<p><?= sprintf( __( 'Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews' ), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>' ); ?></p> |
|
4 | 4 | |
5 | 5 | <div class="glsr-strings-form"> |
6 | 6 | <div class="glsr-search-box" id="glsr-search-translations"> |
7 | - <span class="screen-reader-text"><?= __('Search for translatable text', 'site-reviews'); ?></span> |
|
7 | + <span class="screen-reader-text"><?= __( 'Search for translatable text', 'site-reviews' ); ?></span> |
|
8 | 8 | <div class="glsr-spinner"> |
9 | 9 | <span class="spinner"></span> |
10 | 10 | </div> |
11 | - <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __('Search here for text to translate...', 'site-reviews'); ?>"> |
|
12 | - <?php wp_nonce_field('search-translations', '_search_nonce', false); ?> |
|
11 | + <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __( 'Search here for text to translate...', 'site-reviews' ); ?>"> |
|
12 | + <?php wp_nonce_field( 'search-translations', '_search_nonce', false ); ?> |
|
13 | 13 | <div class="glsr-search-results" data-prefix="{{ database_key }}"></div> |
14 | 14 | </div> |
15 | 15 | <table class="glsr-strings-table wp-list-table widefat striped {{ class }}"> |
16 | 16 | <thead> |
17 | 17 | <tr> |
18 | - <th scope="col" class="manage-column column-primary"><?= __('Original Text', 'site-reviews'); ?></th> |
|
19 | - <th scope="col" class="manage-column"><?= __('Custom Translation', 'site-reviews'); ?></th> |
|
18 | + <th scope="col" class="manage-column column-primary"><?= __( 'Original Text', 'site-reviews' ); ?></th> |
|
19 | + <th scope="col" class="manage-column"><?= __( 'Custom Translation', 'site-reviews' ); ?></th> |
|
20 | 20 | </tr> |
21 | 21 | </thead> |
22 | 22 | <tbody>{{ translations }}</tbody> |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | |
27 | 27 | <script type="text/html" id="tmpl-glsr-string-plural"> |
28 | -<?php include glsr()->path('views/partials/translations/plural.php'); ?> |
|
28 | +<?php include glsr()->path( 'views/partials/translations/plural.php' ); ?> |
|
29 | 29 | </script> |
30 | 30 | <script type="text/html" id="tmpl-glsr-string-single"> |
31 | -<?php include glsr()->path('views/partials/translations/single.php'); ?> |
|
31 | +<?php include glsr()->path( 'views/partials/translations/single.php' ); ?> |
|
32 | 32 | </script> |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @filter site-reviews/get/reviews/query |
16 | 16 | */ |
17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
17 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
18 | 18 | { |
19 | - if ($authorId = get_current_user_id()) { |
|
19 | + if( $authorId = get_current_user_id() ) { |
|
20 | 20 | $parameters['author'] = $authorId; |
21 | 21 | } |
22 | 22 | $parameters['post_status'] = ['pending', 'publish']; |
23 | - return apply_filters('site-reviews/review-limits/query', $parameters, $args); |
|
23 | + return apply_filters( 'site-reviews/review-limits/query', $parameters, $args ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function hasReachedLimit(array $request = []) |
|
29 | + public function hasReachedLimit( array $request = [] ) |
|
30 | 30 | { |
31 | 31 | $this->request = $request; |
32 | 32 | $method = Helper::buildMethodName( |
33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
33 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
34 | 34 | ); |
35 | - return method_exists($this, $method) |
|
36 | - ? !call_user_func([$this, $method]) |
|
35 | + return method_exists( $this, $method ) |
|
36 | + ? !call_user_func( [$this, $method] ) |
|
37 | 37 | : false; |
38 | 38 | } |
39 | 39 | |
@@ -42,41 +42,41 @@ discard block |
||
42 | 42 | * @param string $whitelist |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function isWhitelisted($value, $whitelist) |
|
45 | + public function isWhitelisted( $value, $whitelist ) |
|
46 | 46 | { |
47 | - if (empty($whitelist)) { |
|
47 | + if( empty($whitelist) ) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
50 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $whitelistName |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - protected function getWhitelist($whitelistName) |
|
57 | + protected function getWhitelist( $whitelistName ) |
|
58 | 58 | { |
59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
59 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return bool |
64 | 64 | */ |
65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
65 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
66 | 66 | { |
67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
67 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | - if ($addMetaQuery) { |
|
70 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
71 | + $args = ['assigned_to' => Arr::get( $this->request, 'assign_to' )]; |
|
72 | + if( $addMetaQuery ) { |
|
73 | 73 | $args[$key] = $value; |
74 | 74 | } |
75 | - $reviews = glsr_get_reviews($args); |
|
76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | - $result = 0 === count($reviews); |
|
78 | - $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $this->request, $key); |
|
79 | - return wp_validate_boolean($result); |
|
75 | + $reviews = glsr_get_reviews( $args ); |
|
76 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
77 | + $result = 0 === count( $reviews ); |
|
78 | + $result = apply_filters( 'site-reviews/review-limits/validate', $result, $reviews, $this->request, $key ); |
|
79 | + return wp_validate_boolean( $result ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function validateByEmail() |
86 | 86 | { |
87 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
88 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
87 | + glsr_log()->debug( 'Email is: '.Arr::get( $this->request, 'email' ) ); |
|
88 | + return $this->validate( 'email', Arr::get( $this->request, 'email' ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function validateByIpAddress() |
95 | 95 | { |
96 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
97 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
96 | + glsr_log()->debug( 'IP Address is: '.Arr::get( $this->request, 'ip_address' ) ); |
|
97 | + return $this->validate( 'ip_address', Arr::get( $this->request, 'ip_address' ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | protected function validateByUsername() |
104 | 104 | { |
105 | 105 | $user = wp_get_current_user(); |
106 | - if (!$user->exists()) { |
|
106 | + if( !$user->exists() ) { |
|
107 | 107 | return true; |
108 | 108 | } |
109 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
110 | - return $this->validate('username', $user->user_login, false); |
|
109 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
110 | + return $this->validate( 'username', $user->user_login, false ); |
|
111 | 111 | } |
112 | 112 | } |
@@ -16,23 +16,23 @@ discard block |
||
16 | 16 | * @param mixed $value |
17 | 17 | * @return mixed |
18 | 18 | */ |
19 | - abstract protected function getSize($attribute, $value); |
|
19 | + abstract protected function getSize( $attribute, $value ); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Replace all placeholders. |
23 | 23 | * @param string $message |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - protected function replace($message, array $parameters) |
|
26 | + protected function replace( $message, array $parameters ) |
|
27 | 27 | { |
28 | - if (!Str::contains($message, '%s')) { |
|
28 | + if( !Str::contains( $message, '%s' ) ) { |
|
29 | 29 | return $message; |
30 | 30 | } |
31 | - return preg_replace_callback('/(%s)/', function () use (&$parameters) { |
|
32 | - foreach ($parameters as $key => $value) { |
|
33 | - return array_shift($parameters); |
|
31 | + return preg_replace_callback( '/(%s)/', function() use (&$parameters) { |
|
32 | + foreach( $parameters as $key => $value ) { |
|
33 | + return array_shift( $parameters ); |
|
34 | 34 | } |
35 | - }, $message); |
|
35 | + }, $message ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param mixed $value |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function validateAccepted($value) |
|
45 | + public function validateAccepted( $value ) |
|
46 | 46 | { |
47 | 47 | $acceptable = ['yes', 'on', '1', 1, true, 'true']; |
48 | - return $this->validateRequired($value) && in_array($value, $acceptable, true); |
|
48 | + return $this->validateRequired( $value ) && in_array( $value, $acceptable, true ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * @param mixed $value |
55 | 55 | * @return bool |
56 | 56 | */ |
57 | - public function validateBetween($value, $attribute, array $parameters) |
|
57 | + public function validateBetween( $value, $attribute, array $parameters ) |
|
58 | 58 | { |
59 | - $this->requireParameterCount(2, $parameters, 'between'); |
|
60 | - $size = $this->getSize($attribute, $value); |
|
59 | + $this->requireParameterCount( 2, $parameters, 'between' ); |
|
60 | + $size = $this->getSize( $attribute, $value ); |
|
61 | 61 | return $size >= $parameters[0] && $size <= $parameters[1]; |
62 | 62 | } |
63 | 63 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param mixed $value |
67 | 67 | * @return bool |
68 | 68 | */ |
69 | - public function validateEmail($value) |
|
69 | + public function validateEmail( $value ) |
|
70 | 70 | { |
71 | - return false !== filter_var($value, FILTER_VALIDATE_EMAIL); |
|
71 | + return false !== filter_var( $value, FILTER_VALIDATE_EMAIL ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * @param mixed $value |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | - public function validateMax($value, $attribute, array $parameters) |
|
80 | + public function validateMax( $value, $attribute, array $parameters ) |
|
81 | 81 | { |
82 | - $this->requireParameterCount(1, $parameters, 'max'); |
|
83 | - return $this->getSize($attribute, $value) <= $parameters[0]; |
|
82 | + $this->requireParameterCount( 1, $parameters, 'max' ); |
|
83 | + return $this->getSize( $attribute, $value ) <= $parameters[0]; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @param mixed $value |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - public function validateMin($value, $attribute, array $parameters) |
|
92 | + public function validateMin( $value, $attribute, array $parameters ) |
|
93 | 93 | { |
94 | - $this->requireParameterCount(1, $parameters, 'min'); |
|
95 | - return $this->getSize($attribute, $value) >= $parameters[0]; |
|
94 | + $this->requireParameterCount( 1, $parameters, 'min' ); |
|
95 | + return $this->getSize( $attribute, $value ) >= $parameters[0]; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @param mixed $value |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - public function validateNumber($value) |
|
103 | + public function validateNumber( $value ) |
|
104 | 104 | { |
105 | - return is_numeric($value); |
|
105 | + return is_numeric( $value ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | * @param mixed $value |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public function validateRequired($value) |
|
113 | + public function validateRequired( $value ) |
|
114 | 114 | { |
115 | - return is_null($value) |
|
116 | - || (is_string($value) && in_array(trim($value), ['', '[]'])) |
|
117 | - || (is_array($value) && empty($value)) |
|
115 | + return is_null( $value ) |
|
116 | + || (is_string( $value ) && in_array( trim( $value ), ['', '[]'] )) |
|
117 | + || (is_array( $value ) && empty($value)) |
|
118 | 118 | ? false |
119 | 119 | : true; |
120 | 120 | } |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | * @throws InvalidArgumentException |
128 | 128 | */ |
129 | - protected function requireParameterCount($count, array $parameters, $rule) |
|
129 | + protected function requireParameterCount( $count, array $parameters, $rule ) |
|
130 | 130 | { |
131 | - if (count($parameters) < $count) { |
|
132 | - throw new InvalidArgumentException("Validation rule $rule requires at least $count parameters."); |
|
131 | + if( count( $parameters ) < $count ) { |
|
132 | + throw new InvalidArgumentException( "Validation rule $rule requires at least $count parameters." ); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -8,12 +8,12 @@ |
||
8 | 8 | * @param int|string $postId |
9 | 9 | * @return int |
10 | 10 | */ |
11 | - public function getPostId($postId); |
|
11 | + public function getPostId( $postId ); |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @return array |
15 | 15 | */ |
16 | - public function getPostIds(array $postIds); |
|
16 | + public function getPostIds( array $postIds ); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @return bool |
@@ -1,20 +1,20 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | 4 | <h1 class="wp-heading-inline"> |
5 | - <?= esc_html(get_admin_page_title()); ?> |
|
6 | - <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome'); ?>" class="page-title-action"><?= __('About', 'site-reviews'); ?></a> |
|
5 | + <?= esc_html( get_admin_page_title() ); ?> |
|
6 | + <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome' ); ?>" class="page-title-action"><?= __( 'About', 'site-reviews' ); ?></a> |
|
7 | 7 | </h1> |
8 | 8 | <?= $notices; ?> |
9 | - <p><?= __('Click an active tab to expand/collapse all sections.', 'site-reviews'); ?></p> |
|
9 | + <p><?= __( 'Click an active tab to expand/collapse all sections.', 'site-reviews' ); ?></p> |
|
10 | 10 | <h2 class="glsr-nav-tab-wrapper nav-tab-wrapper"> |
11 | - <?php foreach ($tabs as $id => $title) : ?> |
|
11 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
12 | 12 | <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a> |
13 | 13 | <?php endforeach; ?> |
14 | 14 | </h2> |
15 | - <?php foreach ($tabs as $id => $title) : ?> |
|
15 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
16 | 16 | <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>"> |
17 | - <?php glsr()->render('pages/documentation/'.$id, $data); ?> |
|
17 | + <?php glsr()->render( 'pages/documentation/'.$id, $data ); ?> |
|
18 | 18 | </div> |
19 | 19 | <?php endforeach; ?> |
20 | 20 | <input type="hidden" name="_active_tab"> |