1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\WooCommerce\Elementor\Widgets; |
4
|
|
|
|
5
|
|
|
use Elementor\Controls_Manager; |
6
|
|
|
use Elementor\Group_Control_Typography; |
7
|
|
|
use ElementorPro\Modules\Woocommerce\Widgets\Product_Rating; |
8
|
|
|
use GeminiLabs\SiteReviews\Modules\Html\Template; |
9
|
|
|
use GeminiLabs\SiteReviews\Modules\Style; |
10
|
|
|
|
11
|
|
|
class ProductRating extends Product_Rating |
12
|
|
|
{ |
13
|
|
|
protected function register_controls() |
14
|
|
|
{ |
15
|
|
|
$this->start_controls_section('section_product_rating_style', [ |
16
|
|
|
'label' => esc_html__('Style', 'elementor-pro'), |
17
|
|
|
'tab' => Controls_Manager::TAB_STYLE, |
18
|
|
|
]); |
19
|
|
|
$this->add_control('wc_style_warning', [ |
20
|
|
|
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
21
|
|
|
'raw' => esc_html__('The style of this widget is often affected by your theme and plugins. If you experience any such issue, try to switch to a basic theme and deactivate related plugins.', 'elementor-pro'), |
22
|
|
|
'type' => Controls_Manager::RAW_HTML, |
23
|
|
|
]); |
24
|
|
|
$this->add_control('link_color', [ |
25
|
|
|
'label' => esc_html__('Link Color', 'elementor-pro'), |
26
|
|
|
'selectors' => [ |
27
|
|
|
'.woocommerce {{WRAPPER}} .woocommerce-review-link' => 'color: {{VALUE}}', |
28
|
|
|
], |
29
|
|
|
'type' => Controls_Manager::COLOR, |
30
|
|
|
]); |
31
|
|
|
$this->add_group_control(Group_Control_Typography::get_type(), [ |
32
|
|
|
'name' => 'text_typography', |
33
|
|
|
'selector' => '.woocommerce {{WRAPPER}} .woocommerce-review-link', |
34
|
|
|
]); |
35
|
|
|
$this->add_control('star_size', [ |
36
|
|
|
'default' => [ |
37
|
|
|
'unit' => 'em', |
38
|
|
|
'size' => 1, |
39
|
|
|
], |
40
|
|
|
'label' => esc_html__('Star Size', 'elementor-pro'), |
41
|
|
|
'range' => [ |
42
|
|
|
'em' => [ |
43
|
|
|
'min' => 0, |
44
|
|
|
'max' => 4, |
45
|
|
|
'step' => 0.1, |
46
|
|
|
], |
47
|
|
|
'px' => [ |
48
|
|
|
'min' => 0, |
49
|
|
|
'max' => 50, |
50
|
|
|
'step' => 1, |
51
|
|
|
], |
52
|
|
|
], |
53
|
|
|
'selectors' => [ |
54
|
|
|
'.woocommerce {{WRAPPER}} .glsr-star' => 'background-size:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};width:{{SIZE}}{{UNIT}};', |
55
|
|
|
'.woocommerce {{WRAPPER}} .glsr-rating-level' => 'font-size:{{SIZE}}{{UNIT}};', |
56
|
|
|
], |
57
|
|
|
'size_units' => ['px', 'em', 'custom'], |
58
|
|
|
'type' => Controls_Manager::SLIDER, |
59
|
|
|
]); |
60
|
|
|
$this->add_control('space_between', [ |
61
|
|
|
'default' => [ |
62
|
|
|
'unit' => 'em', |
63
|
|
|
'size' => 0, |
64
|
|
|
], |
65
|
|
|
'label' => esc_html__('Space Between', 'elementor-pro'), |
66
|
|
|
'range' => [ |
67
|
|
|
'em' => [ |
68
|
|
|
'min' => 0, |
69
|
|
|
'max' => 4, |
70
|
|
|
'step' => 0.1, |
71
|
|
|
], |
72
|
|
|
'px' => [ |
73
|
|
|
'min' => 0, |
74
|
|
|
'max' => 50, |
75
|
|
|
'step' => 1, |
76
|
|
|
], |
77
|
|
|
], |
78
|
|
|
'selectors' => [ |
79
|
|
|
'.woocommerce:not(.rtl) {{WRAPPER}} .glsr-star' => 'margin-right: {{SIZE}}{{UNIT}}', |
80
|
|
|
'.woocommerce.rtl {{WRAPPER}} .glsr-star ' => 'margin-left: {{SIZE}}{{UNIT}}', |
81
|
|
|
], |
82
|
|
|
'size_units' => ['px', 'em', 'custom'], |
83
|
|
|
'type' => Controls_Manager::SLIDER, |
84
|
|
|
]); |
85
|
|
|
$this->add_responsive_control('alignment', [ |
86
|
|
|
'label' => esc_html__('Alignment', 'elementor-pro'), |
87
|
|
|
'options' => [ |
88
|
|
|
'left' => [ |
89
|
|
|
'title' => esc_html__('Left', 'elementor-pro'), |
90
|
|
|
'icon' => 'eicon-text-align-left', |
91
|
|
|
], |
92
|
|
|
'center' => [ |
93
|
|
|
'title' => esc_html__('Center', 'elementor-pro'), |
94
|
|
|
'icon' => 'eicon-text-align-center', |
95
|
|
|
], |
96
|
|
|
'right' => [ |
97
|
|
|
'title' => esc_html__('Right', 'elementor-pro'), |
98
|
|
|
'icon' => 'eicon-text-align-right', |
99
|
|
|
], |
100
|
|
|
'justify' => [ |
101
|
|
|
'title' => esc_html__('Justified', 'elementor-pro'), |
102
|
|
|
'icon' => 'eicon-text-align-justify', |
103
|
|
|
], |
104
|
|
|
], |
105
|
|
|
'prefix_class' => 'elementor-product-rating--align-', |
106
|
|
|
'type' => Controls_Manager::CHOOSE, |
107
|
|
|
]); |
108
|
|
|
$this->end_controls_section(); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
protected function render() |
112
|
|
|
{ |
113
|
|
|
global $product; |
114
|
|
|
if ($product = wc_get_product()) { |
115
|
|
|
glsr(Template::class)->render('templates/woocommerce/rating', [ |
116
|
|
|
'product' => $product, |
117
|
|
|
'ratings' => glsr_get_ratings(['assigned_posts' => 'post_id']), |
118
|
|
|
'style' => 'glsr glsr-'.glsr(Style::class)->styleClasses(), |
119
|
|
|
'theme' => glsr_get_option('integrations.woocommerce.style'), |
120
|
|
|
]); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|