Test Failed
Push — develop ( 006c9f...4b441a )
by Paul
13:29
created

BricksSiteReviewsForm::designConfig()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 263
Code Lines 192

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 192
c 0
b 0
f 0
dl 0
loc 263
rs 8
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Bricks;
4
5
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode;
6
7
class BricksSiteReviewsForm extends BricksElement
8
{
9
    public function designConfig(): array
10
    {
11
        $config = [
12
            'styleFormColGap' => [
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
            'styleFormRowGap' => [
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
            'separatorField' => [
49
                'group' => 'design',
50
                'label' => esc_html_x('Fields', 'admin-text', 'site-reviews'),
51
                'tab' => 'content',
52
                'themeStyle' => true,
53
                'type' => 'separator',
54
            ],
55
            'styleFieldLabelTypography' => [
56
                'css' => [
57
                    [
58
                        'selector' => 'label.glsr-label',
59
                        'property' => 'font',
60
                    ],
61
                ],
62
                'group' => 'design',
63
                'label' => esc_html_x('Label', 'admin-text', 'site-reviews'),
64
                'tab' => 'content',
65
                'themeStyle' => true,
66
                'type' => 'typography',
67
            ],
68
            'styleFieldBackgroundColor' => [
69
                'css' => [
70
                    [
71
                        'selector' => '.glsr-textarea, .glsr-input',
72
                        'property' => 'background-color',
73
                    ],
74
                ],
75
                'group' => 'design',
76
                'label' => esc_html_x('Background color', 'admin-text', 'site-reviews'),
77
                'tab' => 'content',
78
                'themeStyle' => true,
79
                'type' => 'color',
80
            ],
81
            'styleFieldBorder' => [
82
                'css' => [
83
                    [
84
                        'selector' => '.glsr-textarea, .glsr-input',
85
                        'property' => 'border',
86
                    ],
87
                ],
88
                'group' => 'design',
89
                'label' => esc_html_x('Border', 'admin-text', 'site-reviews'),
90
                'tab' => 'content',
91
                'themeStyle' => true,
92
                'type' => 'border',
93
            ],
94
            'styleFieldTypography' => [
95
                'css' => [
96
                    [
97
                        'selector' => '.glsr-textarea, .glsr-input, .glsr-toggle label, .glsr-toggle-switch',
98
                        'property' => 'font',
99
                    ],
100
                ],
101
                'group' => 'design',
102
                'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'),
103
                'tab' => 'content',
104
                'themeStyle' => true,
105
                'type' => 'typography',
106
            ],
107
            'styleFieldPlaceholder' => [
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
            'separatorRating' => [
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
            'styleRatingSize' => [
128
                'css' => [
129
                    [
130
                        'selector' => '.glsr',
131
                        'property' => '--glsr-form-star',
132
                    ],
133
                ],
134
                'group' => 'design',
135
                'hasDynamicData' => false,
136
                'hasVariables' => true,
137
                'inline' => true,
138
                'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'),
139
                'placeholder' => '',
140
                'tab' => 'content',
141
                'themeStyle' => true,
142
                'type' => 'number',
143
                'units' => true,
144
            ],
145
            'styleRatingColor' => [
146
                'css' => [
147
                    [
148
                        'selector' => '.glsr:not([data-theme])',
149
                        'property' => '--glsr-form-star-bg',
150
                    ],
151
                    [
152
                        'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span',
153
                        'property' => 'background',
154
                        'value' => 'var(--glsr-form-star-bg)',
155
                    ],
156
                    [
157
                        'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span',
158
                        'property' => 'mask-image',
159
                        'value' => 'var(--glsr-star-empty)',
160
                    ],
161
                    [
162
                        'selector' => '.glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span',
163
                        'property' => 'mask-size',
164
                        'value' => '100%',
165
                    ],
166
                    [
167
                        'selector' => '.glsr:not([data-theme]) .glsr-field .glsr-star-rating--stars > span:is(.gl-active, .gl-active.gl-selected)',
168
                        'property' => 'background',
169
                        'value' => 'var(--glsr-form-star-bg)',
170
                    ],
171
                    [
172
                        'selector' => '.glsr:not([data-theme]) .glsr-field .glsr-star-rating--stars > span:is(.gl-active, .gl-active.gl-selected)',
173
                        'property' => 'mask-image',
174
                        'value' => 'var(--glsr-star-full)',
175
                    ],
176
                ],
177
                'group' => 'design',
178
                'label' => esc_html_x('Rating Color', 'admin-text', 'site-reviews'),
179
                'tab' => 'content',
180
                'themeStyle' => true,
181
                'type' => 'color',
182
            ],
183
            'separatorToggle' => [
184
                'group' => 'design',
185
                'label' => esc_html_x('Toggle Field', 'admin-text', 'site-reviews'),
186
                'tab' => 'content',
187
                'themeStyle' => true,
188
                'type' => 'separator',
189
            ],
190
            'styleToggleColor' => [
191
                'css' => [
192
                    [
193
                        'selector' => '.glsr-field-toggle',
194
                        'property' => '--glsr-toggle-bg-1',
195
                    ],
196
                ],
197
                'group' => 'design',
198
                'label' => esc_html_x('Toggle Color', 'admin-text', 'site-reviews'),
199
                'tab' => 'content',
200
                'themeStyle' => true,
201
                'type' => 'color',
202
            ],
203
            'separatorButton' => [
204
                'group' => 'design',
205
                'label' => esc_html_x('Submit Button', 'admin-text', 'site-reviews'),
206
                'tab' => 'content',
207
                'themeStyle' => true,
208
                'type' => 'separator',
209
            ],
210
            'styleButtonSize' => [
211
                'group' => 'design',
212
                'inline' => true,
213
                'label' => esc_html_x('Size', 'admin-text', 'site-reviews'),
214
                'options' => $this->control_options['buttonSizes'] ?? [],
215
                'placeholder' => esc_html_x('Default', 'admin-text', 'site-reviews'),
216
                'tab' => 'content',
217
                'themeStyle' => true,
218
                'type' => 'select',
219
            ],
220
            'styleButtonStyle' => [
221
                'default' => 'primary',
222
                'group' => 'design',
223
                'inline' => true,
224
                'label' => esc_html_x('Style', 'admin-text', 'site-reviews'),
225
                'options' => $this->control_options['styles'] ?? [],
226
                'placeholder' => esc_html_x('None', 'admin-text', 'site-reviews'),
227
                'tab' => 'content',
228
                'themeStyle' => true,
229
                'type' => 'select',
230
            ],
231
            'styleButtonBackgroundColor' => [
232
                'css' => [
233
                    [
234
                        'selector' => '.bricks-button',
235
                        'property' => 'background-color',
236
                    ],
237
                ],
238
                'group' => 'design',
239
                'label' => esc_html_x('Background', 'admin-text', 'site-reviews'),
240
                'tab' => 'content',
241
                'themeStyle' => true,
242
                'type' => 'color',
243
            ],
244
            'styleButtonBorder' => [
245
                'css' => [
246
                    [
247
                        'selector' => '.bricks-button',
248
                        'property' => 'border',
249
                    ],
250
                ],
251
                'group' => 'design',
252
                'label' => esc_html_x('Border', 'admin-text', 'site-reviews'),
253
                'tab' => 'content',
254
                'themeStyle' => true,
255
                'type' => 'border',
256
            ],
257
            'styleButtonTypography' => [
258
                'css' => [
259
                    [
260
                        'selector' => '.bricks-button',
261
                        'property' => 'font',
262
                    ],
263
                ],
264
                'group' => 'design',
265
                'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'),
266
                'tab' => 'content',
267
                'themeStyle' => true,
268
                'type' => 'typography',
269
            ],
270
        ];
271
        return $config;
272
    }
273
274
    public function render()
275
    {
276
        if (!$this->shortcodeInstance()->hasVisibleFields($this->settings)) {
277
            $this->render_element_placeholder([
278
                'title' => esc_html_x('You have hidden all of the fields.', 'admin-text', 'site-reviews'),
279
            ]);
280
            return;
281
        }
282
        parent::render();
283
    }
284
285
    public static function shortcodeClass(): string
286
    {
287
        return SiteReviewsFormShortcode::class;
288
    }
289
}
290