PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.2
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.2
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / image-comparison / image-comparison.php
elementskit-lite / widgets / image-comparison Last commit date
image-comparison-handler.php 3 years ago image-comparison.php 1 week ago
image-comparison.php
687 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Image_Comparison_Handler as Handler;
5 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9 class ElementsKit_Widget_Image_Comparison extends Widget_Base {
10 use \ElementsKit_Lite\Widgets\Widget_Notice;
11
12 public $base;
13
14 public function __construct( $data = [], $args = null ) {
15 parent::__construct( $data, $args );
16 }
17
18 public function get_script_depends() {
19 return ['imagesloaded','event.move', 'twentytwenty','ekit-image-comparison'];
20 }
21
22 public function get_style_depends() {
23 return ['twentytwenty','ekit-image-comparison'];
24 }
25
26 public function get_name() {
27 return Handler::get_name();
28 }
29
30 public function get_title() {
31 return Handler::get_title();
32 }
33
34 public function get_icon() {
35 return Handler::get_icon();
36 }
37
38 public function get_categories() {
39 return Handler::get_categories();
40 }
41
42 public function get_keywords() {
43 return Handler::get_keywords();
44 }
45
46 public function get_help_url() {
47 return 'https://wpmet.com/doc/image-comparisn/';
48 }
49 protected function is_dynamic_content(): bool {
50 return false;
51 }
52
53 protected function register_controls() {
54
55 $this->start_controls_section(
56 'ekit_img_comparison_section_items',
57 [
58 'label' => esc_html__( 'Items', 'elementskit-lite' ),
59 ]
60 );
61
62
63 $this->add_control(
64 'ekit_img_comparison_container_style',
65 [
66 'label' => esc_html__( 'Container Style', 'elementskit-lite' ),
67 'type' => Controls_Manager::SELECT,
68 'options' => [
69 'horizontal' => esc_html__( 'Horizontal', 'elementskit-lite' ),
70 'vertical' => esc_html__( 'Vertical', 'elementskit-lite' ),
71 ],
72 'default' => 'vertical',
73 ]
74 );
75 $this->add_control(
76 'ekit_img_comparison_before_heading_section',
77 [
78 'label' => esc_html__( 'Before', 'elementskit-lite' ),
79 'type' => Controls_Manager::HEADING,
80 'separator' => 'before',
81 ]
82 );
83 $this->add_control(
84 'ekit_img_comparison_image_before',
85 [
86 'label' => esc_html__( 'Choose Image', 'elementskit-lite' ),
87 'type' => Controls_Manager::MEDIA,
88 'dynamic' => [
89 'active' => true,
90 ],
91 'default' => [
92 'url' => Utils::get_placeholder_image_src(),
93 'id' => -1
94 ],
95 ]
96 );
97 $this->add_control(
98 'ekit_img_comparison_label_before',
99 [
100 'label' => esc_html__( 'Label', 'elementskit-lite' ),
101 'type' => Controls_Manager::TEXT,
102 'dynamic' => [
103 'active' => true,
104 ],
105 'default' => 'Before',
106 ]
107 );
108 $this->add_control(
109 'ekit_img_comparison_after_heading_section',
110 [
111 'label' => esc_html__( 'After', 'elementskit-lite' ),
112 'type' => Controls_Manager::HEADING,
113 'separator' => 'before',
114 ]
115 );
116 $this->add_control(
117 'ekit_img_comparison_image_after',
118 [
119 'label' => esc_html__( 'Choose Image', 'elementskit-lite' ),
120 'type' => Controls_Manager::MEDIA,
121 'dynamic' => [
122 'active' => true,
123 ],
124 'default' => [
125 'url' => Utils::get_placeholder_image_src(),
126 'id' => -1
127 ],
128 ]
129 );
130 $this->add_control(
131 'ekit_img_comparison_label_after',
132 [
133 'label' => esc_html__( 'Label', 'elementskit-lite' ),
134 'type' => Controls_Manager::TEXT,
135 'dynamic' => [
136 'active' => true,
137 ],
138 'default' => 'After',
139 ]
140 );
141
142 $this->end_controls_section();
143
144 $this->start_controls_section(
145 'ekit_img_comparison_section_settings',
146 [
147 'label' => esc_html__( 'Settings', 'elementskit-lite' ),
148 ]
149 );
150 $this->add_control(
151 'ekit_img_comparison_offset',
152 [
153 'label' => esc_html__( 'Offset', 'elementskit-lite' ),
154 'type' => Controls_Manager::SLIDER,
155 'size_units' => [ '%' ],
156 'range' => [
157 '%' => [
158 'min' => 0,
159 'max' => 100,
160 ],
161 ],
162 'default' => [
163 'unit' => '%',
164 'size' => 50,
165 ],
166 'description' => esc_html__('How much of the before image is visible when the page loads', 'elementskit-lite'),
167 ]
168 );
169 $this->add_control(
170 'ekit_img_comparison_overlay',
171 [
172 'label' => esc_html__( 'Remove overlay?', 'elementskit-lite' ),
173 'type' => Controls_Manager::SWITCHER,
174 'label_on' => esc_html__( 'Yes', 'elementskit-lite' ),
175 'label_off' => esc_html__( 'No', 'elementskit-lite' ),
176 'return_value' => true,
177 'default' => false,
178 'description' => esc_html__('Do not show the overlay with before and after', 'elementskit-lite'),
179 ]
180 );
181 $this->add_control(
182 'ekit_img_comparison_move_slider_on_hover',
183 [
184 'label' => esc_html__( 'Move slider on hover?', 'elementskit-lite' ),
185 'type' => Controls_Manager::SWITCHER,
186 'label_on' => esc_html__( 'Yes', 'elementskit-lite' ),
187 'label_off' => esc_html__( 'No', 'elementskit-lite' ),
188 'return_value' => true,
189 'default' => false,
190 'description' => esc_html__('Move slider on mouse hover?', 'elementskit-lite'),
191 ]
192 );
193 $this->add_control(
194 'ekit_img_comparison_click_to_move',
195 [
196 'label' => esc_html__( 'Click to move?', 'elementskit-lite' ),
197 'type' => Controls_Manager::SWITCHER,
198 'label_on' => esc_html__( 'Yes', 'elementskit-lite' ),
199 'label_off' => esc_html__( 'No', 'elementskit-lite' ),
200 'return_value' => true,
201 'default' => false,
202 'description' => esc_html__('Allow a user to click (or tap) anywhere on the image to move the slider to that location.', 'elementskit-lite'),
203 ]
204 );
205 $this->end_controls_section();
206
207 /**
208 * General Style Section
209 */
210 $this->start_controls_section(
211 'ekit_img_comparison_general_style',
212 array(
213 'label' => esc_html__( 'General', 'elementskit-lite' ),
214 'tab' => Controls_Manager::TAB_STYLE,
215 'show_label' => false,
216 )
217 );
218
219 $this->add_group_control(
220 Group_Control_Border::get_type(),
221 array(
222 'name' => 'ekit_img_comparison_container_border',
223 'label' => esc_html__( 'Border', 'elementskit-lite' ),
224 'placeholder' => '1px',
225 'default' => '1px',
226 'selector' => '{{WRAPPER}} .elementskit-image-comparison',
227 )
228 );
229
230 $this->add_responsive_control(
231 'ekit_img_comparison_container_border_radius',
232 array(
233 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
234 'type' => Controls_Manager::DIMENSIONS,
235 'size_units' => array( 'px', '%' ),
236 'selectors' => array(
237 '{{WRAPPER}} .elementskit-image-comparison' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
238 ),
239 )
240 );
241
242 $this->add_responsive_control(
243 'ekit_img_comparison_container_padding',
244 array(
245 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
246 'type' => Controls_Manager::DIMENSIONS,
247 'size_units' => array( 'px', '%' ),
248 'selectors' => array(
249 '{{WRAPPER}} .elementskit-image-comparison' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
250 ),
251 )
252 );
253
254 $this->add_group_control(
255 Group_Control_Box_Shadow::get_type(),
256 array(
257 'name' => 'ekit_img_comparison_container_box_shadow',
258 'exclude' => array('box_shadow_position'), // PHPCS:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
259 'selector' => '{{WRAPPER}} .elementskit-image-comparison',
260 )
261 );
262
263 $this->end_controls_section();
264
265 /**
266 * Label Style Section
267 */
268 $this->start_controls_section(
269 'ekit_img_comparison_label_style',
270 array(
271 'label' => esc_html__( 'Label', 'elementskit-lite' ),
272 'tab' => Controls_Manager::TAB_STYLE,
273 'show_label' => false,
274 'condition' => ['ekit_img_comparison_overlay!' => 'true'],
275 )
276 );
277
278 $this->start_controls_tabs( 'ekit_img_comparison_tabs_label_styles' );
279
280 $this->start_controls_tab(
281 'ekit_img_comparison_tab_label_before',
282 array(
283 'label' => esc_html__( 'Before', 'elementskit-lite' ),
284 )
285 );
286
287 $this->add_responsive_control(
288 'ekit_img_comparison_before_label_color',
289 array(
290 'label' => esc_html__( 'Color', 'elementskit-lite' ),
291 'type' => Controls_Manager::COLOR,
292 'selectors' => array(
293 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-before-label:before' => 'color: {{VALUE}}',
294 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before' => 'color: {{VALUE}}',
295 ),
296 )
297 );
298
299 $this->add_group_control(
300 Group_Control_Typography::get_type(),
301 array(
302 'name' => 'ekit_img_comparison_before_label_typography_group',
303 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-before-label:before',
304 )
305 );
306
307 $this->add_group_control(
308 Group_Control_Background::get_type(),
309 array(
310 'name' => 'ekit_img_comparison_before_label_background_group',
311 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-before-label:before',
312 )
313 );
314
315 $this->add_responsive_control(
316 'ekit_img_comparison_before_label_margin',
317 array(
318 'label' => esc_html__( 'Margin', 'elementskit-lite' ),
319 'type' => Controls_Manager::DIMENSIONS,
320 'size_units' => array( 'px', '%' ),
321 'selectors' => array(
322 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-before-label:before' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
323 ),
324 )
325 );
326
327 $this->add_responsive_control(
328 'ekit_img_comparison_before_label_padding',
329 array(
330 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
331 'type' => Controls_Manager::DIMENSIONS,
332 'size_units' => array( 'px', '%' ),
333 'selectors' => array(
334 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-before-label:before' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
335 ),
336 )
337 );
338 $this->end_controls_tab();
339
340 $this->start_controls_tab(
341 'ekit_img_comparison_tab_label_after',
342 array(
343 'label' => esc_html__( 'After', 'elementskit-lite' ),
344 )
345 );
346
347 $this->add_responsive_control(
348 'ekit_img_comparison_after_label_color',
349 array(
350 'label' => esc_html__( 'Color', 'elementskit-lite' ),
351 'type' => Controls_Manager::COLOR,
352 'selectors' => array(
353 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before' => 'color: {{VALUE}}',
354 ),
355 )
356 );
357
358 $this->add_group_control(
359 Group_Control_Typography::get_type(),
360 array(
361 'name' => 'ekit_img_comparison_after_label_typography_group',
362 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before',
363 )
364 );
365
366 $this->add_group_control(
367 Group_Control_Background::get_type(),
368 array(
369 'name' => 'ekit_img_comparison_after_label_background_group',
370 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before',
371 )
372 );
373
374 $this->add_responsive_control(
375 'ekit_img_comparison_after_label_margin',
376 array(
377 'label' => esc_html__( 'Margin', 'elementskit-lite' ),
378 'type' => Controls_Manager::DIMENSIONS,
379 'size_units' => array( 'px', '%' ),
380 'selectors' => array(
381 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
382 ),
383 )
384 );
385
386 $this->add_responsive_control(
387 'ekit_img_comparison_after_label_padding',
388 array(
389 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
390 'type' => Controls_Manager::DIMENSIONS,
391 'size_units' => array( 'px', '%' ),
392 'selectors' => array(
393 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-after-label:before' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
394 ),
395 )
396 );
397
398 $this->end_controls_tab();
399
400 $this->end_controls_tabs();
401
402 $this->end_controls_section();
403
404 /**
405 * Handle Style Section
406 */
407 $this->start_controls_section(
408 'ekit_img_comparison_handle_style',
409 array(
410 'label' => esc_html__( 'Handle', 'elementskit-lite' ),
411 'tab' => Controls_Manager::TAB_STYLE,
412 'show_label' => false,
413 )
414 );
415
416 $this->add_responsive_control(
417 'ekit_img_comparison_handle_control_width',
418 array(
419 'label' => esc_html__( 'Control Width', 'elementskit-lite' ),
420 'type' => Controls_Manager::SLIDER,
421 'size_units' => array( 'px' ),
422 'range' => array(
423 'px' => array(
424 'min' => 20,
425 'max' => 100,
426 ),
427 ),
428 'selectors' => array(
429 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle' => 'width: {{SIZE}}{{UNIT}}; margin-left: calc( {{SIZE}}{{UNIT}} / -2 );',
430 )
431 )
432 );
433
434 $this->add_responsive_control(
435 'ekit_img_comparison_handle_control_height',
436 array(
437 'label' => esc_html__( 'Height', 'elementskit-lite' ),
438 'type' => Controls_Manager::SLIDER,
439 'size_units' => array( 'px' ),
440 'range' => array(
441 'px' => array(
442 'min' => 20,
443 'max' => 100,
444 ),
445 ),
446 'selectors' => array(
447 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle' => 'height: {{SIZE}}{{UNIT}};margin-top: calc( {{SIZE}}{{UNIT}} / -2 );',
448 )
449 )
450 );
451
452 $this->start_controls_tabs( 'ekit_img_comparison_tabs_handle_styles' );
453
454 $this->start_controls_tab(
455 'ekit_img_comparison_tab_handle_normal',
456 array(
457 'label' => esc_html__( 'Normal', 'elementskit-lite' ),
458 )
459 );
460
461 $this->add_group_control(
462 Group_Control_Background::get_type(),
463 array(
464 'name' => 'ekit_img_comparison_handle_control_background_group',
465 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle',
466 )
467 );
468
469 $this->add_responsive_control(
470 'ekit_img_comparison_handle_arrow_color',
471 array(
472 'label' => esc_html__( 'Arrow Color', 'elementskit-lite' ),
473 'type' => Controls_Manager::COLOR,
474 'default' => '#000',
475 'selectors' => array(
476 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle .twentytwenty-left-arrow' => 'border-right-color: {{VALUE}}',
477 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle .twentytwenty-right-arrow' => 'border-left-color: {{VALUE}}',
478 ),
479 'condition' => [
480 'ekit_img_comparison_container_style' => 'horizontal'
481 ]
482 )
483 );
484
485 $this->add_responsive_control(
486 'ekit_img_comparison_handle_arrow_color_vertical',
487 array(
488 'label' => esc_html__( 'Arrow Color', 'elementskit-lite' ),
489 'type' => Controls_Manager::COLOR,
490 'default' => '#000',
491 'selectors' => array(
492 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle .twentytwenty-up-arrow' => 'border-bottom-color: {{VALUE}}',
493 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle .twentytwenty-down-arrow' => 'border-top-color: {{VALUE}}',
494 ),
495 'condition' => [
496 'ekit_img_comparison_container_style' => 'vertical'
497 ]
498 )
499 );
500
501 $this->add_group_control(
502 Group_Control_Box_Shadow::get_type(),
503 array(
504 'name' => 'ekit_img_comparison_handle_control_box_shadow_group',
505 'selector' => '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle',
506 )
507 );
508
509 $this->end_controls_tab();
510
511 $this->start_controls_tab(
512 'ekit_img_comparison_tab_handle_hover',
513 array(
514 'label' => esc_html__( 'Hover', 'elementskit-lite' ),
515 )
516 );
517
518 $this->add_group_control(
519 Group_Control_Background::get_type(),
520 array(
521 'name' => 'ekit_img_comparison_handle_control_background_hover_group',
522 'selector' => '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle',
523 )
524 );
525
526 $this->add_responsive_control(
527 'ekit_img_comparison_handle_arrow_color_hover',
528 array(
529 'label' => esc_html__( 'Arrow Color', 'elementskit-lite' ),
530 'type' => Controls_Manager::COLOR,
531
532 'selectors' => array(
533 '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle .twentytwenty-left-arrow' => 'border-right-color: {{VALUE}}',
534 '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle .twentytwenty-right-arrow' => 'border-left-color: {{VALUE}}',
535 ),
536 'condition' => [
537 'ekit_img_comparison_container_style' => 'horizontal'
538 ]
539 )
540 );
541
542 $this->add_responsive_control(
543 'ekit_img_comparison_handle_arrow_color_hover_vertical',
544 array(
545 'label' => esc_html__( 'Arrow Color', 'elementskit-lite' ),
546 'type' => Controls_Manager::COLOR,
547
548 'selectors' => array(
549 '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle .twentytwenty-up-arrow' => 'border-bottom-color: {{VALUE}}',
550 '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle .twentytwenty-down-arrow' => 'border-top-color: {{VALUE}}',
551 ),
552 'condition' => [
553 'ekit_img_comparison_container_style' => 'vertical'
554 ]
555 )
556 );
557
558 $this->add_group_control(
559 Group_Control_Box_Shadow::get_type(),
560 array(
561 'name' => 'ekit_img_comparison_handle_control_box_shadow_hover_group',
562 'selector' => '{{WRAPPER}} .elementskit-image-comparison:hover .twentytwenty-handle',
563 )
564 );
565
566 $this->end_controls_tab();
567
568 $this->end_controls_tabs();
569
570 $this->add_responsive_control(
571 'ekit_img_comparison_handle_divider_margin',
572 array(
573 'label' => esc_html__( 'Margin', 'elementskit-lite' ),
574 'type' => Controls_Manager::DIMENSIONS,
575 'size_units' => array( 'px', '%' ),
576 'selectors' => array(
577 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
578 ),
579 'separator' => 'before',
580 )
581 );
582
583 $this->add_responsive_control(
584 'ekit_img_comparison_handle_divider_radius',
585 array(
586 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
587 'type' => Controls_Manager::DIMENSIONS,
588 'size_units' => array( 'px', '%' ),
589 'selectors' => array(
590 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
591 ),
592 )
593 );
594
595 $this->add_control(
596 'ekit_img_comparison_heading_handle_divider_style',
597 array(
598 'label' => esc_html__( 'Handle Divider', 'elementskit-lite' ),
599 'type' => Controls_Manager::HEADING,
600 'separator' => 'before',
601 )
602 );
603
604 $this->add_responsive_control(
605 'ekit_img_comparison_handle_divider_width',
606 array(
607 'label' => esc_html__( 'Divider Thickness', 'elementskit-lite' ),
608 'type' => Controls_Manager::SLIDER,
609 'size_units' => array( 'px' ),
610 'range' => array(
611 'px' => array(
612 'min' => 1,
613 'max' => 10,
614 ),
615 ),
616 'selectors' => array(
617 '{{WRAPPER}} .twentytwenty-horizontal .twentytwenty-handle:before, {{WRAPPER}} .twentytwenty-horizontal .twentytwenty-handle:after' => 'width: {{SIZE}}{{UNIT}};',
618 '{{WRAPPER}} .twentytwenty-vertical .twentytwenty-handle:before, {{WRAPPER}} .twentytwenty-vertical .twentytwenty-handle:after' => 'height: {{SIZE}}{{UNIT}};',
619 )
620 )
621 );
622
623 $this->add_responsive_control(
624 'ekit_img_comparison_handle_divider_color',
625 array(
626 'label' => esc_html__( 'Divider Color', 'elementskit-lite' ),
627 'type' => Controls_Manager::COLOR,
628 'selectors' => array(
629 '{{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle:before, {{WRAPPER}} .elementskit-image-comparison .twentytwenty-handle:after' => 'background-color: {{VALUE}};',
630 ),
631 )
632 );
633
634 $this->end_controls_section();
635
636 $this->insert_pro_message();
637 }
638
639 protected function render( ) {
640 echo '<div class="ekit-wid-con" >';
641 $this->render_raw();
642 echo '</div>';
643 }
644
645 protected function render_raw( ) {
646 $settings = $this->get_settings_for_display();
647
648 if($settings['ekit_img_comparison_container_style'] == 'vertical') :
649 $this->add_render_attribute( 'image_comparison_wrapper', 'class', 'elementskit-image-comparison image-comparison-container-vertical');
650 else :
651 $this->add_render_attribute( 'image_comparison_wrapper', 'class', 'elementskit-image-comparison image-comparison-container');
652 endif;
653
654 $label_after = sanitize_text_field($settings['ekit_img_comparison_label_after']);
655 $label_before = sanitize_text_field($settings['ekit_img_comparison_label_before']);
656
657 $this->add_render_attribute(
658 'image_comparison_wrapper',
659 [
660 'data-offset' => esc_attr($settings['ekit_img_comparison_offset']['size'] / 100),
661 'data-overlay' => esc_attr($settings['ekit_img_comparison_overlay']),
662 'data-label_after' => esc_attr($label_after),
663 'data-label_before' => esc_attr($label_before),
664 'data-move_slider_on_hover' => esc_attr($settings['ekit_img_comparison_move_slider_on_hover']),
665 'data-click_to_move' => esc_attr($settings['ekit_img_comparison_click_to_move']),
666 'data-a11y_label' => esc_attr__( 'Image comparison slider', 'elementskit-lite' ),
667 ]
668 );
669
670 $image_html = '';
671 if ( ! empty( $settings['ekit_img_comparison_image_before']['url'] ) ) {
672 $image_html .= Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'ekit_img_comparison_image_before' );
673 }
674
675 $image_before_html = '';
676 if ( ! empty( $settings['ekit_img_comparison_image_after']['url'] ) ) {
677 $image_html .= Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'ekit_img_comparison_image_after' );
678 }
679 ?>
680
681 <div <?php $this->print_render_attribute_string( 'image_comparison_wrapper' ); ?>>
682 <?php echo wp_kses($image_html, \ElementsKit_Lite\Utils::get_kses_array()); ?>
683 </div>
684
685 <?php }
686 }
687