PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.1
Elementor Website Builder – more than just a page builder v3.3.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / widgets / common.php

common.php in Elementor Website Builder – more than just a page builder 3.3.1, at includes/widgets/common.php

1,055 lines 24.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor common widget.
10 *
11 * Elementor base widget that gives you all the advanced options of the basic
12 * widget.
13 *
14 * @since 1.0.0
15 */
16 class Widget_Common extends Widget_Base {
17
18 /**
19 * Get widget name.
20 *
21 * Retrieve common widget name.
22 *
23 * @since 1.0.0
24 * @access public
25 *
26 * @return string Widget name.
27 */
28 public function get_name() {
29 return 'common';
30 }
31
32 /**
33 * Show in panel.
34 *
35 * Whether to show the common widget in the panel or not.
36 *
37 * @since 1.0.0
38 * @access public
39 *
40 * @return bool Whether to show the widget in the panel.
41 */
42 public function show_in_panel() {
43 return false;
44 }
45
46 /**
47 * @param $shape String Shape name.
48 *
49 * @return string The shape path in the assets folder.
50 */
51 private function get_shape_url( $shape ) {
52 return ELEMENTOR_ASSETS_URL . 'mask-shapes/' . $shape . '.svg';
53 }
54
55 /**
56 * Return a translated user-friendly list of the available masking shapes.
57 *
58 * @param bool $add_custom Determine if the output should contain `Custom` options.
59 *
60 * @return array Array of shapes with their URL as key.
61 */
62 private function get_shapes( $add_custom = true ) {
63 $shapes = [
64 'circle' => __( 'Circle', 'elementor' ),
65 'flower' => __( 'Flower', 'elementor' ),
66 'sketch' => __( 'Sketch', 'elementor' ),
67 'triangle' => __( 'Triangle', 'elementor' ),
68 'blob' => __( 'Blob', 'elementor' ),
69 'hexagon' => __( 'Hexagon', 'elementor' ),
70 ];
71
72 if ( $add_custom ) {
73 $shapes['custom'] = __( 'Custom', 'elementor' );
74 }
75
76 return $shapes;
77 }
78
79 /**
80 * Gets a string of CSS rules to apply, and returns an array of selectors with those rules.
81 * This function has been created in order to deal with masking for image widget.
82 * For most of the widgets the mask is being applied to the wrapper itself, but in the case of an image widget,
83 * the `img` tag should be masked directly. So instead of writing a lot of selectors every time,
84 * this function builds both of those selectors easily.
85 *
86 * @param $rules string The CSS rules to apply.
87 *
88 * @return array Selectors with the rules applied.
89 */
90 private function get_mask_selectors( $rules ) {
91 $mask_selectors = [
92 'default' => '{{WRAPPER}}:not( .elementor-widget-image ) .elementor-widget-container',
93 'image' => '{{WRAPPER}}.elementor-widget-image .elementor-widget-container img',
94 ];
95
96 return [
97 $mask_selectors['default'] => $rules,
98 $mask_selectors['image'] => $rules,
99 ];
100 }
101
102 /**
103 * Register common widget controls.
104 *
105 * Adds different input fields to allow the user to change and customize the widget settings.
106 *
107 * @since 3.1.0
108 * @access protected
109 */
110 protected function register_controls() {
111 $this->start_controls_section(
112 '_section_style',
113 [
114 'label' => __( 'Advanced', 'elementor' ),
115 'tab' => Controls_Manager::TAB_ADVANCED,
116 ]
117 );
118
119 // Element Name for the Navigator
120 $this->add_control(
121 '_title',
122 [
123 'label' => __( 'Title', 'elementor' ),
124 'type' => Controls_Manager::HIDDEN,
125 'render_type' => 'none',
126 ]
127 );
128
129 $this->add_responsive_control(
130 '_margin',
131 [
132 'label' => __( 'Margin', 'elementor' ),
133 'type' => Controls_Manager::DIMENSIONS,
134 'size_units' => [ 'px', 'em', '%', 'rem' ],
135 'selectors' => [
136 '{{WRAPPER}} > .elementor-widget-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
137 ],
138 ]
139 );
140
141 $this->add_responsive_control(
142 '_padding',
143 [
144 'label' => __( 'Padding', 'elementor' ),
145 'type' => Controls_Manager::DIMENSIONS,
146 'size_units' => [ 'px', 'em', '%', 'rem' ],
147 'selectors' => [
148 '{{WRAPPER}} > .elementor-widget-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
149 ],
150 ]
151 );
152
153 $this->add_responsive_control(
154 '_z_index',
155 [
156 'label' => __( 'Z-Index', 'elementor' ),
157 'type' => Controls_Manager::NUMBER,
158 'min' => 0,
159 'selectors' => [
160 '{{WRAPPER}}' => 'z-index: {{VALUE}};',
161 ],
162 'separator' => 'before',
163 ]
164 );
165
166 $this->add_control(
167 '_element_id',
168 [
169 'label' => __( 'CSS ID', 'elementor' ),
170 'type' => Controls_Manager::TEXT,
171 'dynamic' => [
172 'active' => true,
173 ],
174 'default' => '',
175 'title' => __( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ),
176 'style_transfer' => false,
177 'classes' => 'elementor-control-direction-ltr',
178 ]
179 );
180
181 $this->add_control(
182 '_css_classes',
183 [
184 'label' => __( 'CSS Classes', 'elementor' ),
185 'type' => Controls_Manager::TEXT,
186 'dynamic' => [
187 'active' => true,
188 ],
189 'prefix_class' => '',
190 'title' => __( 'Add your custom class WITHOUT the dot. e.g: my-class', 'elementor' ),
191 'classes' => 'elementor-control-direction-ltr',
192 ]
193 );
194
195 $this->end_controls_section();
196
197 $this->start_controls_section(
198 'section_effects',
199 [
200 'label' => __( 'Motion Effects', 'elementor' ),
201 'tab' => Controls_Manager::TAB_ADVANCED,
202 ]
203 );
204
205 $this->add_responsive_control(
206 '_animation',
207 [
208 'label' => __( 'Entrance Animation', 'elementor' ),
209 'type' => Controls_Manager::ANIMATION,
210 'frontend_available' => true,
211 ]
212 );
213
214 $this->add_control(
215 'animation_duration',
216 [
217 'label' => __( 'Animation Duration', 'elementor' ),
218 'type' => Controls_Manager::SELECT,
219 'default' => '',
220 'options' => [
221 'slow' => __( 'Slow', 'elementor' ),
222 '' => __( 'Normal', 'elementor' ),
223 'fast' => __( 'Fast', 'elementor' ),
224 ],
225 'prefix_class' => 'animated-',
226 'condition' => [
227 '_animation!' => '',
228 ],
229 ]
230 );
231
232 $this->add_control(
233 '_animation_delay',
234 [
235 'label' => __( 'Animation Delay', 'elementor' ) . ' (ms)',
236 'type' => Controls_Manager::NUMBER,
237 'default' => '',
238 'min' => 0,
239 'step' => 100,
240 'condition' => [
241 '_animation!' => '',
242 ],
243 'render_type' => 'none',
244 'frontend_available' => true,
245 ]
246 );
247
248 $this->end_controls_section();
249
250 $this->start_controls_section(
251 '_section_background',
252 [
253 'label' => __( 'Background', 'elementor' ),
254 'tab' => Controls_Manager::TAB_ADVANCED,
255 ]
256 );
257
258 $this->start_controls_tabs( '_tabs_background' );
259
260 $this->start_controls_tab(
261 '_tab_background_normal',
262 [
263 'label' => __( 'Normal', 'elementor' ),
264 ]
265 );
266
267 $this->add_group_control(
268 Group_Control_Background::get_type(),
269 [
270 'name' => '_background',
271 'selector' => '{{WRAPPER}} > .elementor-widget-container',
272 ]
273 );
274
275 $this->end_controls_tab();
276
277 $this->start_controls_tab(
278 '_tab_background_hover',
279 [
280 'label' => __( 'Hover', 'elementor' ),
281 ]
282 );
283
284 $this->add_group_control(
285 Group_Control_Background::get_type(),
286 [
287 'name' => '_background_hover',
288 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
289 ]
290 );
291
292 $this->add_control(
293 '_background_hover_transition',
294 [
295 'label' => __( 'Transition Duration', 'elementor' ),
296 'type' => Controls_Manager::SLIDER,
297 'range' => [
298 'px' => [
299 'max' => 3,
300 'step' => 0.1,
301 ],
302 ],
303 'render_type' => 'ui',
304 'separator' => 'before',
305 'selectors' => [
306 '{{WRAPPER}} > .elementor-widget-container' => 'transition: background {{SIZE}}s',
307 ],
308 ]
309 );
310
311 $this->end_controls_tab();
312
313 $this->end_controls_tabs();
314
315 $this->end_controls_section();
316
317 $this->start_controls_section(
318 '_section_border',
319 [
320 'label' => __( 'Border', 'elementor' ),
321 'tab' => Controls_Manager::TAB_ADVANCED,
322 ]
323 );
324
325 $this->start_controls_tabs( '_tabs_border' );
326
327 $this->start_controls_tab(
328 '_tab_border_normal',
329 [
330 'label' => __( 'Normal', 'elementor' ),
331 ]
332 );
333
334 $this->add_group_control(
335 Group_Control_Border::get_type(),
336 [
337 'name' => '_border',
338 'selector' => '{{WRAPPER}} > .elementor-widget-container',
339 ]
340 );
341
342 $this->add_responsive_control(
343 '_border_radius',
344 [
345 'label' => __( 'Border Radius', 'elementor' ),
346 'type' => Controls_Manager::DIMENSIONS,
347 'size_units' => [ 'px', '%' ],
348 'selectors' => [
349 '{{WRAPPER}} > .elementor-widget-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
350 ],
351 ]
352 );
353
354 $this->add_group_control(
355 Group_Control_Box_Shadow::get_type(),
356 [
357 'name' => '_box_shadow',
358 'selector' => '{{WRAPPER}} > .elementor-widget-container',
359 ]
360 );
361
362 $this->end_controls_tab();
363
364 $this->start_controls_tab(
365 '_tab_border_hover',
366 [
367 'label' => __( 'Hover', 'elementor' ),
368 ]
369 );
370
371 $this->add_group_control(
372 Group_Control_Border::get_type(),
373 [
374 'name' => '_border_hover',
375 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
376 ]
377 );
378
379 $this->add_responsive_control(
380 '_border_radius_hover',
381 [
382 'label' => __( 'Border Radius', 'elementor' ),
383 'type' => Controls_Manager::DIMENSIONS,
384 'size_units' => [ 'px', '%' ],
385 'selectors' => [
386 '{{WRAPPER}}:hover > .elementor-widget-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
387 ],
388 ]
389 );
390
391 $this->add_group_control(
392 Group_Control_Box_Shadow::get_type(),
393 [
394 'name' => '_box_shadow_hover',
395 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
396 ]
397 );
398
399 $this->add_control(
400 '_border_hover_transition',
401 [
402 'label' => __( 'Transition Duration', 'elementor' ),
403 'type' => Controls_Manager::SLIDER,
404 'separator' => 'before',
405 'range' => [
406 'px' => [
407 'max' => 3,
408 'step' => 0.1,
409 ],
410 ],
411 'selectors' => [
412 '{{WRAPPER}} .elementor-widget-container' => 'transition: background {{_background_hover_transition.SIZE}}s, border {{SIZE}}s, border-radius {{SIZE}}s, box-shadow {{SIZE}}s',
413 ],
414 ]
415 );
416
417 $this->end_controls_tab();
418
419 $this->end_controls_tabs();
420
421 $this->end_controls_section();
422
423 $this->start_controls_section(
424 '_section_masking',
425 [
426 'label' => __( 'Mask', 'elementor' ),
427 'tab' => Controls_Manager::TAB_ADVANCED,
428 ]
429 );
430
431 $this->add_control(
432 '_mask_switch',
433 [
434 'label' => __( 'Mask', 'elementor' ),
435 'type' => Controls_Manager::SWITCHER,
436 'label_on' => __( 'On', 'elementor' ),
437 'label_off' => __( 'Off', 'elementor' ),
438 'default' => '',
439 ]
440 );
441
442 $this->add_control( '_mask_shape', [
443 'label' => __( 'Shape', 'elementor' ),
444 'type' => Controls_Manager::SELECT,
445 'options' => $this->get_shapes(),
446 'default' => 'circle',
447 'selectors' => $this->get_mask_selectors( '-webkit-mask-image: url( ' . ELEMENTOR_ASSETS_URL . '/mask-shapes/{{VALUE}}.svg );' ),
448 'condition' => [
449 '_mask_switch!' => '',
450 ],
451 ] );
452
453 $this->add_control(
454 '_mask_image',
455 [
456 'label' => __( 'Image', 'elementor' ),
457 'type' => Controls_Manager::MEDIA,
458 'media_type' => 'image',
459 'should_include_svg_inline_option' => true,
460 'library_type' => 'image/svg+xml',
461 'dynamic' => [
462 'active' => true,
463 ],
464 'selectors' => $this->get_mask_selectors( '-webkit-mask-image: url( {{URL}} );' ),
465 'condition' => [
466 '_mask_switch!' => '',
467 '_mask_shape' => 'custom',
468 ],
469 ]
470 );
471
472 $this->add_control(
473 '_mask_notice',
474 [
475 'type' => Controls_Manager::HIDDEN,
476 'raw' => __( 'Need More Shapes?', 'elementor' ) . '<br>' . sprintf( __( 'Explore additional Premium Shape packs and use them in your site. <a target="_blank" href="%s">Learn More</a>', 'elementor' ), 'https://go.elementor.com/mask-control' ),
477 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
478 'condition' => [
479 '_mask_switch!' => '',
480 ],
481 ]
482 );
483
484 $this->add_responsive_control(
485 '_mask_size',
486 [
487 'label' => __( 'Size', 'elementor' ),
488 'type' => Controls_Manager::SELECT,
489 'options' => [
490 'contain' => __( 'Fit', 'elementor' ),
491 'cover' => __( 'Fill', 'elementor' ),
492 'custom' => __( 'Custom', 'elementor' ),
493 ],
494 'default' => 'contain',
495 'selectors' => $this->get_mask_selectors( '-webkit-mask-size: {{VALUE}};' ),
496 'condition' => [
497 '_mask_switch!' => '',
498 ],
499 ]
500 );
501
502 $this->add_responsive_control(
503 '_mask_size_scale',
504 [
505 'label' => __( 'Scale', 'elementor' ),
506 'type' => Controls_Manager::SLIDER,
507 'size_units' => [ 'px', 'em', '%', 'vw' ],
508 'range' => [
509 'px' => [
510 'min' => 0,
511 'max' => 500,
512 ],
513 'em' => [
514 'min' => 0,
515 'max' => 100,
516 ],
517 '%' => [
518 'min' => 0,
519 'max' => 200,
520 ],
521 'vw' => [
522 'min' => 0,
523 'max' => 100,
524 ],
525 ],
526 'default' => [
527 'unit' => '%',
528 'size' => 100,
529 ],
530 'selectors' => $this->get_mask_selectors( '-webkit-mask-size: {{SIZE}}{{UNIT}};' ),
531 'condition' => [
532 '_mask_switch!' => '',
533 '_mask_size' => 'custom',
534 ],
535 ]
536 );
537
538 $this->add_responsive_control(
539 '_mask_position',
540 [
541 'label' => __( 'Position', 'elementor' ),
542 'type' => Controls_Manager::SELECT,
543 'options' => [
544 'center center' => __( 'Center Center', 'elementor' ),
545 'center left' => __( 'Center Left', 'elementor' ),
546 'center right' => __( 'Center Right', 'elementor' ),
547 'top center' => __( 'Top Center', 'elementor' ),
548 'top left' => __( 'Top Left', 'elementor' ),
549 'top right' => __( 'Top Right', 'elementor' ),
550 'bottom center' => __( 'Bottom Center', 'elementor' ),
551 'bottom left' => __( 'Bottom Left', 'elementor' ),
552 'bottom right' => __( 'Bottom Right', 'elementor' ),
553 'custom' => __( 'Custom', 'elementor' ),
554 ],
555 'default' => 'center center',
556 'selectors' => $this->get_mask_selectors( '-webkit-mask-position: {{VALUE}};' ),
557 'condition' => [
558 '_mask_switch!' => '',
559 ],
560 ]
561 );
562
563 $this->add_responsive_control(
564 '_mask_position_x',
565 [
566 'label' => __( 'X Position', 'elementor' ),
567 'type' => Controls_Manager::SLIDER,
568 'size_units' => [ 'px', 'em', '%', 'vw' ],
569 'range' => [
570 'px' => [
571 'min' => -500,
572 'max' => 500,
573 ],
574 'em' => [
575 'min' => -100,
576 'max' => 100,
577 ],
578 '%' => [
579 'min' => -100,
580 'max' => 100,
581 ],
582 'vw' => [
583 'min' => -100,
584 'max' => 100,
585 ],
586 ],
587 'default' => [
588 'unit' => '%',
589 'size' => 0,
590 ],
591 'selectors' => $this->get_mask_selectors( '-webkit-mask-position-x: {{SIZE}}{{UNIT}};' ),
592 'condition' => [
593 '_mask_switch!' => '',
594 '_mask_position' => 'custom',
595 ],
596 ]
597 );
598
599 $this->add_responsive_control(
600 '_mask_position_y',
601 [
602 'label' => __( 'Y Position', 'elementor' ),
603 'type' => Controls_Manager::SLIDER,
604 'size_units' => [ 'px', 'em', '%', 'vw' ],
605 'range' => [
606 'px' => [
607 'min' => -500,
608 'max' => 500,
609 ],
610 'em' => [
611 'min' => -100,
612 'max' => 100,
613 ],
614 '%' => [
615 'min' => -100,
616 'max' => 100,
617 ],
618 'vw' => [
619 'min' => -100,
620 'max' => 100,
621 ],
622 ],
623 'default' => [
624 'unit' => '%',
625 'size' => 0,
626 ],
627 'selectors' => $this->get_mask_selectors( '-webkit-mask-position-y: {{SIZE}}{{UNIT}};' ),
628 'condition' => [
629 '_mask_switch!' => '',
630 '_mask_position' => 'custom',
631 ],
632 ]
633 );
634
635 $this->add_responsive_control(
636 '_mask_repeat',
637 [
638 'label' => __( 'Repeat', 'elementor' ),
639 'type' => Controls_Manager::SELECT,
640 'options' => [
641 'no-repeat' => __( 'No-Repeat', 'elementor' ),
642 'repeat' => __( 'Repeat', 'elementor' ),
643 'repeat-x' => __( 'Repeat-X', 'elementor' ),
644 'repeat-Y' => __( 'Repeat-Y', 'elementor' ),
645 'round' => __( 'Round', 'elementor' ),
646 'space' => __( 'Space', 'elementor' ),
647 ],
648 'default' => 'no-repeat',
649 'selectors' => $this->get_mask_selectors( '-webkit-mask-repeat: {{VALUE}};' ),
650 'condition' => [
651 '_mask_switch!' => '',
652 '_mask_size!' => 'cover',
653 ],
654 ]
655 );
656
657 $this->end_controls_section();
658
659 $this->start_controls_section(
660 '_section_position',
661 [
662 'label' => __( 'Positioning', 'elementor' ),
663 'tab' => Controls_Manager::TAB_ADVANCED,
664 ]
665 );
666
667 $this->add_responsive_control(
668 '_element_width',
669 [
670 'label' => __( 'Width', 'elementor' ),
671 'type' => Controls_Manager::SELECT,
672 'default' => '',
673 'options' => [
674 '' => __( 'Default', 'elementor' ),
675 'inherit' => __( 'Full Width', 'elementor' ) . ' (100%)',
676 'auto' => __( 'Inline', 'elementor' ) . ' (auto)',
677 'initial' => __( 'Custom', 'elementor' ),
678 ],
679 'selectors_dictionary' => [
680 'inherit' => '100%',
681 ],
682 'prefix_class' => 'elementor-widget%s__width-',
683 'selectors' => [
684 '{{WRAPPER}}' => 'width: {{VALUE}}; max-width: {{VALUE}}',
685 ],
686 ]
687 );
688
689 $this->add_responsive_control(
690 '_element_custom_width',
691 [
692 'label' => __( 'Custom Width', 'elementor' ),
693 'type' => Controls_Manager::SLIDER,
694 'range' => [
695 'px' => [
696 'max' => 1000,
697 'step' => 1,
698 ],
699 '%' => [
700 'max' => 100,
701 'step' => 1,
702 ],
703 ],
704 'condition' => [
705 '_element_width' => 'initial',
706 ],
707 'device_args' => [
708 Controls_Stack::RESPONSIVE_TABLET => [
709 'condition' => [
710 '_element_width_tablet' => [ 'initial' ],
711 ],
712 ],
713 Controls_Stack::RESPONSIVE_MOBILE => [
714 'condition' => [
715 '_element_width_mobile' => [ 'initial' ],
716 ],
717 ],
718 ],
719 'size_units' => [ 'px', '%', 'vw' ],
720 'selectors' => [
721 '{{WRAPPER}}' => 'width: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}}',
722 ],
723 ]
724 );
725
726 $this->add_responsive_control(
727 '_element_vertical_align',
728 [
729 'label' => __( 'Vertical Align', 'elementor' ),
730 'type' => Controls_Manager::CHOOSE,
731 'options' => [
732 'flex-start' => [
733 'title' => __( 'Start', 'elementor' ),
734 'icon' => 'eicon-v-align-top',
735 ],
736 'center' => [
737 'title' => __( 'Center', 'elementor' ),
738 'icon' => 'eicon-v-align-middle',
739 ],
740 'flex-end' => [
741 'title' => __( 'End', 'elementor' ),
742 'icon' => 'eicon-v-align-bottom',
743 ],
744 ],
745 'condition' => [
746 '_element_width!' => '',
747 '_position' => '',
748 ],
749 'selectors' => [
750 '{{WRAPPER}}' => 'align-self: {{VALUE}}',
751 ],
752 ]
753 );
754
755 $this->add_control(
756 '_position_description',
757 [
758 'raw' => '<strong>' . __( 'Please note!', 'elementor' ) . '</strong> ' . __( 'Custom positioning is not considered best practice for responsive web design and should not be used too frequently.', 'elementor' ),
759 'type' => Controls_Manager::RAW_HTML,
760 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
761 'render_type' => 'ui',
762 'condition' => [
763 '_position!' => '',
764 ],
765 ]
766 );
767
768 $this->add_control(
769 '_position',
770 [
771 'label' => __( 'Position', 'elementor' ),
772 'type' => Controls_Manager::SELECT,
773 'default' => '',
774 'options' => [
775 '' => __( 'Default', 'elementor' ),
776 'absolute' => __( 'Absolute', 'elementor' ),
777 'fixed' => __( 'Fixed', 'elementor' ),
778 ],
779 'prefix_class' => 'elementor-',
780 'frontend_available' => true,
781 ]
782 );
783
784 $start = is_rtl() ? __( 'Right', 'elementor' ) : __( 'Left', 'elementor' );
785 $end = ! is_rtl() ? __( 'Right', 'elementor' ) : __( 'Left', 'elementor' );
786
787 $this->add_control(
788 '_offset_orientation_h',
789 [
790 'label' => __( 'Horizontal Orientation', 'elementor' ),
791 'type' => Controls_Manager::CHOOSE,
792 'toggle' => false,
793 'default' => 'start',
794 'options' => [
795 'start' => [
796 'title' => $start,
797 'icon' => 'eicon-h-align-left',
798 ],
799 'end' => [
800 'title' => $end,
801 'icon' => 'eicon-h-align-right',
802 ],
803 ],
804 'classes' => 'elementor-control-start-end',
805 'render_type' => 'ui',
806 'condition' => [
807 '_position!' => '',
808 ],
809 ]
810 );
811
812 $this->add_responsive_control(
813 '_offset_x',
814 [
815 'label' => __( 'Offset', 'elementor' ),
816 'type' => Controls_Manager::SLIDER,
817 'range' => [
818 'px' => [
819 'min' => -1000,
820 'max' => 1000,
821 'step' => 1,
822 ],
823 '%' => [
824 'min' => -200,
825 'max' => 200,
826 ],
827 'vw' => [
828 'min' => -200,
829 'max' => 200,
830 ],
831 'vh' => [
832 'min' => -200,
833 'max' => 200,
834 ],
835 ],
836 'default' => [
837 'size' => '0',
838 ],
839 'size_units' => [ 'px', '%', 'vw', 'vh' ],
840 'selectors' => [
841 'body:not(.rtl) {{WRAPPER}}' => 'left: {{SIZE}}{{UNIT}}',
842 'body.rtl {{WRAPPER}}' => 'right: {{SIZE}}{{UNIT}}',
843 ],
844 'condition' => [
845 '_offset_orientation_h!' => 'end',
846 '_position!' => '',
847 ],
848 ]
849 );
850
851 $this->add_responsive_control(
852 '_offset_x_end',
853 [
854 'label' => __( 'Offset', 'elementor' ),
855 'type' => Controls_Manager::SLIDER,
856 'range' => [
857 'px' => [
858 'min' => -1000,
859 'max' => 1000,
860 'step' => 0.1,
861 ],
862 '%' => [
863 'min' => -200,
864 'max' => 200,
865 ],
866 'vw' => [
867 'min' => -200,
868 'max' => 200,
869 ],
870 'vh' => [
871 'min' => -200,
872 'max' => 200,
873 ],
874 ],
875 'default' => [
876 'size' => '0',
877 ],
878 'size_units' => [ 'px', '%', 'vw', 'vh' ],
879 'selectors' => [
880 'body:not(.rtl) {{WRAPPER}}' => 'right: {{SIZE}}{{UNIT}}',
881 'body.rtl {{WRAPPER}}' => 'left: {{SIZE}}{{UNIT}}',
882 ],
883 'condition' => [
884 '_offset_orientation_h' => 'end',
885 '_position!' => '',
886 ],
887 ]
888 );
889
890 $this->add_control(
891 '_offset_orientation_v',
892 [
893 'label' => __( 'Vertical Orientation', 'elementor' ),
894 'type' => Controls_Manager::CHOOSE,
895 'toggle' => false,
896 'default' => 'start',
897 'options' => [
898 'start' => [
899 'title' => __( 'Top', 'elementor' ),
900 'icon' => 'eicon-v-align-top',
901 ],
902 'end' => [
903 'title' => __( 'Bottom', 'elementor' ),
904 'icon' => 'eicon-v-align-bottom',
905 ],
906 ],
907 'render_type' => 'ui',
908 'condition' => [
909 '_position!' => '',
910 ],
911 ]
912 );
913
914 $this->add_responsive_control(
915 '_offset_y',
916 [
917 'label' => __( 'Offset', 'elementor' ),
918 'type' => Controls_Manager::SLIDER,
919 'range' => [
920 'px' => [
921 'min' => -1000,
922 'max' => 1000,
923 'step' => 1,
924 ],
925 '%' => [
926 'min' => -200,
927 'max' => 200,
928 ],
929 'vh' => [
930 'min' => -200,
931 'max' => 200,
932 ],
933 'vw' => [
934 'min' => -200,
935 'max' => 200,
936 ],
937 ],
938 'size_units' => [ 'px', '%', 'vh', 'vw' ],
939 'default' => [
940 'size' => '0',
941 ],
942 'selectors' => [
943 '{{WRAPPER}}' => 'top: {{SIZE}}{{UNIT}}',
944 ],
945 'condition' => [
946 '_offset_orientation_v!' => 'end',
947 '_position!' => '',
948 ],
949 ]
950 );
951
952 $this->add_responsive_control(
953 '_offset_y_end',
954 [
955 'label' => __( 'Offset', 'elementor' ),
956 'type' => Controls_Manager::SLIDER,
957 'range' => [
958 'px' => [
959 'min' => -1000,
960 'max' => 1000,
961 'step' => 1,
962 ],
963 '%' => [
964 'min' => -200,
965 'max' => 200,
966 ],
967 'vh' => [
968 'min' => -200,
969 'max' => 200,
970 ],
971 'vw' => [
972 'min' => -200,
973 'max' => 200,
974 ],
975 ],
976 'size_units' => [ 'px', '%', 'vh', 'vw' ],
977 'default' => [
978 'size' => '0',
979 ],
980 'selectors' => [
981 '{{WRAPPER}}' => 'bottom: {{SIZE}}{{UNIT}}',
982 ],
983 'condition' => [
984 '_offset_orientation_v' => 'end',
985 '_position!' => '',
986 ],
987 ]
988 );
989
990 $this->end_controls_section();
991
992 $this->start_controls_section(
993 '_section_responsive',
994 [
995 'label' => __( 'Responsive', 'elementor' ),
996 'tab' => Controls_Manager::TAB_ADVANCED,
997 ]
998 );
999
1000 $this->add_control(
1001 'responsive_description',
1002 [
1003 'raw' => __( 'Responsive visibility will take effect only on preview or live page, and not while editing in Elementor.', 'elementor' ),
1004 'type' => Controls_Manager::RAW_HTML,
1005 'content_classes' => 'elementor-descriptor',
1006 ]
1007 );
1008
1009 $this->add_control(
1010 'hide_desktop',
1011 [
1012 'label' => __( 'Hide On Desktop', 'elementor' ),
1013 'type' => Controls_Manager::SWITCHER,
1014 'default' => '',
1015 'prefix_class' => 'elementor-',
1016 'label_on' => 'Hide',
1017 'label_off' => 'Show',
1018 'return_value' => 'hidden-desktop',
1019 ]
1020 );
1021
1022 $this->add_control(
1023 'hide_tablet',
1024 [
1025 'label' => __( 'Hide On Tablet', 'elementor' ),
1026 'type' => Controls_Manager::SWITCHER,
1027 'default' => '',
1028 'prefix_class' => 'elementor-',
1029 'label_on' => 'Hide',
1030 'label_off' => 'Show',
1031 'return_value' => 'hidden-tablet',
1032 ]
1033 );
1034
1035 $this->add_control(
1036 'hide_mobile',
1037 [
1038 'label' => __( 'Hide On Mobile', 'elementor' ),
1039 'type' => Controls_Manager::SWITCHER,
1040 'default' => '',
1041 'prefix_class' => 'elementor-',
1042 'label_on' => 'Hide',
1043 'label_off' => 'Show',
1044 'return_value' => 'hidden-phone',
1045 ]
1046 );
1047
1048 $this->end_controls_section();
1049
1050 Plugin::$instance->controls_manager->add_custom_attributes_controls( $this );
1051
1052 Plugin::$instance->controls_manager->add_custom_css_controls( $this );
1053 }
1054 }
1055