PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.0-dev2
Elementor Website Builder – more than just a page builder v3.20.0-dev2
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.20.0-dev2, at includes/controls/groups/background.php

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