1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Elementor\Widgets; |
4
|
|
|
|
5
|
|
|
use Elementor\Controls_Manager; |
6
|
|
|
use Elementor\Group_Control_Typography; |
7
|
|
|
use GeminiLabs\SiteReviews\License; |
8
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode; |
9
|
|
|
|
10
|
|
|
class ElementorSiteReviews extends ElementorWidget |
11
|
|
|
{ |
12
|
|
|
public function get_icon(): string |
13
|
|
|
{ |
14
|
|
|
return 'eicon-glsr-reviews'; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public static function shortcodeClass(): string |
18
|
|
|
{ |
19
|
|
|
return SiteReviewsShortcode::class; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
protected function get_upsale_data(): array |
23
|
|
|
{ |
24
|
|
|
return [ |
25
|
|
|
'condition' => !glsr(License::class)->isPremium(), |
26
|
|
|
'description' => esc_html_x('Upgrade to Site Reviews Premium and get a bunch of additional features and professional support.', 'admin-text', 'site-reviews'), |
27
|
|
|
'image' => glsr()->url('assets/images/premium.svg'), |
28
|
|
|
'image_alt' => esc_attr_x('Upgrade', 'admin-text', 'site-reviews'), |
29
|
|
|
'upgrade_text' => esc_html_x('Upgrade Now', 'admin-text', 'site-reviews'), |
30
|
|
|
'upgrade_url' => glsr_premium_url('site-reviews-premium'), |
31
|
|
|
]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function styleConfig(): array |
35
|
|
|
{ |
36
|
|
|
return [ |
37
|
|
|
'style_align' => [ |
38
|
|
|
'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'), |
39
|
|
|
'label_block' => false, |
40
|
|
|
'default' => 'left', |
41
|
|
|
'options' => [ |
42
|
|
|
'left' => [ |
43
|
|
|
'icon' => 'eicon-flex eicon-align-start-h', |
44
|
|
|
'title' => esc_html_x('Start', 'admin-text', 'site-reviews'), |
45
|
|
|
], |
46
|
|
|
'center' => [ |
47
|
|
|
'icon' => 'eicon-flex eicon-align-center-h', |
48
|
|
|
'title' => esc_html_x('Center', 'admin-text', 'site-reviews'), |
49
|
|
|
], |
50
|
|
|
'right' => [ |
51
|
|
|
'icon' => 'eicon-flex eicon-align-end-h', |
52
|
|
|
'title' => esc_html_x('End', 'admin-text', 'site-reviews'), |
53
|
|
|
], |
54
|
|
|
], |
55
|
|
|
'prefix_class' => 'items-justified-', |
56
|
|
|
'selectors' => [ |
57
|
|
|
'{{WRAPPER}} .glsr-summary-text' => 'text-align: {{VALUE}};', |
58
|
|
|
], |
59
|
|
|
'type' => Controls_Manager::CHOOSE, |
60
|
|
|
], |
61
|
|
|
'style_row_gap' => [ |
62
|
|
|
'is_responsive' => true, |
63
|
|
|
'label' => esc_html_x('Row Gap', 'admin-text', 'site-reviews'), |
64
|
|
|
'selectors' => [ |
65
|
|
|
'{{WRAPPER}}' => '--glsr-review-row-gap: {{SIZE}}{{UNIT}};', |
66
|
|
|
], |
67
|
|
|
'size_units' => ['px', 'em', 'rem', 'custom'], |
68
|
|
|
'type' => Controls_Manager::SLIDER, |
69
|
|
|
], |
70
|
|
|
'style_heading' => [ |
71
|
|
|
'label' => esc_html_x('Heading', 'admin-text', 'site-reviews'), |
72
|
|
|
'selector' => '{{WRAPPER}} .glsr:not([data-theme]) h2, {{WRAPPER}} .glsr:not([data-theme]) h3, {{WRAPPER}} .glsr:not([data-theme]) h4', |
73
|
|
|
'type' => Group_Control_Typography::get_type(), |
74
|
|
|
], |
75
|
|
|
'style_text' => [ |
76
|
|
|
'label' => esc_html_x('Text', 'admin-text', 'site-reviews'), |
77
|
|
|
'selector' => '{{WRAPPER}} .glsr:not([data-theme])', |
78
|
|
|
'type' => Group_Control_Typography::get_type(), |
79
|
|
|
], |
80
|
|
|
'style_rating_size' => [ |
81
|
|
|
'is_responsive' => true, |
82
|
|
|
'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
83
|
|
|
'selectors' => [ |
84
|
|
|
'{{WRAPPER}}' => '--glsr-review-star: {{SIZE}}{{UNIT}};', |
85
|
|
|
], |
86
|
|
|
'size_units' => ['px', 'em', 'rem', 'custom'], |
87
|
|
|
'type' => Controls_Manager::SLIDER, |
88
|
|
|
], |
89
|
|
|
'style_rating_color' => [ |
90
|
|
|
'label' => esc_html_x('Star Color', 'admin-text', 'site-reviews'), |
91
|
|
|
'selectors' => [ |
92
|
|
|
'{{WRAPPER}} .glsr:not([data-theme])' => '--glsr-review-star-bg: {{VALUE}};', |
93
|
|
|
], |
94
|
|
|
'type' => Controls_Manager::COLOR, |
95
|
|
|
], |
96
|
|
|
]; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
protected function transformControl(string $name, array $args): array |
100
|
|
|
{ |
101
|
|
|
$control = parent::transformControl($name, $args); |
102
|
|
|
if ('pagination' === $name) { |
103
|
|
|
$icons = [ |
104
|
|
|
'ajax' => 'eicon eicon-spinner', |
105
|
|
|
'loadmore' => 'eicon eicon-button', |
106
|
|
|
'true' => 'eicon eicon-redo', |
107
|
|
|
]; |
108
|
|
|
$control['label'] = _x('Pagination', 'admin-text', 'site-reviews'); |
109
|
|
|
$control['label_block'] = false; |
110
|
|
|
$control['type'] = Controls_Manager::CHOOSE; |
111
|
|
|
foreach ($control['options'] as $key => $value) { |
112
|
|
|
$control['options'][$key] = [ |
113
|
|
|
'icon' => $icons[$key] ?? $icons['ajax'], |
114
|
|
|
'title' => $value, |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
return $control; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|