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

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