@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | class SiteReviewsSummaryShortcode extends Shortcode |
6 | 6 | { |
7 | - protected function hideOptions() |
|
8 | - { |
|
9 | - return [ |
|
10 | - 'rating' => __('Hide the rating', 'site-reviews'), |
|
11 | - 'stars' => __('Hide the stars', 'site-reviews'), |
|
12 | - 'summary' => __('Hide the summary', 'site-reviews'), |
|
13 | - 'bars' => __('Hide the percentage bars', 'site-reviews'), |
|
14 | - 'if_empty' => __('Hide if no reviews are found', 'site-reviews'), |
|
15 | - ]; |
|
16 | - } |
|
7 | + protected function hideOptions() |
|
8 | + { |
|
9 | + return [ |
|
10 | + 'rating' => __('Hide the rating', 'site-reviews'), |
|
11 | + 'stars' => __('Hide the stars', 'site-reviews'), |
|
12 | + 'summary' => __('Hide the summary', 'site-reviews'), |
|
13 | + 'bars' => __('Hide the percentage bars', 'site-reviews'), |
|
14 | + 'if_empty' => __('Hide if no reviews are found', 'site-reviews'), |
|
15 | + ]; |
|
16 | + } |
|
17 | 17 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | protected function hideOptions() |
8 | 8 | { |
9 | 9 | return [ |
10 | - 'rating' => __('Hide the rating', 'site-reviews'), |
|
11 | - 'stars' => __('Hide the stars', 'site-reviews'), |
|
12 | - 'summary' => __('Hide the summary', 'site-reviews'), |
|
13 | - 'bars' => __('Hide the percentage bars', 'site-reviews'), |
|
14 | - 'if_empty' => __('Hide if no reviews are found', 'site-reviews'), |
|
10 | + 'rating' => __( 'Hide the rating', 'site-reviews' ), |
|
11 | + 'stars' => __( 'Hide the stars', 'site-reviews' ), |
|
12 | + 'summary' => __( 'Hide the summary', 'site-reviews' ), |
|
13 | + 'bars' => __( 'Hide the percentage bars', 'site-reviews' ), |
|
14 | + 'if_empty' => __( 'Hide if no reviews are found', 'site-reviews' ), |
|
15 | 15 | ]; |
16 | 16 | } |
17 | 17 | } |
@@ -6,325 +6,325 @@ |
||
6 | 6 | |
7 | 7 | abstract class TinymcePopupGenerator |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - public $properties; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + public $properties; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - public $tag; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + public $tag; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $errors = []; |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $errors = []; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $required = []; |
|
24 | + /** |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $required = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - abstract public function fields(); |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + abstract public function fields(); |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $tag |
|
36 | - * @return static |
|
37 | - */ |
|
38 | - public function register($tag, array $args) |
|
39 | - { |
|
40 | - $this->tag = $tag; |
|
41 | - $this->properties = wp_parse_args($args, [ |
|
42 | - 'btn_close' => esc_html__('Close', 'site-reviews'), |
|
43 | - 'btn_okay' => esc_html__('Insert Shortcode', 'site-reviews'), |
|
44 | - 'errors' => $this->errors, |
|
45 | - 'fields' => $this->getFields(), |
|
46 | - 'label' => '['.$tag.']', |
|
47 | - 'required' => $this->required, |
|
48 | - 'title' => esc_html__('Shortcode', 'site-reviews'), |
|
49 | - ]); |
|
50 | - return $this; |
|
51 | - } |
|
34 | + /** |
|
35 | + * @param string $tag |
|
36 | + * @return static |
|
37 | + */ |
|
38 | + public function register($tag, array $args) |
|
39 | + { |
|
40 | + $this->tag = $tag; |
|
41 | + $this->properties = wp_parse_args($args, [ |
|
42 | + 'btn_close' => esc_html__('Close', 'site-reviews'), |
|
43 | + 'btn_okay' => esc_html__('Insert Shortcode', 'site-reviews'), |
|
44 | + 'errors' => $this->errors, |
|
45 | + 'fields' => $this->getFields(), |
|
46 | + 'label' => '['.$tag.']', |
|
47 | + 'required' => $this->required, |
|
48 | + 'title' => esc_html__('Shortcode', 'site-reviews'), |
|
49 | + ]); |
|
50 | + return $this; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return array |
|
55 | - */ |
|
56 | - protected function generateFields(array $fields) |
|
57 | - { |
|
58 | - $generatedFields = array_map(function ($field) { |
|
59 | - if (empty($field)) { |
|
60 | - return; |
|
61 | - } |
|
62 | - $field = $this->normalize($field); |
|
63 | - if (!method_exists($this, $method = 'normalize'.ucfirst($field['type']))) { |
|
64 | - return; |
|
65 | - } |
|
66 | - return $this->$method($field); |
|
67 | - }, $fields); |
|
68 | - return array_values(array_filter($generatedFields)); |
|
69 | - } |
|
53 | + /** |
|
54 | + * @return array |
|
55 | + */ |
|
56 | + protected function generateFields(array $fields) |
|
57 | + { |
|
58 | + $generatedFields = array_map(function ($field) { |
|
59 | + if (empty($field)) { |
|
60 | + return; |
|
61 | + } |
|
62 | + $field = $this->normalize($field); |
|
63 | + if (!method_exists($this, $method = 'normalize'.ucfirst($field['type']))) { |
|
64 | + return; |
|
65 | + } |
|
66 | + return $this->$method($field); |
|
67 | + }, $fields); |
|
68 | + return array_values(array_filter($generatedFields)); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param string $tooltip |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - protected function getCategories($tooltip = '') |
|
76 | - { |
|
77 | - $terms = glsr(Database::class)->getTerms(); |
|
78 | - if (empty($terms)) { |
|
79 | - return []; |
|
80 | - } |
|
81 | - return [ |
|
82 | - 'label' => esc_html__('Category', 'site-reviews'), |
|
83 | - 'name' => 'category', |
|
84 | - 'options' => $terms, |
|
85 | - 'tooltip' => $tooltip, |
|
86 | - 'type' => 'listbox', |
|
87 | - ]; |
|
88 | - } |
|
71 | + /** |
|
72 | + * @param string $tooltip |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + protected function getCategories($tooltip = '') |
|
76 | + { |
|
77 | + $terms = glsr(Database::class)->getTerms(); |
|
78 | + if (empty($terms)) { |
|
79 | + return []; |
|
80 | + } |
|
81 | + return [ |
|
82 | + 'label' => esc_html__('Category', 'site-reviews'), |
|
83 | + 'name' => 'category', |
|
84 | + 'options' => $terms, |
|
85 | + 'tooltip' => $tooltip, |
|
86 | + 'type' => 'listbox', |
|
87 | + ]; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function getFields() |
|
94 | - { |
|
95 | - $fields = $this->generateFields($this->fields()); |
|
96 | - if (!empty($this->errors)) { |
|
97 | - $errors = []; |
|
98 | - foreach ($this->required as $name => $alert) { |
|
99 | - if (false !== array_search($name, glsr_array_column($fields, 'name'))) { |
|
100 | - continue; |
|
101 | - } |
|
102 | - $errors[] = $this->errors[$name]; |
|
103 | - } |
|
104 | - $this->errors = $errors; |
|
105 | - } |
|
106 | - return empty($this->errors) |
|
107 | - ? $fields |
|
108 | - : $this->errors; |
|
109 | - } |
|
90 | + /** |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function getFields() |
|
94 | + { |
|
95 | + $fields = $this->generateFields($this->fields()); |
|
96 | + if (!empty($this->errors)) { |
|
97 | + $errors = []; |
|
98 | + foreach ($this->required as $name => $alert) { |
|
99 | + if (false !== array_search($name, glsr_array_column($fields, 'name'))) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + $errors[] = $this->errors[$name]; |
|
103 | + } |
|
104 | + $this->errors = $errors; |
|
105 | + } |
|
106 | + return empty($this->errors) |
|
107 | + ? $fields |
|
108 | + : $this->errors; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - protected function getHideOptions() |
|
115 | - { |
|
116 | - $classname = str_replace('Popup', 'Shortcode', get_class($this)); |
|
117 | - $hideOptions = glsr($classname)->getHideOptions(); |
|
118 | - $options = []; |
|
119 | - foreach ($hideOptions as $name => $tooltip) { |
|
120 | - $options[] = [ |
|
121 | - 'name' => 'hide_'.$name, |
|
122 | - 'text' => $name, |
|
123 | - 'tooltip' => $tooltip, |
|
124 | - 'type' => 'checkbox', |
|
125 | - ]; |
|
126 | - } |
|
127 | - return $options; |
|
128 | - } |
|
111 | + /** |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + protected function getHideOptions() |
|
115 | + { |
|
116 | + $classname = str_replace('Popup', 'Shortcode', get_class($this)); |
|
117 | + $hideOptions = glsr($classname)->getHideOptions(); |
|
118 | + $options = []; |
|
119 | + foreach ($hideOptions as $name => $tooltip) { |
|
120 | + $options[] = [ |
|
121 | + 'name' => 'hide_'.$name, |
|
122 | + 'text' => $name, |
|
123 | + 'tooltip' => $tooltip, |
|
124 | + 'type' => 'checkbox', |
|
125 | + ]; |
|
126 | + } |
|
127 | + return $options; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @param string $tooltip |
|
132 | - * @return array |
|
133 | - */ |
|
134 | - protected function getTypes($tooltip = '') |
|
135 | - { |
|
136 | - if (count(glsr()->reviewTypes) < 2) { |
|
137 | - return []; |
|
138 | - } |
|
139 | - return [ |
|
140 | - 'label' => esc_html__('Type', 'site-reviews'), |
|
141 | - 'name' => 'type', |
|
142 | - 'options' => glsr()->reviewTypes, |
|
143 | - 'tooltip' => $tooltip, |
|
144 | - 'type' => 'listbox', |
|
145 | - ]; |
|
146 | - } |
|
130 | + /** |
|
131 | + * @param string $tooltip |
|
132 | + * @return array |
|
133 | + */ |
|
134 | + protected function getTypes($tooltip = '') |
|
135 | + { |
|
136 | + if (count(glsr()->reviewTypes) < 2) { |
|
137 | + return []; |
|
138 | + } |
|
139 | + return [ |
|
140 | + 'label' => esc_html__('Type', 'site-reviews'), |
|
141 | + 'name' => 'type', |
|
142 | + 'options' => glsr()->reviewTypes, |
|
143 | + 'tooltip' => $tooltip, |
|
144 | + 'type' => 'listbox', |
|
145 | + ]; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - protected function normalize(array $field) |
|
152 | - { |
|
153 | - return wp_parse_args($field, [ |
|
154 | - 'items' => [], |
|
155 | - 'type' => '', |
|
156 | - ]); |
|
157 | - } |
|
148 | + /** |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + protected function normalize(array $field) |
|
152 | + { |
|
153 | + return wp_parse_args($field, [ |
|
154 | + 'items' => [], |
|
155 | + 'type' => '', |
|
156 | + ]); |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * @return void|array |
|
161 | - */ |
|
162 | - protected function normalizeCheckbox(array $field) |
|
163 | - { |
|
164 | - return $this->normalizeField($field, [ |
|
165 | - 'checked' => false, |
|
166 | - 'label' => '', |
|
167 | - 'minHeight' => '', |
|
168 | - 'minWidth' => '', |
|
169 | - 'name' => false, |
|
170 | - 'text' => '', |
|
171 | - 'tooltip' => '', |
|
172 | - 'type' => '', |
|
173 | - 'value' => '', |
|
174 | - ]); |
|
175 | - } |
|
159 | + /** |
|
160 | + * @return void|array |
|
161 | + */ |
|
162 | + protected function normalizeCheckbox(array $field) |
|
163 | + { |
|
164 | + return $this->normalizeField($field, [ |
|
165 | + 'checked' => false, |
|
166 | + 'label' => '', |
|
167 | + 'minHeight' => '', |
|
168 | + 'minWidth' => '', |
|
169 | + 'name' => false, |
|
170 | + 'text' => '', |
|
171 | + 'tooltip' => '', |
|
172 | + 'type' => '', |
|
173 | + 'value' => '', |
|
174 | + ]); |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * @return void|array |
|
179 | - */ |
|
180 | - protected function normalizeContainer(array $field) |
|
181 | - { |
|
182 | - if (!array_key_exists('html', $field) && !array_key_exists('items', $field)) { |
|
183 | - return; |
|
184 | - } |
|
185 | - $field['items'] = $this->generateFields($field['items']); |
|
186 | - return $field; |
|
187 | - } |
|
177 | + /** |
|
178 | + * @return void|array |
|
179 | + */ |
|
180 | + protected function normalizeContainer(array $field) |
|
181 | + { |
|
182 | + if (!array_key_exists('html', $field) && !array_key_exists('items', $field)) { |
|
183 | + return; |
|
184 | + } |
|
185 | + $field['items'] = $this->generateFields($field['items']); |
|
186 | + return $field; |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * @return void|array |
|
191 | - */ |
|
192 | - protected function normalizeField(array $field, array $defaults) |
|
193 | - { |
|
194 | - if (!$this->validate($field)) { |
|
195 | - return; |
|
196 | - } |
|
197 | - return array_filter(shortcode_atts($defaults, $field), function ($value) { |
|
198 | - return '' !== $value; |
|
199 | - }); |
|
200 | - } |
|
189 | + /** |
|
190 | + * @return void|array |
|
191 | + */ |
|
192 | + protected function normalizeField(array $field, array $defaults) |
|
193 | + { |
|
194 | + if (!$this->validate($field)) { |
|
195 | + return; |
|
196 | + } |
|
197 | + return array_filter(shortcode_atts($defaults, $field), function ($value) { |
|
198 | + return '' !== $value; |
|
199 | + }); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @return void|array |
|
204 | - */ |
|
205 | - protected function normalizeListbox(array $field) |
|
206 | - { |
|
207 | - $listbox = $this->normalizeField($field, [ |
|
208 | - 'label' => '', |
|
209 | - 'minWidth' => '', |
|
210 | - 'name' => false, |
|
211 | - 'options' => [], |
|
212 | - 'placeholder' => esc_attr__('- Select -', 'site-reviews'), |
|
213 | - 'tooltip' => '', |
|
214 | - 'type' => '', |
|
215 | - 'value' => '', |
|
216 | - ]); |
|
217 | - if (!is_array($listbox)) { |
|
218 | - return; |
|
219 | - } |
|
220 | - if (!array_key_exists('', $listbox['options'])) { |
|
221 | - $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
|
222 | - } |
|
223 | - foreach ($listbox['options'] as $value => $text) { |
|
224 | - $listbox['values'][] = [ |
|
225 | - 'text' => $text, |
|
226 | - 'value' => $value, |
|
227 | - ]; |
|
228 | - } |
|
229 | - return $listbox; |
|
230 | - } |
|
202 | + /** |
|
203 | + * @return void|array |
|
204 | + */ |
|
205 | + protected function normalizeListbox(array $field) |
|
206 | + { |
|
207 | + $listbox = $this->normalizeField($field, [ |
|
208 | + 'label' => '', |
|
209 | + 'minWidth' => '', |
|
210 | + 'name' => false, |
|
211 | + 'options' => [], |
|
212 | + 'placeholder' => esc_attr__('- Select -', 'site-reviews'), |
|
213 | + 'tooltip' => '', |
|
214 | + 'type' => '', |
|
215 | + 'value' => '', |
|
216 | + ]); |
|
217 | + if (!is_array($listbox)) { |
|
218 | + return; |
|
219 | + } |
|
220 | + if (!array_key_exists('', $listbox['options'])) { |
|
221 | + $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
|
222 | + } |
|
223 | + foreach ($listbox['options'] as $value => $text) { |
|
224 | + $listbox['values'][] = [ |
|
225 | + 'text' => $text, |
|
226 | + 'value' => $value, |
|
227 | + ]; |
|
228 | + } |
|
229 | + return $listbox; |
|
230 | + } |
|
231 | 231 | |
232 | - /** |
|
233 | - * @return void|array |
|
234 | - */ |
|
235 | - protected function normalizePost(array $field) |
|
236 | - { |
|
237 | - if (!is_array($field['query_args'])) { |
|
238 | - $field['query_args'] = []; |
|
239 | - } |
|
240 | - $posts = get_posts(wp_parse_args($field['query_args'], [ |
|
241 | - 'order' => 'ASC', |
|
242 | - 'orderby' => 'title', |
|
243 | - 'post_type' => 'post', |
|
244 | - 'posts_per_page' => 30, |
|
245 | - ])); |
|
246 | - if (!empty($posts)) { |
|
247 | - $options = []; |
|
248 | - foreach ($posts as $post) { |
|
249 | - $options[$post->ID] = esc_html($post->post_title); |
|
250 | - } |
|
251 | - $field['options'] = $options; |
|
252 | - $field['type'] = 'listbox'; |
|
253 | - return $this->normalizeListbox($field); |
|
254 | - } |
|
255 | - $this->validate($field); |
|
256 | - } |
|
232 | + /** |
|
233 | + * @return void|array |
|
234 | + */ |
|
235 | + protected function normalizePost(array $field) |
|
236 | + { |
|
237 | + if (!is_array($field['query_args'])) { |
|
238 | + $field['query_args'] = []; |
|
239 | + } |
|
240 | + $posts = get_posts(wp_parse_args($field['query_args'], [ |
|
241 | + 'order' => 'ASC', |
|
242 | + 'orderby' => 'title', |
|
243 | + 'post_type' => 'post', |
|
244 | + 'posts_per_page' => 30, |
|
245 | + ])); |
|
246 | + if (!empty($posts)) { |
|
247 | + $options = []; |
|
248 | + foreach ($posts as $post) { |
|
249 | + $options[$post->ID] = esc_html($post->post_title); |
|
250 | + } |
|
251 | + $field['options'] = $options; |
|
252 | + $field['type'] = 'listbox'; |
|
253 | + return $this->normalizeListbox($field); |
|
254 | + } |
|
255 | + $this->validate($field); |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * @return void|array |
|
260 | - */ |
|
261 | - protected function normalizeTextbox(array $field) |
|
262 | - { |
|
263 | - return $this->normalizeField($field, [ |
|
264 | - 'hidden' => false, |
|
265 | - 'label' => '', |
|
266 | - 'maxLength' => '', |
|
267 | - 'minHeight' => '', |
|
268 | - 'minWidth' => '', |
|
269 | - 'multiline' => false, |
|
270 | - 'name' => false, |
|
271 | - 'size' => '', |
|
272 | - 'text' => '', |
|
273 | - 'tooltip' => '', |
|
274 | - 'type' => '', |
|
275 | - 'value' => '', |
|
276 | - ]); |
|
277 | - } |
|
258 | + /** |
|
259 | + * @return void|array |
|
260 | + */ |
|
261 | + protected function normalizeTextbox(array $field) |
|
262 | + { |
|
263 | + return $this->normalizeField($field, [ |
|
264 | + 'hidden' => false, |
|
265 | + 'label' => '', |
|
266 | + 'maxLength' => '', |
|
267 | + 'minHeight' => '', |
|
268 | + 'minWidth' => '', |
|
269 | + 'multiline' => false, |
|
270 | + 'name' => false, |
|
271 | + 'size' => '', |
|
272 | + 'text' => '', |
|
273 | + 'tooltip' => '', |
|
274 | + 'type' => '', |
|
275 | + 'value' => '', |
|
276 | + ]); |
|
277 | + } |
|
278 | 278 | |
279 | - /** |
|
280 | - * @return bool |
|
281 | - */ |
|
282 | - protected function validate(array $field) |
|
283 | - { |
|
284 | - $args = shortcode_atts([ |
|
285 | - 'label' => '', |
|
286 | - 'name' => false, |
|
287 | - 'required' => false, |
|
288 | - ], $field); |
|
289 | - if (!$args['name']) { |
|
290 | - return false; |
|
291 | - } |
|
292 | - return $this->validateErrors($args) && $this->validateRequired($args); |
|
293 | - } |
|
279 | + /** |
|
280 | + * @return bool |
|
281 | + */ |
|
282 | + protected function validate(array $field) |
|
283 | + { |
|
284 | + $args = shortcode_atts([ |
|
285 | + 'label' => '', |
|
286 | + 'name' => false, |
|
287 | + 'required' => false, |
|
288 | + ], $field); |
|
289 | + if (!$args['name']) { |
|
290 | + return false; |
|
291 | + } |
|
292 | + return $this->validateErrors($args) && $this->validateRequired($args); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * @return bool |
|
297 | - */ |
|
298 | - protected function validateErrors(array $args) |
|
299 | - { |
|
300 | - if (!isset($args['required']['error'])) { |
|
301 | - return true; |
|
302 | - } |
|
303 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
304 | - 'html' => $args['required']['error'], |
|
305 | - 'type' => 'container', |
|
306 | - ]); |
|
307 | - return false; |
|
308 | - } |
|
295 | + /** |
|
296 | + * @return bool |
|
297 | + */ |
|
298 | + protected function validateErrors(array $args) |
|
299 | + { |
|
300 | + if (!isset($args['required']['error'])) { |
|
301 | + return true; |
|
302 | + } |
|
303 | + $this->errors[$args['name']] = $this->normalizeContainer([ |
|
304 | + 'html' => $args['required']['error'], |
|
305 | + 'type' => 'container', |
|
306 | + ]); |
|
307 | + return false; |
|
308 | + } |
|
309 | 309 | |
310 | - /** |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - protected function validateRequired(array $args) |
|
314 | - { |
|
315 | - if (false == $args['required']) { |
|
316 | - return true; |
|
317 | - } |
|
318 | - $alert = esc_html__('Some of the shortcode options are required.', 'site-reviews'); |
|
319 | - if (isset($args['required']['alert'])) { |
|
320 | - $alert = $args['required']['alert']; |
|
321 | - } elseif (!empty($args['label'])) { |
|
322 | - $alert = sprintf( |
|
323 | - esc_html_x('The "%s" option is required.', 'the option label', 'site-reviews'), |
|
324 | - str_replace(':', '', $args['label']) |
|
325 | - ); |
|
326 | - } |
|
327 | - $this->required[$args['name']] = $alert; |
|
328 | - return false; |
|
329 | - } |
|
310 | + /** |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + protected function validateRequired(array $args) |
|
314 | + { |
|
315 | + if (false == $args['required']) { |
|
316 | + return true; |
|
317 | + } |
|
318 | + $alert = esc_html__('Some of the shortcode options are required.', 'site-reviews'); |
|
319 | + if (isset($args['required']['alert'])) { |
|
320 | + $alert = $args['required']['alert']; |
|
321 | + } elseif (!empty($args['label'])) { |
|
322 | + $alert = sprintf( |
|
323 | + esc_html_x('The "%s" option is required.', 'the option label', 'site-reviews'), |
|
324 | + str_replace(':', '', $args['label']) |
|
325 | + ); |
|
326 | + } |
|
327 | + $this->required[$args['name']] = $alert; |
|
328 | + return false; |
|
329 | + } |
|
330 | 330 | } |
@@ -35,51 +35,51 @@ discard block |
||
35 | 35 | * @param string $tag |
36 | 36 | * @return static |
37 | 37 | */ |
38 | - public function register($tag, array $args) |
|
38 | + public function register( $tag, array $args ) |
|
39 | 39 | { |
40 | 40 | $this->tag = $tag; |
41 | - $this->properties = wp_parse_args($args, [ |
|
42 | - 'btn_close' => esc_html__('Close', 'site-reviews'), |
|
43 | - 'btn_okay' => esc_html__('Insert Shortcode', 'site-reviews'), |
|
41 | + $this->properties = wp_parse_args( $args, [ |
|
42 | + 'btn_close' => esc_html__( 'Close', 'site-reviews' ), |
|
43 | + 'btn_okay' => esc_html__( 'Insert Shortcode', 'site-reviews' ), |
|
44 | 44 | 'errors' => $this->errors, |
45 | 45 | 'fields' => $this->getFields(), |
46 | 46 | 'label' => '['.$tag.']', |
47 | 47 | 'required' => $this->required, |
48 | - 'title' => esc_html__('Shortcode', 'site-reviews'), |
|
49 | - ]); |
|
48 | + 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
|
49 | + ] ); |
|
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @return array |
55 | 55 | */ |
56 | - protected function generateFields(array $fields) |
|
56 | + protected function generateFields( array $fields ) |
|
57 | 57 | { |
58 | - $generatedFields = array_map(function ($field) { |
|
59 | - if (empty($field)) { |
|
58 | + $generatedFields = array_map( function( $field ) { |
|
59 | + if( empty($field) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | - $field = $this->normalize($field); |
|
63 | - if (!method_exists($this, $method = 'normalize'.ucfirst($field['type']))) { |
|
62 | + $field = $this->normalize( $field ); |
|
63 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) ) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | - return $this->$method($field); |
|
67 | - }, $fields); |
|
68 | - return array_values(array_filter($generatedFields)); |
|
66 | + return $this->$method( $field ); |
|
67 | + }, $fields ); |
|
68 | + return array_values( array_filter( $generatedFields ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @param string $tooltip |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - protected function getCategories($tooltip = '') |
|
75 | + protected function getCategories( $tooltip = '' ) |
|
76 | 76 | { |
77 | - $terms = glsr(Database::class)->getTerms(); |
|
78 | - if (empty($terms)) { |
|
77 | + $terms = glsr( Database::class )->getTerms(); |
|
78 | + if( empty($terms) ) { |
|
79 | 79 | return []; |
80 | 80 | } |
81 | 81 | return [ |
82 | - 'label' => esc_html__('Category', 'site-reviews'), |
|
82 | + 'label' => esc_html__( 'Category', 'site-reviews' ), |
|
83 | 83 | 'name' => 'category', |
84 | 84 | 'options' => $terms, |
85 | 85 | 'tooltip' => $tooltip, |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function getFields() |
94 | 94 | { |
95 | - $fields = $this->generateFields($this->fields()); |
|
96 | - if (!empty($this->errors)) { |
|
95 | + $fields = $this->generateFields( $this->fields() ); |
|
96 | + if( !empty($this->errors) ) { |
|
97 | 97 | $errors = []; |
98 | - foreach ($this->required as $name => $alert) { |
|
99 | - if (false !== array_search($name, glsr_array_column($fields, 'name'))) { |
|
98 | + foreach( $this->required as $name => $alert ) { |
|
99 | + if( false !== array_search( $name, glsr_array_column( $fields, 'name' ) ) ) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | $errors[] = $this->errors[$name]; |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function getHideOptions() |
115 | 115 | { |
116 | - $classname = str_replace('Popup', 'Shortcode', get_class($this)); |
|
117 | - $hideOptions = glsr($classname)->getHideOptions(); |
|
116 | + $classname = str_replace( 'Popup', 'Shortcode', get_class( $this ) ); |
|
117 | + $hideOptions = glsr( $classname )->getHideOptions(); |
|
118 | 118 | $options = []; |
119 | - foreach ($hideOptions as $name => $tooltip) { |
|
119 | + foreach( $hideOptions as $name => $tooltip ) { |
|
120 | 120 | $options[] = [ |
121 | 121 | 'name' => 'hide_'.$name, |
122 | 122 | 'text' => $name, |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param string $tooltip |
132 | 132 | * @return array |
133 | 133 | */ |
134 | - protected function getTypes($tooltip = '') |
|
134 | + protected function getTypes( $tooltip = '' ) |
|
135 | 135 | { |
136 | - if (count(glsr()->reviewTypes) < 2) { |
|
136 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
137 | 137 | return []; |
138 | 138 | } |
139 | 139 | return [ |
140 | - 'label' => esc_html__('Type', 'site-reviews'), |
|
140 | + 'label' => esc_html__( 'Type', 'site-reviews' ), |
|
141 | 141 | 'name' => 'type', |
142 | 142 | 'options' => glsr()->reviewTypes, |
143 | 143 | 'tooltip' => $tooltip, |
@@ -148,20 +148,20 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * @return array |
150 | 150 | */ |
151 | - protected function normalize(array $field) |
|
151 | + protected function normalize( array $field ) |
|
152 | 152 | { |
153 | - return wp_parse_args($field, [ |
|
153 | + return wp_parse_args( $field, [ |
|
154 | 154 | 'items' => [], |
155 | 155 | 'type' => '', |
156 | - ]); |
|
156 | + ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @return void|array |
161 | 161 | */ |
162 | - protected function normalizeCheckbox(array $field) |
|
162 | + protected function normalizeCheckbox( array $field ) |
|
163 | 163 | { |
164 | - return $this->normalizeField($field, [ |
|
164 | + return $this->normalizeField( $field, [ |
|
165 | 165 | 'checked' => false, |
166 | 166 | 'label' => '', |
167 | 167 | 'minHeight' => '', |
@@ -171,30 +171,30 @@ discard block |
||
171 | 171 | 'tooltip' => '', |
172 | 172 | 'type' => '', |
173 | 173 | 'value' => '', |
174 | - ]); |
|
174 | + ] ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @return void|array |
179 | 179 | */ |
180 | - protected function normalizeContainer(array $field) |
|
180 | + protected function normalizeContainer( array $field ) |
|
181 | 181 | { |
182 | - if (!array_key_exists('html', $field) && !array_key_exists('items', $field)) { |
|
182 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) ) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | - $field['items'] = $this->generateFields($field['items']); |
|
185 | + $field['items'] = $this->generateFields( $field['items'] ); |
|
186 | 186 | return $field; |
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @return void|array |
191 | 191 | */ |
192 | - protected function normalizeField(array $field, array $defaults) |
|
192 | + protected function normalizeField( array $field, array $defaults ) |
|
193 | 193 | { |
194 | - if (!$this->validate($field)) { |
|
194 | + if( !$this->validate( $field ) ) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | - return array_filter(shortcode_atts($defaults, $field), function ($value) { |
|
197 | + return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
|
198 | 198 | return '' !== $value; |
199 | 199 | }); |
200 | 200 | } |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @return void|array |
204 | 204 | */ |
205 | - protected function normalizeListbox(array $field) |
|
205 | + protected function normalizeListbox( array $field ) |
|
206 | 206 | { |
207 | - $listbox = $this->normalizeField($field, [ |
|
207 | + $listbox = $this->normalizeField( $field, [ |
|
208 | 208 | 'label' => '', |
209 | 209 | 'minWidth' => '', |
210 | 210 | 'name' => false, |
211 | 211 | 'options' => [], |
212 | - 'placeholder' => esc_attr__('- Select -', 'site-reviews'), |
|
212 | + 'placeholder' => esc_attr__( '- Select -', 'site-reviews' ), |
|
213 | 213 | 'tooltip' => '', |
214 | 214 | 'type' => '', |
215 | 215 | 'value' => '', |
216 | - ]); |
|
217 | - if (!is_array($listbox)) { |
|
216 | + ] ); |
|
217 | + if( !is_array( $listbox ) ) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | - if (!array_key_exists('', $listbox['options'])) { |
|
220 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
221 | 221 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
222 | 222 | } |
223 | - foreach ($listbox['options'] as $value => $text) { |
|
223 | + foreach( $listbox['options'] as $value => $text ) { |
|
224 | 224 | $listbox['values'][] = [ |
225 | 225 | 'text' => $text, |
226 | 226 | 'value' => $value, |
@@ -232,35 +232,35 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * @return void|array |
234 | 234 | */ |
235 | - protected function normalizePost(array $field) |
|
235 | + protected function normalizePost( array $field ) |
|
236 | 236 | { |
237 | - if (!is_array($field['query_args'])) { |
|
237 | + if( !is_array( $field['query_args'] ) ) { |
|
238 | 238 | $field['query_args'] = []; |
239 | 239 | } |
240 | - $posts = get_posts(wp_parse_args($field['query_args'], [ |
|
240 | + $posts = get_posts( wp_parse_args( $field['query_args'], [ |
|
241 | 241 | 'order' => 'ASC', |
242 | 242 | 'orderby' => 'title', |
243 | 243 | 'post_type' => 'post', |
244 | 244 | 'posts_per_page' => 30, |
245 | - ])); |
|
246 | - if (!empty($posts)) { |
|
245 | + ] ) ); |
|
246 | + if( !empty($posts) ) { |
|
247 | 247 | $options = []; |
248 | - foreach ($posts as $post) { |
|
249 | - $options[$post->ID] = esc_html($post->post_title); |
|
248 | + foreach( $posts as $post ) { |
|
249 | + $options[$post->ID] = esc_html( $post->post_title ); |
|
250 | 250 | } |
251 | 251 | $field['options'] = $options; |
252 | 252 | $field['type'] = 'listbox'; |
253 | - return $this->normalizeListbox($field); |
|
253 | + return $this->normalizeListbox( $field ); |
|
254 | 254 | } |
255 | - $this->validate($field); |
|
255 | + $this->validate( $field ); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | 259 | * @return void|array |
260 | 260 | */ |
261 | - protected function normalizeTextbox(array $field) |
|
261 | + protected function normalizeTextbox( array $field ) |
|
262 | 262 | { |
263 | - return $this->normalizeField($field, [ |
|
263 | + return $this->normalizeField( $field, [ |
|
264 | 264 | 'hidden' => false, |
265 | 265 | 'label' => '', |
266 | 266 | 'maxLength' => '', |
@@ -273,55 +273,55 @@ discard block |
||
273 | 273 | 'tooltip' => '', |
274 | 274 | 'type' => '', |
275 | 275 | 'value' => '', |
276 | - ]); |
|
276 | + ] ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - protected function validate(array $field) |
|
282 | + protected function validate( array $field ) |
|
283 | 283 | { |
284 | - $args = shortcode_atts([ |
|
284 | + $args = shortcode_atts( [ |
|
285 | 285 | 'label' => '', |
286 | 286 | 'name' => false, |
287 | 287 | 'required' => false, |
288 | - ], $field); |
|
289 | - if (!$args['name']) { |
|
288 | + ], $field ); |
|
289 | + if( !$args['name'] ) { |
|
290 | 290 | return false; |
291 | 291 | } |
292 | - return $this->validateErrors($args) && $this->validateRequired($args); |
|
292 | + return $this->validateErrors( $args ) && $this->validateRequired( $args ); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | - protected function validateErrors(array $args) |
|
298 | + protected function validateErrors( array $args ) |
|
299 | 299 | { |
300 | - if (!isset($args['required']['error'])) { |
|
300 | + if( !isset($args['required']['error']) ) { |
|
301 | 301 | return true; |
302 | 302 | } |
303 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
303 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
304 | 304 | 'html' => $args['required']['error'], |
305 | 305 | 'type' => 'container', |
306 | - ]); |
|
306 | + ] ); |
|
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | 311 | * @return bool |
312 | 312 | */ |
313 | - protected function validateRequired(array $args) |
|
313 | + protected function validateRequired( array $args ) |
|
314 | 314 | { |
315 | - if (false == $args['required']) { |
|
315 | + if( false == $args['required'] ) { |
|
316 | 316 | return true; |
317 | 317 | } |
318 | - $alert = esc_html__('Some of the shortcode options are required.', 'site-reviews'); |
|
319 | - if (isset($args['required']['alert'])) { |
|
318 | + $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
|
319 | + if( isset($args['required']['alert']) ) { |
|
320 | 320 | $alert = $args['required']['alert']; |
321 | - } elseif (!empty($args['label'])) { |
|
321 | + } elseif( !empty($args['label']) ) { |
|
322 | 322 | $alert = sprintf( |
323 | - esc_html_x('The "%s" option is required.', 'the option label', 'site-reviews'), |
|
324 | - str_replace(':', '', $args['label']) |
|
323 | + esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
|
324 | + str_replace( ':', '', $args['label'] ) |
|
325 | 325 | ); |
326 | 326 | } |
327 | 327 | $this->required[$args['name']] = $alert; |
@@ -318,7 +318,8 @@ |
||
318 | 318 | $alert = esc_html__('Some of the shortcode options are required.', 'site-reviews'); |
319 | 319 | if (isset($args['required']['alert'])) { |
320 | 320 | $alert = $args['required']['alert']; |
321 | - } elseif (!empty($args['label'])) { |
|
321 | + } |
|
322 | + elseif (!empty($args['label'])) { |
|
322 | 323 | $alert = sprintf( |
323 | 324 | esc_html_x('The "%s" option is required.', 'the option label', 'site-reviews'), |
324 | 325 | str_replace(':', '', $args['label']) |
@@ -6,18 +6,18 @@ |
||
6 | 6 | |
7 | 7 | class PaginationDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'before_page_number' => '<span class="meta-nav screen-reader-text">'.__('Page', 'site-reviews').' </span>', |
|
16 | - 'format' => '?'.glsr()->constant('PAGED_QUERY_VAR').'=%#%', |
|
17 | - 'mid_size' => 1, |
|
18 | - 'next_text' => __('Next →', 'site-reviews'), |
|
19 | - 'prev_text' => __('← Previous', 'site-reviews'), |
|
20 | - 'type' => 'plain', |
|
21 | - ]; |
|
22 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'before_page_number' => '<span class="meta-nav screen-reader-text">'.__('Page', 'site-reviews').' </span>', |
|
16 | + 'format' => '?'.glsr()->constant('PAGED_QUERY_VAR').'=%#%', |
|
17 | + 'mid_size' => 1, |
|
18 | + 'next_text' => __('Next →', 'site-reviews'), |
|
19 | + 'prev_text' => __('← Previous', 'site-reviews'), |
|
20 | + 'type' => 'plain', |
|
21 | + ]; |
|
22 | + } |
|
23 | 23 | } |
@@ -12,11 +12,11 @@ |
||
12 | 12 | protected function defaults() |
13 | 13 | { |
14 | 14 | return [ |
15 | - 'before_page_number' => '<span class="meta-nav screen-reader-text">'.__('Page', 'site-reviews').' </span>', |
|
16 | - 'format' => '?'.glsr()->constant('PAGED_QUERY_VAR').'=%#%', |
|
15 | + 'before_page_number' => '<span class="meta-nav screen-reader-text">'.__( 'Page', 'site-reviews' ).' </span>', |
|
16 | + 'format' => '?'.glsr()->constant( 'PAGED_QUERY_VAR' ).'=%#%', |
|
17 | 17 | 'mid_size' => 1, |
18 | - 'next_text' => __('Next →', 'site-reviews'), |
|
19 | - 'prev_text' => __('← Previous', 'site-reviews'), |
|
18 | + 'next_text' => __( 'Next →', 'site-reviews' ), |
|
19 | + 'prev_text' => __( '← Previous', 'site-reviews' ), |
|
20 | 20 | 'type' => 'plain', |
21 | 21 | ]; |
22 | 22 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | |
7 | 7 | class ReviewsDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assigned_to' => '', |
|
16 | - 'category' => '', |
|
17 | - 'count' => 10, |
|
18 | - 'offset' => '', |
|
19 | - 'order' => 'DESC', |
|
20 | - 'orderby' => 'date', |
|
21 | - 'pagination' => false, |
|
22 | - 'post__in' => [], |
|
23 | - 'post__not_in' => [], |
|
24 | - 'rating' => '', |
|
25 | - 'type' => '', |
|
26 | - ]; |
|
27 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assigned_to' => '', |
|
16 | + 'category' => '', |
|
17 | + 'count' => 10, |
|
18 | + 'offset' => '', |
|
19 | + 'order' => 'DESC', |
|
20 | + 'orderby' => 'date', |
|
21 | + 'pagination' => false, |
|
22 | + 'post__in' => [], |
|
23 | + 'post__not_in' => [], |
|
24 | + 'rating' => '', |
|
25 | + 'type' => '', |
|
26 | + ]; |
|
27 | + } |
|
28 | 28 | } |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsSummaryDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'labels', |
|
14 | - 'text', |
|
15 | - 'title', |
|
16 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'labels', |
|
14 | + 'text', |
|
15 | + 'title', |
|
16 | + ]; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - protected function defaults() |
|
22 | - { |
|
23 | - return [ |
|
24 | - 'assigned_to' => '', |
|
25 | - 'category' => '', |
|
26 | - 'class' => '', |
|
27 | - 'hide' => '', |
|
28 | - 'id' => '', |
|
29 | - 'labels' => '', |
|
30 | - 'rating' => 1, |
|
31 | - 'schema' => false, |
|
32 | - 'text' => '', |
|
33 | - 'title' => '', |
|
34 | - 'type' => 'local', |
|
35 | - ]; |
|
36 | - } |
|
18 | + /** |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + protected function defaults() |
|
22 | + { |
|
23 | + return [ |
|
24 | + 'assigned_to' => '', |
|
25 | + 'category' => '', |
|
26 | + 'class' => '', |
|
27 | + 'hide' => '', |
|
28 | + 'id' => '', |
|
29 | + 'labels' => '', |
|
30 | + 'rating' => 1, |
|
31 | + 'schema' => false, |
|
32 | + 'text' => '', |
|
33 | + 'title' => '', |
|
34 | + 'type' => 'local', |
|
35 | + ]; |
|
36 | + } |
|
37 | 37 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | |
7 | 7 | class ValidationStringsDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'accepted' => __('This field must be accepted.', 'site-reviews'), |
|
16 | - 'between' => __('This field value must be between %s and %s.', 'site-reviews'), |
|
17 | - 'betweenlength' => __('This field must have between %s and %s characters.', 'site-reviews'), |
|
18 | - 'email' => __('This field requires a valid e-mail address.', 'site-reviews'), |
|
19 | - 'errors' => __('Please fix the submission errors.', 'site-reviews'), |
|
20 | - 'max' => __('Maximum value for this field is %s.', 'site-reviews'), |
|
21 | - 'maxlength' => __('This field allows a maximum of %s characters.', 'site-reviews'), |
|
22 | - 'min' => __('Minimum value for this field is %s.', 'site-reviews'), |
|
23 | - 'minlength' => __('This field requires a minimum of %s characters.', 'site-reviews'), |
|
24 | - 'number' => __('This field requires a number.', 'site-reviews'), |
|
25 | - 'required' => __('This field is required.', 'site-reviews'), |
|
26 | - 'unsupported' => __('The review could not be submitted (unsupported browser).', 'site-reviews'), |
|
27 | - ]; |
|
28 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'accepted' => __('This field must be accepted.', 'site-reviews'), |
|
16 | + 'between' => __('This field value must be between %s and %s.', 'site-reviews'), |
|
17 | + 'betweenlength' => __('This field must have between %s and %s characters.', 'site-reviews'), |
|
18 | + 'email' => __('This field requires a valid e-mail address.', 'site-reviews'), |
|
19 | + 'errors' => __('Please fix the submission errors.', 'site-reviews'), |
|
20 | + 'max' => __('Maximum value for this field is %s.', 'site-reviews'), |
|
21 | + 'maxlength' => __('This field allows a maximum of %s characters.', 'site-reviews'), |
|
22 | + 'min' => __('Minimum value for this field is %s.', 'site-reviews'), |
|
23 | + 'minlength' => __('This field requires a minimum of %s characters.', 'site-reviews'), |
|
24 | + 'number' => __('This field requires a number.', 'site-reviews'), |
|
25 | + 'required' => __('This field is required.', 'site-reviews'), |
|
26 | + 'unsupported' => __('The review could not be submitted (unsupported browser).', 'site-reviews'), |
|
27 | + ]; |
|
28 | + } |
|
29 | 29 | } |
@@ -12,18 +12,18 @@ |
||
12 | 12 | protected function defaults() |
13 | 13 | { |
14 | 14 | return [ |
15 | - 'accepted' => __('This field must be accepted.', 'site-reviews'), |
|
16 | - 'between' => __('This field value must be between %s and %s.', 'site-reviews'), |
|
17 | - 'betweenlength' => __('This field must have between %s and %s characters.', 'site-reviews'), |
|
18 | - 'email' => __('This field requires a valid e-mail address.', 'site-reviews'), |
|
19 | - 'errors' => __('Please fix the submission errors.', 'site-reviews'), |
|
20 | - 'max' => __('Maximum value for this field is %s.', 'site-reviews'), |
|
21 | - 'maxlength' => __('This field allows a maximum of %s characters.', 'site-reviews'), |
|
22 | - 'min' => __('Minimum value for this field is %s.', 'site-reviews'), |
|
23 | - 'minlength' => __('This field requires a minimum of %s characters.', 'site-reviews'), |
|
24 | - 'number' => __('This field requires a number.', 'site-reviews'), |
|
25 | - 'required' => __('This field is required.', 'site-reviews'), |
|
26 | - 'unsupported' => __('The review could not be submitted (unsupported browser).', 'site-reviews'), |
|
15 | + 'accepted' => __( 'This field must be accepted.', 'site-reviews' ), |
|
16 | + 'between' => __( 'This field value must be between %s and %s.', 'site-reviews' ), |
|
17 | + 'betweenlength' => __( 'This field must have between %s and %s characters.', 'site-reviews' ), |
|
18 | + 'email' => __( 'This field requires a valid e-mail address.', 'site-reviews' ), |
|
19 | + 'errors' => __( 'Please fix the submission errors.', 'site-reviews' ), |
|
20 | + 'max' => __( 'Maximum value for this field is %s.', 'site-reviews' ), |
|
21 | + 'maxlength' => __( 'This field allows a maximum of %s characters.', 'site-reviews' ), |
|
22 | + 'min' => __( 'Minimum value for this field is %s.', 'site-reviews' ), |
|
23 | + 'minlength' => __( 'This field requires a minimum of %s characters.', 'site-reviews' ), |
|
24 | + 'number' => __( 'This field requires a number.', 'site-reviews' ), |
|
25 | + 'required' => __( 'This field is required.', 'site-reviews' ), |
|
26 | + 'unsupported' => __( 'The review could not be submitted (unsupported browser).', 'site-reviews' ), |
|
27 | 27 | ]; |
28 | 28 | } |
29 | 29 | } |
@@ -6,33 +6,33 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'fallback', |
|
14 | - 'title', |
|
15 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'fallback', |
|
14 | + 'title', |
|
15 | + ]; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - protected function defaults() |
|
21 | - { |
|
22 | - return [ |
|
23 | - 'assigned_to' => '', |
|
24 | - 'category' => '', |
|
25 | - 'class' => '', |
|
26 | - 'count' => 5, |
|
27 | - 'fallback' => '', |
|
28 | - 'hide' => [], |
|
29 | - 'id' => '', |
|
30 | - 'offset' => '', |
|
31 | - 'pagination' => false, |
|
32 | - 'rating' => 1, |
|
33 | - 'schema' => false, |
|
34 | - 'title' => '', |
|
35 | - 'type' => 'local', |
|
36 | - ]; |
|
37 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + protected function defaults() |
|
21 | + { |
|
22 | + return [ |
|
23 | + 'assigned_to' => '', |
|
24 | + 'category' => '', |
|
25 | + 'class' => '', |
|
26 | + 'count' => 5, |
|
27 | + 'fallback' => '', |
|
28 | + 'hide' => [], |
|
29 | + 'id' => '', |
|
30 | + 'offset' => '', |
|
31 | + 'pagination' => false, |
|
32 | + 'rating' => 1, |
|
33 | + 'schema' => false, |
|
34 | + 'title' => '', |
|
35 | + 'type' => 'local', |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | 'avatar' => '', |
19 | 19 | 'content' => '', |
20 | 20 | 'custom' => '', |
21 | - 'date' => current_time('mysql'), |
|
21 | + 'date' => current_time( 'mysql' ), |
|
22 | 22 | 'email' => '', |
23 | - 'ip_address' => glsr(Helper::class)->getIpAddress(), |
|
23 | + 'ip_address' => glsr( Helper::class )->getIpAddress(), |
|
24 | 24 | 'pinned' => false, |
25 | 25 | 'rating' => '', |
26 | 26 | 'response' => '', |
27 | - 'review_id' => md5(time().mt_rand()), |
|
27 | + 'review_id' => md5( time().mt_rand() ), |
|
28 | 28 | 'review_type' => 'local', |
29 | 29 | 'title' => '', |
30 | 30 | 'url' => '', |
@@ -7,41 +7,41 @@ |
||
7 | 7 | |
8 | 8 | class CreateReviewDefaults extends Defaults |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $guarded = [ |
|
14 | - 'assigned_to', |
|
15 | - 'content', |
|
16 | - 'date', |
|
17 | - 'pinned', |
|
18 | - 'response', |
|
19 | - 'review_id', |
|
20 | - 'review_type', |
|
21 | - 'title', |
|
22 | - ]; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $guarded = [ |
|
14 | + 'assigned_to', |
|
15 | + 'content', |
|
16 | + 'date', |
|
17 | + 'pinned', |
|
18 | + 'response', |
|
19 | + 'review_id', |
|
20 | + 'review_type', |
|
21 | + 'title', |
|
22 | + ]; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - protected function defaults() |
|
28 | - { |
|
29 | - return [ |
|
30 | - 'assigned_to' => '', |
|
31 | - 'author' => '', |
|
32 | - 'avatar' => '', |
|
33 | - 'content' => '', |
|
34 | - 'custom' => '', |
|
35 | - 'date' => current_time('mysql'), |
|
36 | - 'email' => '', |
|
37 | - 'ip_address' => glsr(Helper::class)->getIpAddress(), |
|
38 | - 'pinned' => false, |
|
39 | - 'rating' => '', |
|
40 | - 'response' => '', |
|
41 | - 'review_id' => md5(time().mt_rand()), |
|
42 | - 'review_type' => 'local', |
|
43 | - 'title' => '', |
|
44 | - 'url' => '', |
|
45 | - ]; |
|
46 | - } |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + protected function defaults() |
|
28 | + { |
|
29 | + return [ |
|
30 | + 'assigned_to' => '', |
|
31 | + 'author' => '', |
|
32 | + 'avatar' => '', |
|
33 | + 'content' => '', |
|
34 | + 'custom' => '', |
|
35 | + 'date' => current_time('mysql'), |
|
36 | + 'email' => '', |
|
37 | + 'ip_address' => glsr(Helper::class)->getIpAddress(), |
|
38 | + 'pinned' => false, |
|
39 | + 'rating' => '', |
|
40 | + 'response' => '', |
|
41 | + 'review_id' => md5(time().mt_rand()), |
|
42 | + 'review_type' => 'local', |
|
43 | + 'title' => '', |
|
44 | + 'url' => '', |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsFormDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'description', |
|
14 | - 'title', |
|
15 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'description', |
|
14 | + 'title', |
|
15 | + ]; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - protected function defaults() |
|
21 | - { |
|
22 | - return [ |
|
23 | - 'assign_to' => '', |
|
24 | - 'category' => '', |
|
25 | - 'class' => '', |
|
26 | - 'description' => '', |
|
27 | - 'excluded' => '', |
|
28 | - 'hide' => '', |
|
29 | - 'id' => '', |
|
30 | - 'title' => '', |
|
31 | - ]; |
|
32 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + protected function defaults() |
|
21 | + { |
|
22 | + return [ |
|
23 | + 'assign_to' => '', |
|
24 | + 'category' => '', |
|
25 | + 'class' => '', |
|
26 | + 'description' => '', |
|
27 | + 'excluded' => '', |
|
28 | + 'hide' => '', |
|
29 | + 'id' => '', |
|
30 | + 'title' => '', |
|
31 | + ]; |
|
32 | + } |
|
33 | 33 | } |