Conditions | 1 |
Paths | 1 |
Total Lines | 281 |
Code Lines | 206 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
9 | public function designConfig(): array |
||
10 | { |
||
11 | $config = [ |
||
12 | 'style_col_gap' => [ |
||
13 | 'css' => [ |
||
14 | [ |
||
15 | 'selector' => '.glsr', |
||
16 | 'property' => '--glsr-form-col-gap', |
||
17 | ], |
||
18 | ], |
||
19 | 'group' => 'design', |
||
20 | 'hasDynamicData' => false, |
||
21 | 'hasVariables' => true, |
||
22 | 'inline' => true, |
||
23 | 'label' => esc_html_x('Column Gap', 'admin-text', 'site-reviews'), |
||
24 | 'placeholder' => '', |
||
25 | 'tab' => 'content', |
||
26 | 'themeStyle' => true, |
||
27 | 'type' => 'number', |
||
28 | 'units' => true, |
||
29 | ], |
||
30 | 'style_row_gap' => [ |
||
31 | 'css' => [ |
||
32 | [ |
||
33 | 'selector' => '.glsr', |
||
34 | 'property' => '--glsr-form-row-gap', |
||
35 | ], |
||
36 | ], |
||
37 | 'group' => 'design', |
||
38 | 'hasDynamicData' => false, |
||
39 | 'hasVariables' => true, |
||
40 | 'inline' => true, |
||
41 | 'label' => esc_html_x('Row Gap', 'admin-text', 'site-reviews'), |
||
42 | 'placeholder' => '', |
||
43 | 'tab' => 'content', |
||
44 | 'themeStyle' => true, |
||
45 | 'type' => 'number', |
||
46 | 'units' => true, |
||
47 | ], |
||
48 | 'style_field_separator' => [ |
||
49 | 'group' => 'design', |
||
50 | 'label' => esc_html_x('Fields', 'admin-text', 'site-reviews'), |
||
51 | 'tab' => 'content', |
||
52 | 'themeStyle' => true, |
||
53 | 'type' => 'separator', |
||
54 | ], |
||
55 | 'style_field_background_color' => [ |
||
56 | 'css' => [ |
||
57 | [ |
||
58 | 'selector' => '.glsr-textarea, .glsr-input', |
||
59 | 'property' => 'background-color', |
||
60 | ], |
||
61 | ], |
||
62 | 'group' => 'design', |
||
63 | 'label' => esc_html_x('Background color', 'admin-text', 'site-reviews'), |
||
64 | 'tab' => 'content', |
||
65 | 'themeStyle' => true, |
||
66 | 'type' => 'color', |
||
67 | ], |
||
68 | 'style_field_border' => [ |
||
69 | 'css' => [ |
||
70 | [ |
||
71 | 'selector' => '.glsr-textarea, .glsr-input', |
||
72 | 'property' => 'border', |
||
73 | ], |
||
74 | ], |
||
75 | 'group' => 'design', |
||
76 | 'label' => esc_html_x('Border', 'admin-text', 'site-reviews'), |
||
77 | 'tab' => 'content', |
||
78 | 'themeStyle' => true, |
||
79 | 'type' => 'border', |
||
80 | ], |
||
81 | 'style_field_typography' => [ |
||
82 | 'css' => [ |
||
83 | [ |
||
84 | 'selector' => '.glsr-textarea, .glsr-input, .glsr-toggle label, .glsr-toggle-switch', |
||
85 | 'property' => 'font', |
||
86 | ], |
||
87 | ], |
||
88 | 'group' => 'design', |
||
89 | 'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'), |
||
90 | 'tab' => 'content', |
||
91 | 'themeStyle' => true, |
||
92 | 'type' => 'typography', |
||
93 | ], |
||
94 | 'style_field_label_typography' => [ |
||
95 | 'css' => [ |
||
96 | [ |
||
97 | 'selector' => 'label.glsr-label', |
||
98 | 'property' => 'font', |
||
99 | ], |
||
100 | ], |
||
101 | 'group' => 'design', |
||
102 | 'label' => esc_html_x('Labels', 'admin-text', 'site-reviews'), |
||
103 | 'tab' => 'content', |
||
104 | 'themeStyle' => true, |
||
105 | 'type' => 'typography', |
||
106 | ], |
||
107 | 'style_field_placeholder' => [ |
||
108 | 'css' => [ |
||
109 | [ |
||
110 | 'selector' => '::placeholder', |
||
111 | 'property' => 'font', |
||
112 | ], |
||
113 | ], |
||
114 | 'group' => 'design', |
||
115 | 'label' => esc_html_x('Placeholder', 'admin-text', 'site-reviews'), |
||
116 | 'tab' => 'content', |
||
117 | 'themeStyle' => true, |
||
118 | 'type' => 'typography', |
||
119 | ], |
||
120 | 'style_rating_separator' => [ |
||
121 | 'group' => 'design', |
||
122 | 'label' => esc_html_x('Rating Field', 'admin-text', 'site-reviews'), |
||
123 | 'tab' => 'content', |
||
124 | 'themeStyle' => true, |
||
125 | 'type' => 'separator', |
||
126 | ], |
||
127 | 'style_rating_color' => [ |
||
128 | 'css' => [ |
||
129 | [ |
||
130 | 'selector' => '.glsr:not([data-theme])', |
||
131 | 'property' => '--glsr-form-star-bg', |
||
132 | ], |
||
133 | [ |
||
134 | 'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span', |
||
135 | 'property' => 'background', |
||
136 | 'value' => 'var(--glsr-form-star-bg)', |
||
137 | ], |
||
138 | [ |
||
139 | 'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span', |
||
140 | 'property' => 'mask-image', |
||
141 | 'value' => 'var(--glsr-star-empty)', |
||
142 | ], |
||
143 | [ |
||
144 | 'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span', |
||
145 | 'property' => 'mask-size', |
||
146 | 'value' => '100%', |
||
147 | ], |
||
148 | [ |
||
149 | 'selector' => '.glsr:not([data-theme]) .glsr-field .glsr-star-rating--stars > span:is(.gl-active, .gl-active.gl-selected)', |
||
150 | 'property' => 'background', |
||
151 | 'value' => 'var(--glsr-form-star-bg)', |
||
152 | ], |
||
153 | [ |
||
154 | 'selector' => '.glsr:not([data-theme]) .glsr-field .glsr-star-rating--stars > span:is(.gl-active, .gl-active.gl-selected)', |
||
155 | 'property' => 'mask-image', |
||
156 | 'value' => 'var(--glsr-star-full)', |
||
157 | ], |
||
158 | ], |
||
159 | 'group' => 'design', |
||
160 | 'label' => esc_html_x('Star Color', 'admin-text', 'site-reviews'), |
||
161 | 'tab' => 'content', |
||
162 | 'themeStyle' => true, |
||
163 | 'type' => 'color', |
||
164 | ], |
||
165 | 'style_rating_size' => [ |
||
166 | 'css' => [ |
||
167 | [ |
||
168 | 'selector' => '.glsr', |
||
169 | 'property' => '--glsr-form-star', |
||
170 | ], |
||
171 | ], |
||
172 | 'group' => 'design', |
||
173 | 'hasDynamicData' => false, |
||
174 | 'hasVariables' => true, |
||
175 | 'inline' => true, |
||
176 | 'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
||
177 | 'placeholder' => '', |
||
178 | 'tab' => 'content', |
||
179 | 'themeStyle' => true, |
||
180 | 'type' => 'number', |
||
181 | 'units' => true, |
||
182 | ], |
||
183 | 'style_rating_gap' => [ |
||
184 | 'css' => [ |
||
185 | [ |
||
186 | 'selector' => '.glsr-field-rating span[data-rating]', |
||
187 | 'property' => 'column-gap', |
||
188 | ], |
||
189 | ], |
||
190 | 'group' => 'design', |
||
191 | 'hasDynamicData' => false, |
||
192 | 'hasVariables' => true, |
||
193 | 'inline' => true, |
||
194 | 'label' => esc_html_x('Star Spacing', 'admin-text', 'site-reviews'), |
||
195 | 'placeholder' => '', |
||
196 | 'tab' => 'content', |
||
197 | 'themeStyle' => true, |
||
198 | 'type' => 'number', |
||
199 | 'units' => true, |
||
200 | ], |
||
201 | 'style_toggle_separator' => [ |
||
202 | 'group' => 'design', |
||
203 | 'label' => esc_html_x('Toggle Field', 'admin-text', 'site-reviews'), |
||
204 | 'tab' => 'content', |
||
205 | 'themeStyle' => true, |
||
206 | 'type' => 'separator', |
||
207 | ], |
||
208 | 'style_toggle_color' => [ |
||
209 | 'css' => [ |
||
210 | [ |
||
211 | 'selector' => '.glsr-field-toggle', |
||
212 | 'property' => '--glsr-toggle-bg-1', |
||
213 | ], |
||
214 | ], |
||
215 | 'group' => 'design', |
||
216 | 'label' => esc_html_x('Toggle Color', 'admin-text', 'site-reviews'), |
||
217 | 'tab' => 'content', |
||
218 | 'themeStyle' => true, |
||
219 | 'type' => 'color', |
||
220 | ], |
||
221 | 'style_button_separator' => [ |
||
222 | 'group' => 'design', |
||
223 | 'label' => esc_html_x('Submit Button', 'admin-text', 'site-reviews'), |
||
224 | 'tab' => 'content', |
||
225 | 'themeStyle' => true, |
||
226 | 'type' => 'separator', |
||
227 | ], |
||
228 | 'style_button_size' => [ |
||
229 | 'group' => 'design', |
||
230 | 'inline' => true, |
||
231 | 'label' => esc_html_x('Size', 'admin-text', 'site-reviews'), |
||
232 | 'options' => $this->control_options['buttonSizes'] ?? [], |
||
233 | 'placeholder' => esc_html_x('Default', 'admin-text', 'site-reviews'), |
||
234 | 'tab' => 'content', |
||
235 | 'themeStyle' => true, |
||
236 | 'type' => 'select', |
||
237 | ], |
||
238 | 'style_button_preset' => [ |
||
239 | 'default' => 'primary', |
||
240 | 'group' => 'design', |
||
241 | 'inline' => true, |
||
242 | 'label' => esc_html_x('Style', 'admin-text', 'site-reviews'), |
||
243 | 'options' => $this->control_options['styles'] ?? [], |
||
244 | 'placeholder' => esc_html_x('None', 'admin-text', 'site-reviews'), |
||
245 | 'tab' => 'content', |
||
246 | 'themeStyle' => true, |
||
247 | 'type' => 'select', |
||
248 | ], |
||
249 | 'style_button_background_color' => [ |
||
250 | 'css' => [ |
||
251 | [ |
||
252 | 'selector' => '.bricks-button', |
||
253 | 'property' => 'background-color', |
||
254 | ], |
||
255 | ], |
||
256 | 'group' => 'design', |
||
257 | 'label' => esc_html_x('Background', 'admin-text', 'site-reviews'), |
||
258 | 'tab' => 'content', |
||
259 | 'themeStyle' => true, |
||
260 | 'type' => 'color', |
||
261 | ], |
||
262 | 'style_button_border' => [ |
||
263 | 'css' => [ |
||
264 | [ |
||
265 | 'selector' => '.bricks-button', |
||
266 | 'property' => 'border', |
||
267 | ], |
||
268 | ], |
||
269 | 'group' => 'design', |
||
270 | 'label' => esc_html_x('Border', 'admin-text', 'site-reviews'), |
||
271 | 'tab' => 'content', |
||
272 | 'themeStyle' => true, |
||
273 | 'type' => 'border', |
||
274 | ], |
||
275 | 'style_button_typography' => [ |
||
276 | 'css' => [ |
||
277 | [ |
||
278 | 'selector' => '.bricks-button', |
||
279 | 'property' => 'font', |
||
280 | ], |
||
281 | ], |
||
282 | 'group' => 'design', |
||
283 | 'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'), |
||
284 | 'tab' => 'content', |
||
285 | 'themeStyle' => true, |
||
286 | 'type' => 'typography', |
||
287 | ], |
||
288 | ]; |
||
289 | return $config; |
||
290 | } |
||
308 |