1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor; |
4
|
|
|
|
5
|
|
|
use Elementor\Controls_Manager; |
6
|
|
|
use GeminiLabs\SiteReviews\Modules\Rating; |
7
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode; |
8
|
|
|
|
9
|
|
|
class ElementorReviewsWidget extends ElementorWidget |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @return string |
13
|
|
|
*/ |
14
|
|
|
public function get_icon() |
15
|
|
|
{ |
16
|
|
|
return 'eicon-glsr-reviews'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public static function shortcodeClass(): string |
20
|
|
|
{ |
21
|
|
|
return SiteReviewsShortcode::class; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
protected function hide_if_all_fields_hidden(): bool |
25
|
|
|
{ |
26
|
|
|
return true; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function settings_basic(): array |
30
|
|
|
{ |
31
|
|
|
$options = [ |
32
|
|
|
'assigned_posts' => [ |
33
|
|
|
'default' => '', |
34
|
|
|
'label' => _x('Limit Reviews to an Assigned Page', 'admin-text', 'site-reviews'), |
35
|
|
|
'label_block' => true, |
36
|
|
|
'options' => $this->assigned_posts_options(), |
37
|
|
|
'type' => Controls_Manager::SELECT2, |
38
|
|
|
], |
39
|
|
|
'assigned_posts_custom' => [ |
40
|
|
|
'condition' => ['assigned_posts' => 'custom'], |
41
|
|
|
'description' => _x('Separate values with a comma.', 'admin-text', 'site-reviews'), |
42
|
|
|
'label_block' => true, |
43
|
|
|
'placeholder' => _x('Enter the Post IDs', 'admin-text', 'site-reviews'), |
44
|
|
|
'show_label' => false, |
45
|
|
|
'type' => Controls_Manager::TEXT, |
46
|
|
|
], |
47
|
|
|
'assigned_terms' => [ |
48
|
|
|
'default' => '', |
49
|
|
|
'label' => _x('Limit Reviews to an Assigned Category', 'admin-text', 'site-reviews'), |
50
|
|
|
'label_block' => true, |
51
|
|
|
'multiple' => true, |
52
|
|
|
'options' => $this->assigned_terms_options(), |
53
|
|
|
'type' => Controls_Manager::SELECT2, |
54
|
|
|
], |
55
|
|
|
'assigned_users' => [ |
56
|
|
|
'default' => '', |
57
|
|
|
'label' => _x('Limit Reviews to an Assigned User', 'admin-text', 'site-reviews'), |
58
|
|
|
'label_block' => true, |
59
|
|
|
'options' => $this->assigned_users_options(), |
60
|
|
|
'type' => Controls_Manager::SELECT2, |
61
|
|
|
], |
62
|
|
|
'assigned_users_custom' => [ |
63
|
|
|
'condition' => ['assigned_users' => 'custom'], |
64
|
|
|
'description' => _x('Separate values with a comma.', 'admin-text', 'site-reviews'), |
65
|
|
|
'label_block' => true, |
66
|
|
|
'placeholder' => _x('Enter the User IDs', 'admin-text', 'site-reviews'), |
67
|
|
|
'show_label' => false, |
68
|
|
|
'type' => Controls_Manager::TEXT, |
69
|
|
|
], |
70
|
|
|
'terms' => [ |
71
|
|
|
'default' => '', |
72
|
|
|
'label' => _x('Limit Reviews to terms', 'admin-text', 'site-reviews'), |
73
|
|
|
'label_block' => true, |
74
|
|
|
'options' => $this->shortcodeInstance()->options('terms'), |
75
|
|
|
'type' => Controls_Manager::SELECT2, |
76
|
|
|
], |
77
|
|
|
'type' => $this->get_type_control(), |
78
|
|
|
'pagination' => [ |
79
|
|
|
'default' => '', |
80
|
|
|
'label' => _x('Pagination Type', 'admin-text', 'site-reviews'), |
81
|
|
|
'options' => [ |
82
|
|
|
'' => [ |
83
|
|
|
'icon' => 'eicon eicon-close', |
84
|
|
|
'title' => esc_attr_x('No Pagination', 'admin-text', 'site-reviews'), |
85
|
|
|
], |
86
|
|
|
'loadmore' => [ |
87
|
|
|
'icon' => 'eicon eicon-spinner', |
88
|
|
|
'title' => esc_attr_x('Load More Button', 'admin-text', 'site-reviews'), |
89
|
|
|
], |
90
|
|
|
'ajax' => [ |
91
|
|
|
'icon' => 'eicon eicon-spinner', |
92
|
|
|
'title' => esc_attr_x('Pagination (AJAX)', 'admin-text', 'site-reviews'), |
93
|
|
|
], |
94
|
|
|
'true' => [ |
95
|
|
|
'icon' => 'eicon eicon-redo', |
96
|
|
|
'title' => esc_attr_x('Pagination (with page reload)', 'admin-text', 'site-reviews'), |
97
|
|
|
], |
98
|
|
|
], |
99
|
|
|
'separator' => 'before', |
100
|
|
|
'type' => Controls_Manager::CHOOSE, |
101
|
|
|
], |
102
|
|
|
'display' => [ |
103
|
|
|
'default' => 10, |
104
|
|
|
'label' => _x('Reviews Per Page', 'admin-text', 'site-reviews'), |
105
|
|
|
'max' => 50, |
106
|
|
|
'min' => 1, |
107
|
|
|
'type' => Controls_Manager::NUMBER, |
108
|
|
|
], |
109
|
|
|
'rating' => [ |
110
|
|
|
'default' => Rating::min(), |
111
|
|
|
'label' => _x('Minimum Rating', 'admin-text', 'site-reviews'), |
112
|
|
|
'max' => Rating::max(), |
113
|
|
|
'min' => Rating::min(), |
114
|
|
|
'separator' => 'before', |
115
|
|
|
'type' => Controls_Manager::NUMBER, |
116
|
|
|
], |
117
|
|
|
'schema' => [ |
118
|
|
|
'description' => _x('The schema should only be enabled once per page.', 'admin-text', 'site-reviews'), |
119
|
|
|
'label' => _x('Enable the schema?', 'admin-text', 'site-reviews'), |
120
|
|
|
'return_value' => 'true', |
121
|
|
|
'separator' => 'before', |
122
|
|
|
'type' => Controls_Manager::SWITCHER, |
123
|
|
|
], |
124
|
|
|
]; |
125
|
|
|
$options = $this->insert_hide_controls($options); |
126
|
|
|
return $options; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
protected function settings_layout(): array |
130
|
|
|
{ |
131
|
|
|
return [ |
132
|
|
|
'alignment' => [ |
133
|
|
|
'default' => 'start', |
134
|
|
|
'is_responsive' => true, |
135
|
|
|
'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'), |
136
|
|
|
'options' => [ |
137
|
|
|
'start' => [ |
138
|
|
|
'title' => esc_html_x('Start', 'admin-text', 'site-reviews'), |
139
|
|
|
'icon' => 'eicon-flex eicon-align-start-h', |
140
|
|
|
], |
141
|
|
|
'center' => [ |
142
|
|
|
'title' => esc_html_x('Center', 'admin-text', 'site-reviews'), |
143
|
|
|
'icon' => 'eicon-flex eicon-align-center-h', |
144
|
|
|
], |
145
|
|
|
'end' => [ |
146
|
|
|
'title' => esc_html_x('End', 'admin-text', 'site-reviews'), |
147
|
|
|
'icon' => 'eicon-flex eicon-align-end-h', |
148
|
|
|
], |
149
|
|
|
], |
150
|
|
|
'selectors' => [ |
151
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review' => 'text-align: {{VALUE}}; justify-content: {{VALUE}};', |
152
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-actions' => 'justify-content: {{VALUE}};', |
153
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-date' => 'flex: inherit;', |
154
|
|
|
], |
155
|
|
|
'type' => Controls_Manager::CHOOSE, |
156
|
|
|
], |
157
|
|
|
'spacing' => [ |
158
|
|
|
'default' => [ |
159
|
|
|
'unit' => 'em', |
160
|
|
|
'size' => 2, |
161
|
|
|
], |
162
|
|
|
'is_responsive' => true, |
163
|
|
|
'label' => esc_html_x('Review Spacing', 'admin-text', 'site-reviews'), |
164
|
|
|
'range' => [ |
165
|
|
|
'em' => [ |
166
|
|
|
'min' => 0, |
167
|
|
|
'max' => 4, |
168
|
|
|
'step' => 0.125, |
169
|
|
|
], |
170
|
|
|
], |
171
|
|
|
'selectors' => [ |
172
|
|
|
'{{WRAPPER}} .glsr-reviews' => '--glsr-gap-xl: {{SIZE}}{{UNIT}};', |
173
|
|
|
], |
174
|
|
|
'size_units' => $this->set_custom_size_unit(['em']), |
175
|
|
|
'type' => Controls_Manager::SLIDER, |
176
|
|
|
], |
177
|
|
|
]; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
protected function settings_rating(): array |
181
|
|
|
{ |
182
|
|
|
return [ |
183
|
|
|
'rating_color' => [ |
184
|
|
|
'global' => [ |
185
|
|
|
'default' => '', |
186
|
|
|
], |
187
|
|
|
'label' => esc_html_x('Color', 'admin-text', 'site-reviews'), |
188
|
|
|
'selectors' => [ |
189
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-empty' => 'background: {{VALUE}} !important;', |
190
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-full' => 'background: {{VALUE}} !important;', |
191
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-half' => 'background: {{VALUE}} !important;', |
192
|
|
|
], |
193
|
|
|
'type' => Controls_Manager::COLOR, |
194
|
|
|
], |
195
|
|
|
'rating_size' => [ |
196
|
|
|
'default' => [ |
197
|
|
|
'unit' => 'em', |
198
|
|
|
'size' => 1.25, |
199
|
|
|
], |
200
|
|
|
'is_responsive' => true, |
201
|
|
|
'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
202
|
|
|
'range' => [ |
203
|
|
|
'em' => [ |
204
|
|
|
'min' => 0.25, |
205
|
|
|
'max' => 2.25, |
206
|
|
|
'step' => 0.125, |
207
|
|
|
], |
208
|
|
|
], |
209
|
|
|
'selectors' => [ |
210
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star' => '--glsr-review-star: {{SIZE}}{{UNIT}};', |
211
|
|
|
], |
212
|
|
|
'size_units' => $this->set_custom_size_unit(['em']), |
213
|
|
|
'type' => Controls_Manager::SLIDER, |
214
|
|
|
], |
215
|
|
|
]; |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|