|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Bricks; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Helpers\Arr; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsSummaryShortcode; |
|
7
|
|
|
|
|
8
|
|
|
class BricksSiteReviewsSummary extends BricksElement |
|
9
|
|
|
{ |
|
10
|
|
|
public function designConfig(): array |
|
11
|
|
|
{ |
|
12
|
|
|
$config = [ |
|
13
|
|
|
'stylePreset' => [ |
|
14
|
|
|
'group' => 'design', |
|
15
|
|
|
'inline' => true, |
|
16
|
|
|
'label' => esc_html_x('Style', 'admin-text', 'site-reviews'), |
|
17
|
|
|
'options' => [ |
|
18
|
|
|
'default' => esc_html_x('Default', 'admin-text', 'site-reviews'), |
|
19
|
|
|
'1' => esc_html_x('Style 1', 'admin-text', 'site-reviews'), |
|
20
|
|
|
'2' => esc_html_x('Style 2', 'admin-text', 'site-reviews'), |
|
21
|
|
|
'3' => esc_html_x('Style 3', 'admin-text', 'site-reviews'), |
|
22
|
|
|
], |
|
23
|
|
|
'placeholder' => esc_html_x('Default', 'admin-text', 'site-reviews'), |
|
24
|
|
|
'tab' => 'content', |
|
25
|
|
|
'themeStyle' => true, |
|
26
|
|
|
'type' => 'select', |
|
27
|
|
|
], |
|
28
|
|
|
'styleAlign' => [ |
|
29
|
|
|
'css' => [ |
|
30
|
|
|
[ |
|
31
|
|
|
'required' => 'left', |
|
32
|
|
|
'selector' => '.glsr-summary', |
|
33
|
|
|
'property' => '--glsr-summary-align', |
|
34
|
|
|
'value' => 'start', |
|
35
|
|
|
], |
|
36
|
|
|
[ |
|
37
|
|
|
'required' => 'left', |
|
38
|
|
|
'selector' => 'div.is-style-1 .glsr-summary-rating, div.is-style-3 .glsr-summary-rating', |
|
39
|
|
|
'property' => 'justify-content', |
|
40
|
|
|
'value' => 'start', |
|
41
|
|
|
], |
|
42
|
|
|
[ |
|
43
|
|
|
'required' => 'center', |
|
44
|
|
|
'selector' => '.glsr-summary', |
|
45
|
|
|
'property' => '--glsr-summary-align', |
|
46
|
|
|
], |
|
47
|
|
|
[ |
|
48
|
|
|
'required' => 'center', |
|
49
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary', |
|
50
|
|
|
'property' => 'grid-template-columns', |
|
51
|
|
|
'value' => '1fr auto auto 1fr', |
|
52
|
|
|
], |
|
53
|
|
|
[ |
|
54
|
|
|
'required' => 'center', |
|
55
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-rating', |
|
56
|
|
|
'property' => 'grid-column-start', |
|
57
|
|
|
'value' => '2', |
|
58
|
|
|
], |
|
59
|
|
|
[ |
|
60
|
|
|
'required' => 'center', |
|
61
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-stars, div:is(.is-style-1, .is-style-3) .glsr-summary-text', |
|
62
|
|
|
'property' => 'grid-column-start', |
|
63
|
|
|
'value' => '3', |
|
64
|
|
|
], |
|
65
|
|
|
[ |
|
66
|
|
|
'required' => 'center', |
|
67
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-stars, div:is(.is-style-1, .is-style-3) .glsr-summary-text', |
|
68
|
|
|
'property' => 'text-align', |
|
69
|
|
|
'value' => 'start', |
|
70
|
|
|
], |
|
71
|
|
|
[ |
|
72
|
|
|
'required' => 'center', |
|
73
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-percentages', |
|
74
|
|
|
'property' => 'grid-column-end', |
|
75
|
|
|
'value' => 'span 4', |
|
76
|
|
|
], |
|
77
|
|
|
[ |
|
78
|
|
|
'required' => 'right', |
|
79
|
|
|
'selector' => '.glsr-summary', |
|
80
|
|
|
'property' => '--glsr-summary-align', |
|
81
|
|
|
'value' => 'end', |
|
82
|
|
|
], |
|
83
|
|
|
[ |
|
84
|
|
|
'required' => 'right', |
|
85
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary', |
|
86
|
|
|
'property' => 'grid-template-columns', |
|
87
|
|
|
'value' => '1fr auto', |
|
88
|
|
|
], |
|
89
|
|
|
[ |
|
90
|
|
|
'required' => 'right', |
|
91
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-rating', |
|
92
|
|
|
'property' => 'justify-content', |
|
93
|
|
|
'value' => 'end', |
|
94
|
|
|
], |
|
95
|
|
|
[ |
|
96
|
|
|
'required' => 'right', |
|
97
|
|
|
'selector' => 'div:is(.is-style-1, .is-style-3) .glsr-summary-text', |
|
98
|
|
|
'property' => 'text-align', |
|
99
|
|
|
'value' => 'start', |
|
100
|
|
|
], |
|
101
|
|
|
], |
|
102
|
|
|
'exclude' => ['auto', 'justify'], |
|
103
|
|
|
'group' => 'design', |
|
104
|
|
|
'inline' => true, |
|
105
|
|
|
'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'), |
|
106
|
|
|
'rerender' => true, |
|
107
|
|
|
'tab' => 'content', |
|
108
|
|
|
'themeStyle' => true, |
|
109
|
|
|
'type' => 'text-align', |
|
110
|
|
|
], |
|
111
|
|
|
'styleMaxWidth' => [ |
|
112
|
|
|
'css' => [ |
|
113
|
|
|
[ |
|
114
|
|
|
'selector' => '.glsr', |
|
115
|
|
|
'property' => '--glsr-max-w', |
|
116
|
|
|
], |
|
117
|
|
|
], |
|
118
|
|
|
'group' => 'design', |
|
119
|
|
|
'hasDynamicData' => false, |
|
120
|
|
|
'hasVariables' => true, |
|
121
|
|
|
'inline' => true, |
|
122
|
|
|
'label' => esc_html_x('Max Width', 'admin-text', 'site-reviews'), |
|
123
|
|
|
'placeholder' => '', |
|
124
|
|
|
'tab' => 'content', |
|
125
|
|
|
'themeStyle' => true, |
|
126
|
|
|
'type' => 'number', |
|
127
|
|
|
'units' => true, |
|
128
|
|
|
], |
|
129
|
|
|
'separatorRating' => [ |
|
130
|
|
|
'group' => 'design', |
|
131
|
|
|
'label' => esc_html_x('Rating', 'admin-text', 'site-reviews'), |
|
132
|
|
|
'tab' => 'content', |
|
133
|
|
|
'themeStyle' => true, |
|
134
|
|
|
'type' => 'separator', |
|
135
|
|
|
], |
|
136
|
|
|
'styleRatingColor' => [ |
|
137
|
|
|
'css' => [ |
|
138
|
|
|
[ |
|
139
|
|
|
'selector' => '.glsr:not([data-theme])', |
|
140
|
|
|
'property' => '--glsr-summary-star-bg', |
|
141
|
|
|
], |
|
142
|
|
|
[ |
|
143
|
|
|
'selector' => '.glsr:not([data-theme]) .glsr-star', |
|
144
|
|
|
'property' => 'background', |
|
145
|
|
|
'value' => 'var(--glsr-summary-star-bg)', |
|
146
|
|
|
], |
|
147
|
|
|
[ |
|
148
|
|
|
'selector' => '.glsr:not([data-theme]) .glsr-star', |
|
149
|
|
|
'property' => 'mask-size', |
|
150
|
|
|
'value' => '100%', |
|
151
|
|
|
], |
|
152
|
|
|
[ |
|
153
|
|
|
'selector' => '.glsr:not([data-theme]) .glsr-star-empty', |
|
154
|
|
|
'property' => 'mask-image', |
|
155
|
|
|
'value' => 'var(--glsr-star-empty)', |
|
156
|
|
|
], |
|
157
|
|
|
[ |
|
158
|
|
|
'selector' => '.glsr:not([data-theme]) .glsr-star-full', |
|
159
|
|
|
'property' => 'mask-image', |
|
160
|
|
|
'value' => 'var(--glsr-star-full)', |
|
161
|
|
|
], |
|
162
|
|
|
[ |
|
163
|
|
|
'selector' => '.glsr:not([data-theme]) .glsr-star-half', |
|
164
|
|
|
'property' => 'mask-image', |
|
165
|
|
|
'value' => 'var(--glsr-star-half)', |
|
166
|
|
|
], |
|
167
|
|
|
], |
|
168
|
|
|
'group' => 'design', |
|
169
|
|
|
'label' => esc_html_x('Star Color', 'admin-text', 'site-reviews'), |
|
170
|
|
|
'tab' => 'content', |
|
171
|
|
|
'themeStyle' => true, |
|
172
|
|
|
'type' => 'color', |
|
173
|
|
|
], |
|
174
|
|
|
'styleRatingSize' => [ |
|
175
|
|
|
'css' => [ |
|
176
|
|
|
[ |
|
177
|
|
|
'selector' => '.glsr', |
|
178
|
|
|
'property' => '--glsr-summary-star', |
|
179
|
|
|
], |
|
180
|
|
|
], |
|
181
|
|
|
'group' => 'design', |
|
182
|
|
|
'hasDynamicData' => false, |
|
183
|
|
|
'hasVariables' => true, |
|
184
|
|
|
'inline' => true, |
|
185
|
|
|
'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
|
186
|
|
|
'placeholder' => '', |
|
187
|
|
|
'tab' => 'content', |
|
188
|
|
|
'themeStyle' => true, |
|
189
|
|
|
'type' => 'number', |
|
190
|
|
|
'units' => true, |
|
191
|
|
|
], |
|
192
|
|
|
'styleRatingTypography' => [ |
|
193
|
|
|
'css' => [ |
|
194
|
|
|
[ |
|
195
|
|
|
'selector' => '.glsr-summary-rating', |
|
196
|
|
|
'property' => 'font', |
|
197
|
|
|
], |
|
198
|
|
|
], |
|
199
|
|
|
'group' => 'design', |
|
200
|
|
|
'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'), |
|
201
|
|
|
'tab' => 'content', |
|
202
|
|
|
'themeStyle' => true, |
|
203
|
|
|
'type' => 'typography', |
|
204
|
|
|
], |
|
205
|
|
|
'separatorText' => [ |
|
206
|
|
|
'group' => 'design', |
|
207
|
|
|
'label' => esc_html_x('Text', 'admin-text', 'site-reviews'), |
|
208
|
|
|
'tab' => 'content', |
|
209
|
|
|
'themeStyle' => true, |
|
210
|
|
|
'type' => 'separator', |
|
211
|
|
|
], |
|
212
|
|
|
'styleTextTypography' => [ |
|
213
|
|
|
'css' => [ |
|
214
|
|
|
[ |
|
215
|
|
|
'selector' => '.glsr-summary-text', |
|
216
|
|
|
'property' => 'font', |
|
217
|
|
|
], |
|
218
|
|
|
], |
|
219
|
|
|
'group' => 'design', |
|
220
|
|
|
'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'), |
|
221
|
|
|
'tab' => 'content', |
|
222
|
|
|
'themeStyle' => true, |
|
223
|
|
|
'type' => 'typography', |
|
224
|
|
|
], |
|
225
|
|
|
'separatorBar' => [ |
|
226
|
|
|
'group' => 'design', |
|
227
|
|
|
'label' => esc_html_x('Bars', 'admin-text', 'site-reviews'), |
|
228
|
|
|
'tab' => 'content', |
|
229
|
|
|
'themeStyle' => true, |
|
230
|
|
|
'type' => 'separator', |
|
231
|
|
|
], |
|
232
|
|
|
'styleBarColor' => [ |
|
233
|
|
|
'css' => [ |
|
234
|
|
|
[ |
|
235
|
|
|
'selector' => '.glsr:not([data-theme])', |
|
236
|
|
|
'property' => '--glsr-bar-bg', |
|
237
|
|
|
], |
|
238
|
|
|
], |
|
239
|
|
|
'group' => 'design', |
|
240
|
|
|
'label' => esc_html_x('Color', 'admin-text', 'site-reviews'), |
|
241
|
|
|
'tab' => 'content', |
|
242
|
|
|
'themeStyle' => true, |
|
243
|
|
|
'type' => 'color', |
|
244
|
|
|
], |
|
245
|
|
|
'styleBarSpacing' => [ |
|
246
|
|
|
'css' => [ |
|
247
|
|
|
[ |
|
248
|
|
|
'selector' => '.glsr', |
|
249
|
|
|
'property' => '--glsr-bar-spacing', |
|
250
|
|
|
], |
|
251
|
|
|
], |
|
252
|
|
|
'group' => 'design', |
|
253
|
|
|
'hasDynamicData' => false, |
|
254
|
|
|
'hasVariables' => true, |
|
255
|
|
|
'inline' => true, |
|
256
|
|
|
'label' => esc_html_x('Gap', 'admin-text', 'site-reviews'), |
|
257
|
|
|
'placeholder' => '', |
|
258
|
|
|
'tab' => 'content', |
|
259
|
|
|
'themeStyle' => true, |
|
260
|
|
|
'type' => 'number', |
|
261
|
|
|
'units' => true, |
|
262
|
|
|
], |
|
263
|
|
|
'styleBarSize' => [ |
|
264
|
|
|
'css' => [ |
|
265
|
|
|
[ |
|
266
|
|
|
'selector' => '.glsr', |
|
267
|
|
|
'property' => '--glsr-bar-size', |
|
268
|
|
|
], |
|
269
|
|
|
], |
|
270
|
|
|
'group' => 'design', |
|
271
|
|
|
'hasDynamicData' => false, |
|
272
|
|
|
'hasVariables' => true, |
|
273
|
|
|
'inline' => true, |
|
274
|
|
|
'label' => esc_html_x('Size', 'admin-text', 'site-reviews'), |
|
275
|
|
|
'placeholder' => '', |
|
276
|
|
|
'tab' => 'content', |
|
277
|
|
|
'themeStyle' => true, |
|
278
|
|
|
'type' => 'number', |
|
279
|
|
|
'units' => true, |
|
280
|
|
|
], |
|
281
|
|
|
'styleBarTypography' => [ |
|
282
|
|
|
'css' => [ |
|
283
|
|
|
[ |
|
284
|
|
|
'selector' => '.glsr-summary-percentages', |
|
285
|
|
|
'property' => 'font', |
|
286
|
|
|
], |
|
287
|
|
|
], |
|
288
|
|
|
'group' => 'design', |
|
289
|
|
|
'label' => esc_html_x('Typography', 'admin-text', 'site-reviews'), |
|
290
|
|
|
'tab' => 'content', |
|
291
|
|
|
'themeStyle' => true, |
|
292
|
|
|
'type' => 'typography', |
|
293
|
|
|
], |
|
294
|
|
|
]; |
|
295
|
|
|
if ($placeholder = $config['stylePreset']['options'][$this->theme_styles['stylePreset'] ?? ''] ?? '') { |
|
296
|
|
|
$config['stylePreset']['placeholder'] = $placeholder; |
|
297
|
|
|
} |
|
298
|
|
|
return $config; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
public function elementConfig(): array |
|
302
|
|
|
{ |
|
303
|
|
|
$controls = parent::elementConfig(); |
|
304
|
|
|
$controls = Arr::insertBefore('text', $controls, [ |
|
305
|
|
|
'text_notice' => [ |
|
306
|
|
|
'content' => esc_html_x('The recommended way to change these values is to use the Site Reviews → Settings → Strings page.', 'admin-text', 'site-reviews'), |
|
307
|
|
|
'group' => 'text', |
|
308
|
|
|
'tab' => 'content', |
|
309
|
|
|
'type' => 'info', |
|
310
|
|
|
], |
|
311
|
|
|
]); |
|
312
|
|
|
return $controls; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
public function render() |
|
316
|
|
|
{ |
|
317
|
|
|
if (!$this->shortcodeInstance()->hasVisibleFields($this->settings)) { |
|
318
|
|
|
$this->render_element_placeholder([ |
|
319
|
|
|
'title' => esc_html_x('You have hidden all of the fields.', 'admin-text', 'site-reviews'), |
|
320
|
|
|
]); |
|
321
|
|
|
return; |
|
322
|
|
|
} |
|
323
|
|
|
parent::render(); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
public function styledClasses(array $classes = []): array |
|
327
|
|
|
{ |
|
328
|
|
|
if ($align = $this->styledSetting('styleAlign')) { |
|
329
|
|
|
$classes[] = "items-justified-{$align}"; |
|
330
|
|
|
} |
|
331
|
|
|
return $classes; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
public static function shortcodeClass(): string |
|
335
|
|
|
{ |
|
336
|
|
|
return SiteReviewsSummaryShortcode::class; |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
|