1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor; |
4
|
|
|
|
5
|
|
|
use Elementor\Controls_Manager; |
6
|
|
|
use GeminiLabs\SiteReviews\Review; |
7
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewShortcode; |
8
|
|
|
|
9
|
|
|
class ElementorReviewWidget extends ElementorWidget |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @return string |
13
|
|
|
*/ |
14
|
|
|
public function get_icon() |
15
|
|
|
{ |
16
|
|
|
return 'eicon-glsr-review'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public static function shortcodeClass(): string |
20
|
|
|
{ |
21
|
|
|
return SiteReviewShortcode::class; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
protected function hide_if_all_fields_hidden(): bool |
25
|
|
|
{ |
26
|
|
|
return true; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function print_content() |
30
|
|
|
{ |
31
|
|
|
if (Review::isReview($this->get_settings_for_display('post_id'))) { |
32
|
|
|
parent::print_content(); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function settings_basic(): array |
37
|
|
|
{ |
38
|
|
|
$options = [ |
39
|
|
|
'post_id' => [ |
40
|
|
|
'default' => '', |
41
|
|
|
'label' => _x('Review Post ID', 'admin-text', 'site-reviews'), |
42
|
|
|
'type' => Controls_Manager::TEXT, |
43
|
|
|
], |
44
|
|
|
]; |
45
|
|
|
$options = $this->insert_hide_controls($options); |
46
|
|
|
return $options; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
protected function settings_layout(): array |
50
|
|
|
{ |
51
|
|
|
return [ |
52
|
|
|
'alignment' => [ |
53
|
|
|
'default' => 'start', |
54
|
|
|
'is_responsive' => true, |
55
|
|
|
'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'), |
56
|
|
|
'options' => [ |
57
|
|
|
'start' => [ |
58
|
|
|
'title' => esc_html_x('Start', 'admin-text', 'site-reviews'), |
59
|
|
|
'icon' => 'eicon-flex eicon-align-start-h', |
60
|
|
|
], |
61
|
|
|
'center' => [ |
62
|
|
|
'title' => esc_html_x('Center', 'admin-text', 'site-reviews'), |
63
|
|
|
'icon' => 'eicon-flex eicon-align-center-h', |
64
|
|
|
], |
65
|
|
|
'end' => [ |
66
|
|
|
'title' => esc_html_x('End', 'admin-text', 'site-reviews'), |
67
|
|
|
'icon' => 'eicon-flex eicon-align-end-h', |
68
|
|
|
], |
69
|
|
|
], |
70
|
|
|
'selectors' => [ |
71
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review' => 'text-align: {{VALUE}}; justify-content: {{VALUE}};', |
72
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-actions' => 'justify-content: {{VALUE}};', |
73
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-date' => 'flex: inherit;', |
74
|
|
|
], |
75
|
|
|
'type' => Controls_Manager::CHOOSE, |
76
|
|
|
], |
77
|
|
|
]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
protected function settings_rating(): array |
81
|
|
|
{ |
82
|
|
|
return [ |
83
|
|
|
'rating_color' => [ |
84
|
|
|
'global' => [ |
85
|
|
|
'default' => '', |
86
|
|
|
], |
87
|
|
|
'label' => esc_html_x('Color', 'admin-text', 'site-reviews'), |
88
|
|
|
'selectors' => [ |
89
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-empty' => 'background: {{VALUE}} !important;', |
90
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-full' => 'background: {{VALUE}} !important;', |
91
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-half' => 'background: {{VALUE}} !important;', |
92
|
|
|
], |
93
|
|
|
'type' => Controls_Manager::COLOR, |
94
|
|
|
], |
95
|
|
|
'rating_size' => [ |
96
|
|
|
'default' => [ |
97
|
|
|
'unit' => 'em', |
98
|
|
|
'size' => 1.25, |
99
|
|
|
], |
100
|
|
|
'is_responsive' => true, |
101
|
|
|
'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
102
|
|
|
'range' => [ |
103
|
|
|
'em' => [ |
104
|
|
|
'min' => 0.25, |
105
|
|
|
'max' => 2.25, |
106
|
|
|
'step' => 0.125, |
107
|
|
|
], |
108
|
|
|
], |
109
|
|
|
'selectors' => [ |
110
|
|
|
'{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star' => '--glsr-review-star: {{SIZE}}{{UNIT}};', |
111
|
|
|
], |
112
|
|
|
'size_units' => $this->set_custom_size_unit(['em']), |
113
|
|
|
'type' => Controls_Manager::SLIDER, |
114
|
|
|
], |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|