PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.9.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.9.2
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / widgets / product-rating / product-rating.php
shopengine / widgets / product-rating Last commit date
screens 5 days ago product-rating-config.php 4 years ago product-rating.php 5 days ago
product-rating.php
276 lines
1 <?php
2
3 namespace Elementor;
4
5 use ShopEngine\Widgets\Products;
6
7 defined('ABSPATH') || exit;
8
9 class ShopEngine_Product_Rating extends \ShopEngine\Base\Widget
10 {
11
12 public function config() {
13 return new ShopEngine_Product_Rating_Config();
14 }
15
16 protected function register_controls() {
17
18 $this->start_controls_section(
19 'shopengine_rating_contents',
20 array(
21 'label' => esc_html__('Label', 'shopengine'),
22 'tab' => Controls_Manager::TAB_CONTENT,
23 )
24 );
25 $this->add_control(
26 'shopengine_rating_singular_label',
27 [
28 'label' => esc_html__('Rating Singular Label', 'shopengine'),
29 'type' => Controls_Manager::TEXT,
30 'label_block' => true,
31 'description' => esc_html__('Will display when 1 review', 'shopengine'),
32 ]
33 );
34 $this->add_control(
35 'shopengine_rating_plural_label',
36 [
37 'label' => esc_html__('Rating Plural Label', 'shopengine'),
38 'type' => Controls_Manager::TEXT,
39 'label_block' => true,
40 'description' => esc_html__('Will display when it is not 1 review', 'shopengine'),
41 ]
42 );
43 $this->add_control(
44 'shopengine_show_zero_reviews',
45 [
46 'label' => esc_html__('Show Review Section (Even if 0 Reviews)', 'shopengine'),
47 'type' => Controls_Manager::SWITCHER,
48 'label_on' => esc_html__('Yes', 'shopengine'),
49 'label_off' => esc_html__('No', 'shopengine'),
50 'return_value' => 'yes',
51 'default' => 'no',
52 'description' => esc_html__('Enable this to display the rating section even when the product has no reviews', 'shopengine'),
53 ]
54 );
55 $this->end_controls_section();
56
57 $this->start_controls_section(
58 'shopengine_rating_section_style',
59 array(
60 'label' => esc_html__('Rating', 'shopengine'),
61 'tab' => Controls_Manager::TAB_STYLE,
62 )
63 );
64
65 $this->add_control(
66 'shopengine_rating_star_head',
67 [
68 'label' => esc_html__('Rating Star', 'shopengine'),
69 'type' => Controls_Manager::HEADING,
70 ]
71 );
72
73 $this->add_control(
74 'shopengine_rating_star_color',
75 [
76 'label' => esc_html__('Star Color', 'shopengine'),
77 'type' => Controls_Manager::COLOR,
78 'default' => '#FEC42D',
79 'alpha' => false,
80 'selectors' => [
81 '{{WRAPPER}} .shopengine-product-rating' => 'line-height: 0;',
82 '{{WRAPPER}} .shopengine-product-rating .star-rating' => 'margin: 0; color: {{VALUE}};',
83 '{{WRAPPER}} .shopengine-product-rating .star-rating span::before' => 'color: {{VALUE}};',
84 ],
85 ]
86 );
87
88 $this->add_control(
89 'shopengine_rating_empty_star_color',
90 [
91 'label' => esc_html__('Empty Star Color', 'shopengine'),
92 'type' => Controls_Manager::COLOR,
93 'default' => '#d3ced2',
94 'alpha' => false,
95 'selectors' => [
96 '{{WRAPPER}} .shopengine-product-rating .star-rating::before' => 'color: {{VALUE}};',
97 ],
98 ]
99 );
100
101 $this->add_control(
102 'shopengine_rating_star_size',
103 [
104 'label' => esc_html__('Star Size (px)', 'shopengine'),
105 'type' => Controls_Manager::SLIDER,
106 'size_units' => ['px'],
107 'range' => [
108 'px' => [
109 'min' => 0,
110 'max' => 100,
111 'step' => 1,
112 ],
113 ],
114 'selectors' => [
115 '{{WRAPPER}} .shopengine-product-rating .star-rating' => 'font-size: {{SIZE}}{{UNIT}}',
116 ],
117 ]
118 );
119
120 $this->add_control(
121 'shopengine_review_link_head',
122 [
123 'label' => esc_html__('Review Link', 'shopengine'),
124 'type' => Controls_Manager::HEADING,
125 'separator' => 'before',
126 ]
127 );
128
129 $this->add_control(
130 'shopengine_rating_link_color',
131 [
132 'label' => esc_html__('Link Color', 'shopengine'),
133 'type' => Controls_Manager::COLOR,
134 'default' => '#666666',
135 'alpha' => false,
136 'selectors' => [
137 '{{WRAPPER}} .shopengine-product-rating a' => 'color: {{VALUE}}',
138 '{{WRAPPER}} .shopengine-product-rating .woocommerce-review-link' => 'float: left;',
139 ],
140 ]
141 );
142
143 $this->add_control(
144 'shopengine_rating_link_hover_color',
145 [
146 'label' => esc_html__('Link Hover Color', 'shopengine'),
147 'type' => Controls_Manager::COLOR,
148 'alpha' => false,
149 'selectors' => [
150 '{{WRAPPER}} .shopengine-product-rating a:hover' => 'color: {{VALUE}}',
151 ],
152 ]
153 );
154
155 $this->add_group_control(
156 Group_Control_Typography::get_type(),
157 array(
158 'name' => 'shopengine_rating_text_typography',
159 'label' => esc_html__('Typography', 'shopengine'),
160 'selector' => '{{WRAPPER}} .shopengine-product-rating a',
161 'exclude' => ['letter_spacing', 'font_style', 'text_decoration'],
162 'fields_options' => [
163 'typography' => [
164 'default' => 'custom',
165 ],
166 'font_family' => [
167 'default' => '',
168 ],
169 'font_weight' => [
170 'default' => '500',
171 ],
172 'font_size' => [
173 'label' => esc_html__('Font Size (px)', 'shopengine'),
174 'default' => [
175 'size' => '13',
176 'unit' => 'px',
177 ],
178 'size_units' => ['px'],
179 ],
180 'text_transform' => [
181 'default' => '',
182 ],
183 'line_height' => [
184 'label' => esc_html__('Line Height (px)', 'shopengine'),
185 'default' => [
186 'size' => '16',
187 'unit' => 'px',
188 ],
189 'size_units' => ['px'],
190 'tablet_default' => [
191 'unit' => 'px',
192 ],
193 'mobile_default' => [
194 'unit' => 'px',
195 ],
196 ],
197 'letter_spacing' => [
198 'default' => [
199 'size' => '',
200 ]
201 ],
202 ],
203 )
204 );
205
206 $this->add_control(
207 'shopengine_rating_space_between',
208 [
209 'label' => esc_html__('Left Spacing (px)', 'shopengine'),
210 'type' => Controls_Manager::SLIDER,
211 'size_units' => ['px'],
212 'range' => [
213 'px' => [
214 'min' => 0,
215 'max' => 100,
216 'step' => 1,
217 ],
218 ],
219 'default' => [
220 'unit' => 'px',
221 'size' => 5,
222 ],
223 'selectors' => [
224 'body:not(.rtl) {{WRAPPER}} .shopengine-product-rating .star-rating' => 'margin-right: {{SIZE}}{{UNIT}}',
225 'body.rtl {{WRAPPER}} .shopengine-product-rating .star-rating' => 'margin-left: {{SIZE}}{{UNIT}}',
226 ],
227 ]
228 );
229
230 $this->add_responsive_control(
231 'shopengine_rating_alignment',
232 [
233 'label' => esc_html__('Alignment', 'shopengine'),
234 'type' => Controls_Manager::CHOOSE,
235 'options' => [
236 'left' => [
237 'title' => esc_html__('Left', 'shopengine'),
238 'icon' => 'eicon-text-align-left',
239 ],
240 'center' => [
241 'title' => esc_html__('Center', 'shopengine'),
242 'icon' => 'eicon-text-align-center',
243 ],
244 'right' => [
245 'title' => esc_html__('Right', 'shopengine'),
246 'icon' => 'eicon-text-align-right',
247 ]
248 ],
249 'prefix_class' => 'elementors-align-',
250 'selectors' => [
251 '{{WRAPPER}} .shopengine-product-rating .woocommerce-product-rating' => 'display: inline-block; margin: 0;',
252 '.rtl {{WRAPPER}}.elementors-align-left .shopengine-product-rating' => 'text-align: right;',
253 '.rtl {{WRAPPER}}.elementors-align-right .shopengine-product-rating' => 'text-align: left;',
254 '.rtl {{WRAPPER}}.elementors-align-center .shopengine-product-rating' => 'text-align: center;',
255 ],
256 'separator' => 'before',
257 ]
258 );
259
260 $this->end_controls_section();
261 }
262
263 protected function screen() {
264
265 $settings = $this->get_settings_for_display();
266
267 $post_type = get_post_type();
268
269 $product = Products::instance()->get_product($post_type);
270
271 $tpl = Products::instance()->get_widget_template($this->get_name());
272
273 include $tpl;
274 }
275 }
276