PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
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 / controls / groups / background.php

background.php in Elementor Website Builder – more than just a page builder 3.23.0-dev3, at includes/controls/groups/background.php

856 lines 22.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 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 use Elementor\Modules\DynamicTags\Module as TagsModule;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Elementor background control.
13 *
14 * A base control for creating background control. Displays input fields to define
15 * the background color, background image, background gradient or background video.
16 *
17 * @since 1.2.2
18 */
19 class Group_Control_Background extends Group_Control_Base {
20
21 /**
22 * Fields.
23 *
24 * Holds all the background control fields.
25 *
26 * @since 1.2.2
27 * @access protected
28 * @static
29 *
30 * @var array Background control fields.
31 */
32 protected static $fields;
33
34 /**
35 * Background Types.
36 *
37 * Holds all the available background types.
38 *
39 * @since 1.2.2
40 * @access private
41 * @static
42 *
43 * @var array
44 */
45 private static $background_types;
46
47 /**
48 * Get background control type.
49 *
50 * Retrieve the control type, in this case `background`.
51 *
52 * @since 1.0.0
53 * @access public
54 * @static
55 *
56 * @return string Control type.
57 */
58 public static function get_type() {
59 return 'background';
60 }
61
62 /**
63 * Get background control types.
64 *
65 * Retrieve available background types.
66 *
67 * @since 1.2.2
68 * @access public
69 * @static
70 *
71 * @return array Available background types.
72 */
73 public static function get_background_types() {
74 if ( null === self::$background_types ) {
75 self::$background_types = self::get_default_background_types();
76 }
77
78 return self::$background_types;
79 }
80
81 /**
82 * Get Default background types.
83 *
84 * Retrieve background control initial types.
85 *
86 * @since 2.0.0
87 * @access private
88 * @static
89 *
90 * @return array Default background types.
91 */
92 private static function get_default_background_types() {
93 return [
94 'classic' => [
95 'title' => esc_html__( 'Classic', 'elementor' ),
96 'icon' => 'eicon-paint-brush',
97 ],
98 'gradient' => [
99 'title' => esc_html__( 'Gradient', 'elementor' ),
100 'icon' => 'eicon-barcode',
101 ],
102 'video' => [
103 'title' => esc_html__( 'Video', 'elementor' ),
104 'icon' => 'eicon-video-camera',
105 ],
106 'slideshow' => [
107 'title' => esc_html__( 'Slideshow', 'elementor' ),
108 'icon' => 'eicon-slideshow',
109 ],
110 ];
111 }
112
113 /**
114 * Init fields.
115 *
116 * Initialize background control fields.
117 *
118 * @since 1.2.2
119 * @access public
120 *
121 * @return array Control fields.
122 */
123 public function init_fields() {
124 $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
125
126 $location_device_args = [];
127 $location_device_defaults = [
128 'default' => [
129 'unit' => '%',
130 ],
131 ];
132
133 $angel_device_args = [];
134 $angel_device_defaults = [
135 'default' => [
136 'unit' => 'deg',
137 ],
138 ];
139
140 $position_device_args = [];
141 $position_device_defaults = [
142 'default' => 'center center',
143 ];
144
145 foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
146 $location_device_args[ $breakpoint_name ] = $location_device_defaults;
147 $angel_device_args[ $breakpoint_name ] = $angel_device_defaults;
148 $position_device_args[ $breakpoint_name ] = $position_device_defaults;
149 }
150
151 $fields = [];
152
153 $fields['background'] = [
154 'label' => esc_html__( 'Background Type', 'elementor' ),
155 'type' => Controls_Manager::CHOOSE,
156 'render_type' => 'ui',
157 ];
158
159 $fields['gradient_notice'] = [
160 'type' => Controls_Manager::ALERT,
161 'alert_type' => 'warning',
162 'content' => esc_html__( 'Set locations and angle for each breakpoint to ensure the gradient adapts to different screen sizes.', 'elementor' ),
163 'render_type' => 'ui',
164 'condition' => [
165 'background' => [ 'gradient' ],
166 ],
167 ];
168
169 $fields['color'] = [
170 'label' => esc_html__( 'Color', 'elementor' ),
171 'type' => Controls_Manager::COLOR,
172 'default' => '',
173 'title' => esc_html__( 'Background Color', 'elementor' ),
174 'selectors' => [
175 '{{SELECTOR}}' => 'background-color: {{VALUE}};',
176 ],
177 'condition' => [
178 'background' => [ 'classic', 'gradient', 'video' ],
179 ],
180 ];
181
182 $fields['color_stop'] = [
183 'label' => esc_html_x( 'Location', 'Background Control', 'elementor' ),
184 'type' => Controls_Manager::SLIDER,
185 'size_units' => [ '%', 'custom' ],
186 'default' => [
187 'unit' => '%',
188 'size' => 0,
189 ],
190 'device_args' => $location_device_args,
191 'responsive' => true,
192 'render_type' => 'ui',
193 'condition' => [
194 'background' => [ 'gradient' ],
195 ],
196 'of_type' => 'gradient',
197 ];
198
199 $fields['color_b'] = [
200 'label' => esc_html__( 'Second Color', 'elementor' ),
201 'type' => Controls_Manager::COLOR,
202 'default' => '#f2295b',
203 'render_type' => 'ui',
204 'control_type' => 'content',
205 'condition' => [
206 'background' => [ 'gradient' ],
207 ],
208 'of_type' => 'gradient',
209 ];
210
211 $fields['color_b_stop'] = [
212 'label' => esc_html_x( 'Location', 'Background Control', 'elementor' ),
213 'type' => Controls_Manager::SLIDER,
214 'size_units' => [ '%', 'custom' ],
215 'default' => [
216 'unit' => '%',
217 'size' => 100,
218 ],
219 'device_args' => $location_device_args,
220 'responsive' => true,
221 'render_type' => 'ui',
222 'condition' => [
223 'background' => [ 'gradient' ],
224 ],
225 'of_type' => 'gradient',
226 ];
227
228 $fields['gradient_type'] = [
229 'label' => esc_html_x( 'Type', 'Background Control', 'elementor' ),
230 'type' => Controls_Manager::SELECT,
231 'options' => [
232 'linear' => esc_html__( 'Linear', 'elementor' ),
233 'radial' => esc_html__( 'Radial', 'elementor' ),
234 ],
235 'default' => 'linear',
236 'render_type' => 'ui',
237 'condition' => [
238 'background' => [ 'gradient' ],
239 ],
240 'of_type' => 'gradient',
241 ];
242
243 $fields['gradient_angle'] = [
244 'label' => esc_html__( 'Angle', 'elementor' ),
245 'type' => Controls_Manager::SLIDER,
246 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
247 'default' => [
248 'unit' => 'deg',
249 'size' => 180,
250 ],
251 'device_args' => $angel_device_args,
252 'responsive' => true,
253 'selectors' => [
254 '{{SELECTOR}}' => 'background-color: transparent; background-image: linear-gradient({{SIZE}}{{UNIT}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
255 ],
256 'condition' => [
257 'background' => [ 'gradient' ],
258 'gradient_type' => 'linear',
259 ],
260 'of_type' => 'gradient',
261 ];
262
263 $fields['gradient_position'] = [
264 'label' => esc_html__( 'Position', 'elementor' ),
265 'type' => Controls_Manager::SELECT,
266 'options' => [
267 'center center' => esc_html__( 'Center Center', 'elementor' ),
268 'center left' => esc_html__( 'Center Left', 'elementor' ),
269 'center right' => esc_html__( 'Center Right', 'elementor' ),
270 'top center' => esc_html__( 'Top Center', 'elementor' ),
271 'top left' => esc_html__( 'Top Left', 'elementor' ),
272 'top right' => esc_html__( 'Top Right', 'elementor' ),
273 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
274 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
275 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
276 ],
277 'default' => 'center center',
278 'device_args' => $position_device_args,
279 'responsive' => true,
280 'selectors' => [
281 '{{SELECTOR}}' => 'background-color: transparent; background-image: radial-gradient(at {{VALUE}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
282 ],
283 'condition' => [
284 'background' => [ 'gradient' ],
285 'gradient_type' => 'radial',
286 ],
287 'of_type' => 'gradient',
288 ];
289
290 $fields['image'] = [
291 'label' => esc_html__( 'Image', 'elementor' ),
292 'type' => Controls_Manager::MEDIA,
293 'ai' => [
294 'category' => 'background',
295 ],
296 'dynamic' => [
297 'active' => true,
298 ],
299 'responsive' => true,
300 'title' => esc_html__( 'Background Image', 'elementor' ),
301 'selectors' => [
302 '{{SELECTOR}}' => 'background-image: url("{{URL}}");',
303 ],
304 'has_sizes' => true,
305 'render_type' => 'template',
306 'condition' => [
307 'background' => [ 'classic' ],
308 ],
309 ];
310
311 $fields['position'] = [
312 'label' => esc_html__( 'Position', 'elementor' ),
313 'type' => Controls_Manager::SELECT,
314 'default' => '',
315 'separator' => 'before',
316 'responsive' => true,
317 'options' => [
318 '' => esc_html__( 'Default', 'elementor' ),
319 'center center' => esc_html__( 'Center Center', 'elementor' ),
320 'center left' => esc_html__( 'Center Left', 'elementor' ),
321 'center right' => esc_html__( 'Center Right', 'elementor' ),
322 'top center' => esc_html__( 'Top Center', 'elementor' ),
323 'top left' => esc_html__( 'Top Left', 'elementor' ),
324 'top right' => esc_html__( 'Top Right', 'elementor' ),
325 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
326 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
327 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
328 'initial' => esc_html__( 'Custom', 'elementor' ),
329
330 ],
331 'selectors' => [
332 '{{SELECTOR}}' => 'background-position: {{VALUE}};',
333 ],
334 'condition' => [
335 'background' => [ 'classic' ],
336 'image[url]!' => '',
337 ],
338 ];
339
340 $fields['xpos'] = [
341 'label' => esc_html__( 'X Position', 'elementor' ),
342 'type' => Controls_Manager::SLIDER,
343 'responsive' => true,
344 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
345 'default' => [
346 'size' => 0,
347 ],
348 'tablet_default' => [
349 'size' => 0,
350 ],
351 'mobile_default' => [
352 'size' => 0,
353 ],
354 'range' => [
355 'px' => [
356 'min' => -800,
357 'max' => 800,
358 ],
359 'em' => [
360 'min' => -100,
361 'max' => 100,
362 ],
363 '%' => [
364 'min' => -100,
365 'max' => 100,
366 ],
367 'vw' => [
368 'min' => -100,
369 'max' => 100,
370 ],
371 ],
372 'selectors' => [
373 '{{SELECTOR}}' => 'background-position: {{SIZE}}{{UNIT}} {{ypos.SIZE}}{{ypos.UNIT}}',
374 ],
375 'condition' => [
376 'background' => [ 'classic' ],
377 'position' => [ 'initial' ],
378 'image[url]!' => '',
379 ],
380 'required' => true,
381 ];
382
383 $fields['ypos'] = [
384 'label' => esc_html__( 'Y Position', 'elementor' ),
385 'type' => Controls_Manager::SLIDER,
386 'responsive' => true,
387 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
388 'default' => [
389 'size' => 0,
390 ],
391 'tablet_default' => [
392 'size' => 0,
393 ],
394 'mobile_default' => [
395 'size' => 0,
396 ],
397 'range' => [
398 'px' => [
399 'min' => -800,
400 'max' => 800,
401 ],
402 'em' => [
403 'min' => -100,
404 'max' => 100,
405 ],
406 '%' => [
407 'min' => -100,
408 'max' => 100,
409 ],
410 'vh' => [
411 'min' => -100,
412 'max' => 100,
413 ],
414 ],
415 'selectors' => [
416 '{{SELECTOR}}' => 'background-position: {{xpos.SIZE}}{{xpos.UNIT}} {{SIZE}}{{UNIT}}',
417 ],
418 'condition' => [
419 'background' => [ 'classic' ],
420 'position' => [ 'initial' ],
421 'image[url]!' => '',
422 ],
423 'required' => true,
424 ];
425
426 $fields['attachment'] = [
427 'label' => esc_html_x( 'Attachment', 'Background Control', 'elementor' ),
428 'type' => Controls_Manager::SELECT,
429 'default' => '',
430 'options' => [
431 '' => esc_html__( 'Default', 'elementor' ),
432 'scroll' => esc_html_x( 'Scroll', 'Background Control', 'elementor' ),
433 'fixed' => esc_html_x( 'Fixed', 'Background Control', 'elementor' ),
434 ],
435 'selectors' => [
436 '(desktop+){{SELECTOR}}' => 'background-attachment: {{VALUE}};',
437 ],
438 'condition' => [
439 'background' => [ 'classic' ],
440 'image[url]!' => '',
441 ],
442 ];
443
444 $fields['attachment_alert'] = [
445 'type' => Controls_Manager::RAW_HTML,
446 'content_classes' => 'elementor-control-field-description',
447 'raw' => esc_html__( 'Note: Attachment Fixed works only on desktop.', 'elementor' ),
448 'condition' => [
449 'background' => [ 'classic' ],
450 'image[url]!' => '',
451 'attachment' => 'fixed',
452 ],
453 ];
454
455 $fields['repeat'] = [
456 'label' => esc_html_x( 'Repeat', 'Background Control', 'elementor' ),
457 'type' => Controls_Manager::SELECT,
458 'default' => '',
459 'responsive' => true,
460 'options' => [
461 '' => esc_html__( 'Default', 'elementor' ),
462 'no-repeat' => esc_html__( 'No-repeat', 'elementor' ),
463 'repeat' => esc_html__( 'Repeat', 'elementor' ),
464 'repeat-x' => esc_html__( 'Repeat-x', 'elementor' ),
465 'repeat-y' => esc_html__( 'Repeat-y', 'elementor' ),
466 ],
467 'selectors' => [
468 '{{SELECTOR}}' => 'background-repeat: {{VALUE}};',
469 ],
470 'condition' => [
471 'background' => [ 'classic' ],
472 'image[url]!' => '',
473 ],
474 ];
475
476 $fields['size'] = [
477 'label' => esc_html__( 'Display Size', 'elementor' ),
478 'type' => Controls_Manager::SELECT,
479 'responsive' => true,
480 'default' => '',
481 'options' => [
482 '' => esc_html__( 'Default', 'elementor' ),
483 'auto' => esc_html__( 'Auto', 'elementor' ),
484 'cover' => esc_html__( 'Cover', 'elementor' ),
485 'contain' => esc_html__( 'Contain', 'elementor' ),
486 'initial' => esc_html__( 'Custom', 'elementor' ),
487 ],
488 'selectors' => [
489 '{{SELECTOR}}' => 'background-size: {{VALUE}};',
490 ],
491 'condition' => [
492 'background' => [ 'classic' ],
493 'image[url]!' => '',
494 ],
495 ];
496
497 $fields['bg_width'] = [
498 'label' => esc_html__( 'Width', 'elementor' ),
499 'type' => Controls_Manager::SLIDER,
500 'responsive' => true,
501 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
502 'range' => [
503 'px' => [
504 'max' => 1000,
505 ],
506 ],
507 'default' => [
508 'size' => 100,
509 'unit' => '%',
510 ],
511 'required' => true,
512 'selectors' => [
513 '{{SELECTOR}}' => 'background-size: {{SIZE}}{{UNIT}} auto',
514
515 ],
516 'condition' => [
517 'background' => [ 'classic' ],
518 'size' => [ 'initial' ],
519 'image[url]!' => '',
520 ],
521 ];
522
523 $fields['video_link'] = [
524 'label' => esc_html__( 'Video Link', 'elementor' ),
525 'type' => Controls_Manager::TEXT,
526 'placeholder' => 'https://www.youtube.com/watch?v=XHOmBV4js_E',
527 'description' => esc_html__( 'YouTube/Vimeo link, or link to video file (mp4 is recommended).', 'elementor' ),
528 'label_block' => true,
529 'default' => '',
530 'dynamic' => [
531 'active' => true,
532 'categories' => [
533 TagsModule::POST_META_CATEGORY,
534 TagsModule::URL_CATEGORY,
535 ],
536 ],
537 'ai' => [
538 'active' => false,
539 ],
540 'condition' => [
541 'background' => [ 'video' ],
542 ],
543 'of_type' => 'video',
544 'frontend_available' => true,
545 ];
546
547 $fields['video_start'] = [
548 'label' => esc_html__( 'Start Time', 'elementor' ),
549 'type' => Controls_Manager::NUMBER,
550 'description' => esc_html__( 'Specify a start time (in seconds)', 'elementor' ),
551 'placeholder' => 10,
552 'condition' => [
553 'background' => [ 'video' ],
554 ],
555 'of_type' => 'video',
556 'frontend_available' => true,
557 ];
558
559 $fields['video_end'] = [
560 'label' => esc_html__( 'End Time', 'elementor' ),
561 'type' => Controls_Manager::NUMBER,
562 'description' => esc_html__( 'Specify an end time (in seconds)', 'elementor' ),
563 'placeholder' => 70,
564 'condition' => [
565 'background' => [ 'video' ],
566 ],
567 'of_type' => 'video',
568 'frontend_available' => true,
569 ];
570
571 $fields['play_once'] = [
572 'label' => esc_html__( 'Play Once', 'elementor' ),
573 'type' => Controls_Manager::SWITCHER,
574 'condition' => [
575 'background' => [ 'video' ],
576 ],
577 'of_type' => 'video',
578 'frontend_available' => true,
579 ];
580
581 $fields['play_on_mobile'] = [
582 'label' => esc_html__( 'Play On Mobile', 'elementor' ),
583 'type' => Controls_Manager::SWITCHER,
584 'condition' => [
585 'background' => [ 'video' ],
586 ],
587 'of_type' => 'video',
588 'frontend_available' => true,
589 ];
590
591 // This control was added to handle a bug with the Youtube Embed API. The bug: If there is a video with Privacy
592 // Mode on, and at the same time the page contains another video WITHOUT privacy mode on, one of the videos
593 // will not run properly. This added control allows users to align all their videos to one host (either
594 // youtube.com or youtube-nocookie.com, depending on whether the user wants privacy mode on or not).
595 $fields['privacy_mode'] = [
596 'label' => esc_html__( 'Privacy Mode', 'elementor' ),
597 'type' => Controls_Manager::SWITCHER,
598 'condition' => [
599 'background' => [ 'video' ],
600 ],
601 'of_type' => 'video',
602 'frontend_available' => true,
603 ];
604
605 $fields['video_fallback'] = [
606 'label' => esc_html__( 'Background Fallback', 'elementor' ),
607 'description' => esc_html__( 'This cover image will replace the background video in case that the video could not be loaded.', 'elementor' ),
608 'type' => Controls_Manager::MEDIA,
609 'dynamic' => [
610 'active' => true,
611 ],
612 'condition' => [
613 'background' => [ 'video' ],
614 ],
615 'selectors' => [
616 '{{SELECTOR}}' => 'background: url("{{URL}}") 50% 50%; background-size: cover;',
617 ],
618 'of_type' => 'video',
619 ];
620
621 $fields['slideshow_gallery'] = [
622 'label' => esc_html__( 'Images', 'elementor' ),
623 'type' => Controls_Manager::GALLERY,
624 'condition' => [
625 'background' => [ 'slideshow' ],
626 ],
627 'show_label' => false,
628 'of_type' => 'slideshow',
629 'frontend_available' => true,
630 ];
631
632 $fields['slideshow_loop'] = [
633 'label' => esc_html__( 'Infinite Loop', 'elementor' ),
634 'type' => Controls_Manager::SWITCHER,
635 'default' => 'yes',
636 'condition' => [
637 'background' => [ 'slideshow' ],
638 ],
639 'of_type' => 'slideshow',
640 'frontend_available' => true,
641 ];
642
643 $fields['slideshow_slide_duration'] = [
644 'label' => esc_html__( 'Duration', 'elementor' ) . ' (ms)',
645 'type' => Controls_Manager::NUMBER,
646 'default' => 5000,
647 'condition' => [
648 'background' => [ 'slideshow' ],
649 ],
650 'frontend_available' => true,
651 ];
652
653 $fields['slideshow_slide_transition'] = [
654 'label' => esc_html__( 'Transition', 'elementor' ),
655 'type' => Controls_Manager::SELECT,
656 'default' => 'fade',
657 'options' => [
658 'fade' => 'Fade',
659 'slide_right' => 'Slide Right',
660 'slide_left' => 'Slide Left',
661 'slide_up' => 'Slide Up',
662 'slide_down' => 'Slide Down',
663 ],
664 'condition' => [
665 'background' => [ 'slideshow' ],
666 ],
667 'of_type' => 'slideshow',
668 'frontend_available' => true,
669 ];
670
671 $fields['slideshow_transition_duration'] = [
672 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (ms)',
673 'type' => Controls_Manager::NUMBER,
674 'default' => 500,
675 'condition' => [
676 'background' => [ 'slideshow' ],
677 ],
678 'frontend_available' => true,
679 ];
680
681 $fields['slideshow_background_size'] = [
682 'label' => esc_html__( 'Background Size', 'elementor' ),
683 'type' => Controls_Manager::SELECT,
684 'responsive' => true,
685 'default' => '',
686 'options' => [
687 '' => esc_html__( 'Default', 'elementor' ),
688 'auto' => esc_html__( 'Auto', 'elementor' ),
689 'cover' => esc_html__( 'Cover', 'elementor' ),
690 'contain' => esc_html__( 'Contain', 'elementor' ),
691 ],
692 'selectors' => [
693 '{{WRAPPER}} .elementor-background-slideshow__slide__image' => 'background-size: {{VALUE}};',
694 ],
695 'condition' => [
696 'background' => [ 'slideshow' ],
697 ],
698 ];
699
700 $fields['slideshow_background_position'] = [
701 'label' => esc_html__( 'Background Position', 'elementor' ),
702 'type' => Controls_Manager::SELECT,
703 'default' => '',
704 'responsive' => true,
705 'options' => [
706 '' => esc_html__( 'Default', 'elementor' ),
707 'center center' => esc_html__( 'Center Center', 'elementor' ),
708 'center left' => esc_html__( 'Center Left', 'elementor' ),
709 'center right' => esc_html__( 'Center Right', 'elementor' ),
710 'top center' => esc_html__( 'Top Center', 'elementor' ),
711 'top left' => esc_html__( 'Top Left', 'elementor' ),
712 'top right' => esc_html__( 'Top Right', 'elementor' ),
713 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
714 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
715 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
716 ],
717 'selectors' => [
718 '{{WRAPPER}} .elementor-background-slideshow__slide__image' => 'background-position: {{VALUE}};',
719 ],
720 'condition' => [
721 'background' => [ 'slideshow' ],
722 ],
723 ];
724
725 $fields['slideshow_lazyload'] = [
726 'label' => esc_html__( 'Lazyload', 'elementor' ),
727 'type' => Controls_Manager::SWITCHER,
728 'separator' => 'before',
729 'condition' => [
730 'background' => [ 'slideshow' ],
731 ],
732 'of_type' => 'slideshow',
733 'frontend_available' => true,
734 ];
735
736 $fields['slideshow_ken_burns'] = [
737 'label' => esc_html__( 'Ken Burns Effect', 'elementor' ),
738 'type' => Controls_Manager::SWITCHER,
739 'separator' => 'before',
740 'condition' => [
741 'background' => [ 'slideshow' ],
742 ],
743 'of_type' => 'slideshow',
744 'frontend_available' => true,
745 ];
746
747 $fields['slideshow_ken_burns_zoom_direction'] = [
748 'label' => esc_html__( 'Direction', 'elementor' ),
749 'type' => Controls_Manager::SELECT,
750 'default' => 'in',
751 'options' => [
752 'in' => esc_html__( 'In', 'elementor' ),
753 'out' => esc_html__( 'Out', 'elementor' ),
754 ],
755 'condition' => [
756 'background' => [ 'slideshow' ],
757 'slideshow_ken_burns!' => '',
758 ],
759 'of_type' => 'slideshow',
760 'frontend_available' => true,
761 ];
762
763 return $fields;
764 }
765
766 /**
767 * Get child default args.
768 *
769 * Retrieve the default arguments for all the child controls for a specific group
770 * control.
771 *
772 * @since 1.2.2
773 * @access protected
774 *
775 * @return array Default arguments for all the child controls.
776 */
777 protected function get_child_default_args() {
778 return [
779 'types' => [ 'classic', 'gradient' ],
780 'selector' => '{{WRAPPER}}:not(.elementor-motion-effects-element-type-background), {{WRAPPER}} > .elementor-motion-effects-container > .elementor-motion-effects-layer',
781 ];
782 }
783
784 /**
785 * Filter fields.
786 *
787 * Filter which controls to display, using `include`, `exclude`, `condition`
788 * and `of_type` arguments.
789 *
790 * @since 1.2.2
791 * @access protected
792 *
793 * @return array Control fields.
794 */
795 protected function filter_fields() {
796 $fields = parent::filter_fields();
797
798 $args = $this->get_args();
799
800 foreach ( $fields as &$field ) {
801 if ( isset( $field['of_type'] ) && ! in_array( $field['of_type'], $args['types'] ) ) {
802 unset( $field );
803 }
804 }
805
806 return $fields;
807 }
808
809 /**
810 * Prepare fields.
811 *
812 * Process background control fields before adding them to `add_control()`.
813 *
814 * @since 1.2.2
815 * @access protected
816 *
817 * @param array $fields Background control fields.
818 *
819 * @return array Processed fields.
820 */
821 protected function prepare_fields( $fields ) {
822 $args = $this->get_args();
823
824 $background_types = self::get_background_types();
825
826 $choose_types = [];
827
828 foreach ( $args['types'] as $type ) {
829 if ( isset( $background_types[ $type ] ) ) {
830 $choose_types[ $type ] = $background_types[ $type ];
831 }
832 }
833
834 $fields['background']['options'] = $choose_types;
835
836 return parent::prepare_fields( $fields );
837 }
838
839 /**
840 * Get default options.
841 *
842 * Retrieve the default options of the background control. Used to return the
843 * default options while initializing the background control.
844 *
845 * @since 1.9.0
846 * @access protected
847 *
848 * @return array Default background control options.
849 */
850 protected function get_default_options() {
851 return [
852 'popover' => false,
853 ];
854 }
855 }
856