PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / lottie / lottie.php
elementskit-lite / widgets / lottie Last commit date
json-handler.php 2 years ago lottie-handler.php 3 years ago lottie.php 2 years ago
lottie.php
394 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Lottie_Handler as Handler;
5 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9
10 class ElementsKit_Widget_Lottie extends Widget_Base {
11 use \ElementsKit_Lite\Widgets\Widget_Notice;
12
13 public $base;
14
15 public function get_script_depends() {
16 return ['lottie', 'lottie-init'];
17 }
18
19 public function get_name() {
20 return Handler::get_name();
21 }
22
23 public function get_title() {
24 return Handler::get_title();
25 }
26
27 public function get_icon() {
28 return Handler::get_icon();
29 }
30
31 public function get_categories() {
32 return Handler::get_categories();
33 }
34
35 public function get_keywords() {
36 return Handler::get_keywords();
37 }
38
39 public function get_help_url() {
40 return 'https://wpmet.com/doc/lottie-animation/';
41 }
42 protected function is_dynamic_content(): bool {
43 return false;
44 }
45
46 protected function register_controls() {
47 $this->start_controls_section(
48 'ekit_lottie',
49 [
50 'label' => esc_html__( 'Lottie', 'elementskit-lite' ),
51 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
52 ]
53 );
54 $this->add_control(
55 'ekit_lottie_type',
56 [
57 'label' => esc_html__( 'Select JSON', 'elementskit-lite' ),
58 'type' => \Elementor\Controls_Manager::CHOOSE,
59 'default' => 'file',
60 'options' => [
61 'file' => [
62 'title' => esc_html__( 'JSON File', 'elementskit-lite' ),
63 'icon' => 'eicon-folder-o',
64 ],
65 'url' => [
66 'title' => esc_html__( 'JSON URL', 'elementskit-lite' ),
67 'icon' => 'eicon-link',
68 ],
69 ]
70 ]
71 );
72
73 $this->add_control(
74 'ekit_lottie_json',
75 [
76 'show_label' => false,
77 'description' => sprintf('%1$s <a href="https://lottiefiles.com/featured" target="_blank"> %2$s</a> %3$s',
78 esc_html__('Discover thousands of' , 'elementskit-lite'),
79 esc_html__('Lottie animations' , 'elementskit-lite'),
80 esc_html__('ready to use.' , 'elementskit-lite'),
81 ),
82 'type' => \Elementor\Controls_Manager::MEDIA,
83 'media_type' => 'application/json',
84 'condition' => [
85 'ekit_lottie_type' => 'file',
86 ],
87 ]
88 );
89
90 $this->add_control(
91 'ekit_lottie_url',
92 [
93 'show_label' => false,
94 'label_block' => true,
95 'description' => sprintf('%1$s <a href="https://lottiefiles.com/featured" target="_blank"> %2$s</a> %3$s',
96 esc_html__('Discover thousands of' , 'elementskit-lite'),
97 esc_html__('Lottie animations' , 'elementskit-lite'),
98 esc_html__('ready to use.' , 'elementskit-lite'),
99 ),
100 'type' => \Elementor\Controls_Manager::TEXT,
101 'dynamic' => [
102 'active' => true,
103 ],
104 'placeholder' => esc_html( 'https://example.com/file.json'),
105 'show_external' => false,
106 'condition' => [
107 'ekit_lottie_type' => 'url'
108 ],
109 ]
110 );
111
112 $this->add_control(
113 'ekit_lottie_link_check',
114 [
115 'label' => esc_html__( 'Link', 'elementskit-lite' ),
116 'type' => \Elementor\Controls_Manager::SWITCHER,
117 ]
118 );
119
120 $this->add_control(
121 'ekit_lottie_link',
122 [
123 'show_label' => false,
124 'type' => \Elementor\Controls_Manager::URL,
125 'dynamic' => [
126 'active' => true,
127 ],
128 'condition' => [
129 'ekit_lottie_link_check' => 'yes'
130 ],
131 ]
132 );
133
134 $this->add_control(
135 'ekit_lottie_options',
136 [
137 'label' => esc_html__( 'Animation Options', 'elementskit-lite' ),
138 'type' => \Elementor\Controls_Manager::HEADING,
139 'separator' => 'before',
140 ]
141 );
142
143 $this->add_control(
144 'ekit_lottie_reverse',
145 [
146 'label' => esc_html__( 'Reverse', 'elementskit-lite' ),
147 'type' => \Elementor\Controls_Manager::SWITCHER,
148 ]
149 );
150
151 $this->add_control(
152 'ekit_lottie_autoplay',
153 [
154 'label' => esc_html__( 'Autoplay', 'elementskit-lite' ),
155 'type' => \Elementor\Controls_Manager::SWITCHER,
156 'return_value' => 'true',
157 'default' => 'true',
158 ]
159 );
160
161 $this->add_control(
162 'ekit_lottie_on_scroll',
163 [
164 'label' => esc_html__( 'Start when visible', 'elementskit-lite' ),
165 'type' => \Elementor\Controls_Manager::SWITCHER,
166 'condition' => [
167 'ekit_lottie_autoplay' => ''
168 ],
169 ]
170 );
171
172 $this->add_control(
173 'ekit_lottie_loop',
174 [
175 'label' => esc_html__( 'Loop', 'elementskit-lite' ),
176 'type' => \Elementor\Controls_Manager::SWITCHER,
177 'return_value' => 'true',
178 'default' => 'true',
179 ]
180 );
181
182 $this->add_control(
183 'ekit_lottie_loop_count',
184 [
185 'label' => esc_html__( 'Loop Count', 'elementskit-lite' ),
186 'type' => \Elementor\Controls_Manager::SLIDER,
187 'range' => [
188 'px' => [
189 'max' => 10,
190 ]
191 ],
192 'condition' => [
193 'ekit_lottie_loop' => 'true'
194 ],
195 ]
196 );
197
198 $this->add_control(
199 'ekit_lottie_speed',
200 [
201 'label' => esc_html__( 'Speed', 'elementskit-lite' ),
202 'type' => \Elementor\Controls_Manager::SLIDER,
203 'range' => [
204 'px' => [
205 'max' => 10,
206 'step' => 0.2,
207 ]
208 ],
209 'default' => [
210 'size' => 1,
211 ],
212 ]
213 );
214
215 $this->add_control(
216 'ekit_lottie_renderer',
217 [
218 'label' => esc_html__( 'Render Type', 'elementskit-lite' ),
219 'type' => \Elementor\Controls_Manager::CHOOSE,
220 'default' => 'svg',
221 'options' => [
222 'svg' => [
223 'title' => esc_html__( 'SVG', 'elementskit-lite' ),
224 'icon' => 'fa fa-magic',
225 ],
226 'canvas' => [
227 'title' => esc_html__( 'Canvas', 'elementskit-lite' ),
228 'icon' => 'fa fa-chalkboard',
229 ],
230 ],
231 ]
232 );
233
234 $this->add_control(
235 'ekit_lottie_action',
236 [
237 'label' => esc_html__( 'On Hover', 'elementskit-lite' ),
238 'type' => \Elementor\Controls_Manager::SELECT,
239 'options' => [
240 '' => esc_html__( 'None', 'elementskit-lite' ),
241 'play' => esc_html__( 'Play', 'elementskit-lite' ),
242 'pause' => esc_html__( 'Pause', 'elementskit-lite' ),
243 'reverse' => esc_html__( 'Reverse', 'elementskit-lite' ),
244 ],
245 ]
246 );
247 $this->end_controls_section();
248
249 $this->start_controls_section(
250 'ekit_lottie_styles',
251 [
252 'label' => esc_html__( 'Lottie', 'elementskit-lite' ),
253 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
254 ]
255 );
256 $this->start_controls_tabs(
257 'ekit_lottie_state'
258 );
259 $this->start_controls_tab(
260 'ekit_lottie_normal',
261 [
262 'label' => esc_html__( 'Normal', 'elementskit-lite' ),
263 ]
264 );
265 $this->add_control(
266 'ekit_lottie_opacity',
267 [
268 'label' => esc_html__( 'Opacity', 'elementskit-lite' ),
269 'type' => \Elementor\Controls_Manager::SLIDER,
270 'range' => [
271 'px' => [
272 'min' => 0,
273 'max' => 1,
274 'step' => 0.1,
275 ]
276 ],
277 'selectors' => [
278 '{{WRAPPER}}' => 'opacity: {{SIZE}};',
279 ],
280 ]
281 );
282
283 $this->add_group_control(
284 \Elementor\Group_Control_Css_Filter::get_type(),
285 [
286 'name' => 'ekit_lottie_filter',
287 'selector' => '{{WRAPPER}}',
288 ]
289 );
290 $this->end_controls_tab();
291
292 $this->start_controls_tab(
293 'ekit_lottie_hover',
294 [
295 'label' => esc_html__( 'Hover', 'elementskit-lite' ),
296 ]
297 );
298 $this->add_control(
299 'ekit_lottie_opacity_hover',
300 [
301 'label' => esc_html__( 'Opacity', 'elementskit-lite' ),
302 'type' => \Elementor\Controls_Manager::SLIDER,
303 'range' => [
304 'px' => [
305 'min' => 0,
306 'max' => 1,
307 'step' => 0.1,
308 ]
309 ],
310 'selectors' => [
311 '{{WRAPPER}}:hover' => 'opacity: {{SIZE}};',
312 ],
313 ]
314 );
315
316 $this->add_group_control(
317 \Elementor\Group_Control_Css_Filter::get_type(),
318 [
319 'name' => 'ekit_lottie_filter_hover',
320 'selector' => '{{WRAPPER}}',
321 ]
322 );
323
324 $this->add_control(
325 'ekit_lottie_transition',
326 [
327 'label' => esc_html__( 'Transition', 'elementskit-lite' ),
328 'type' => \Elementor\Controls_Manager::SLIDER,
329 'range' => [
330 'px' => [
331 'max' => 10,
332 'step' => 0.1,
333 ],
334 ],
335 'selectors' => [
336 '{{WRAPPER}}' => 'transition: all {{SIZE}}s ease;',
337 ],
338 ]
339 );
340 $this->end_controls_tab();
341 $this->end_controls_tabs();
342 $this->end_controls_section();
343
344 $this->insert_pro_message();
345 }
346
347 protected function render() {
348 echo '<div class="ekit-wid-con" >';
349 $this->render_raw();
350 echo '</div>';
351 }
352
353 protected function render_raw() {
354 $settings = $this->get_settings_for_display();
355
356 $this->add_render_attribute(
357 'wrapper',
358 [
359 'id' => 'ekit_lottie_' . $this->get_id(),
360 'class' => 'ekit_lottie',
361 'data-autoplay' => $settings['ekit_lottie_autoplay'],
362 'data-on-scroll' => $settings['ekit_lottie_on_scroll'],
363 'data-speed' => $settings['ekit_lottie_speed']['size'],
364 'data-direction' => $settings['ekit_lottie_reverse'],
365 'data-action' => $settings['ekit_lottie_action'],
366 'data-renderer' => $settings['ekit_lottie_renderer'],
367 ]
368 );
369
370
371 if ( !empty($settings['ekit_lottie_json']['url']) ):
372 $this->add_render_attribute( 'wrapper', 'data-path', $settings['ekit_lottie_json']['url'] );
373 else:
374 $this->add_render_attribute( 'wrapper', 'data-path', $settings['ekit_lottie_url'] );
375 endif;
376
377 if ( isset($settings['ekit_lottie_loop_count']['size']) && is_numeric($settings['ekit_lottie_loop_count']['size']) ):
378 $this->add_render_attribute( 'wrapper', 'data-loop', max(0, $settings['ekit_lottie_loop_count']['size'] - 1) );
379 else:
380 $this->add_render_attribute( 'wrapper', 'data-loop', $settings['ekit_lottie_loop'] );
381 endif;
382
383
384 if ( !empty($settings['ekit_lottie_link']['url']) && $settings['ekit_lottie_link']['url'] ):
385 $this->add_render_attribute( 'wrapper', 'class', 'met_d--block' );
386 $this->add_link_attributes( 'link', $settings['ekit_lottie_link'] );
387
388 echo '<a '. $this->get_render_attribute_string( 'link' ) .' '. $this->get_render_attribute_string( 'wrapper' ) .'>&nbsp;</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_render_attribute_string Already escaped by elementor
389 else:
390 echo '<div '. $this->get_render_attribute_string( 'wrapper' ) .'>&nbsp;</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_render_attribute_string Already escaped by elementor
391 endif;
392 }
393 }
394