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

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