PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.0
Elementor Website Builder – more than just a page builder v3.4.0
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.4.0, at includes/widgets/common.php

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