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

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