PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.5.3
Easy Elements for Elementor – Addons & Website Templates v1.5.3
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / counter / counter.php

counter.php in Easy Elements for Elementor – Addons & Website Templates 1.5.3, at widgets/counter/counter.php

893 lines 24.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Controls_Manager;
4 use Elementor\Group_Control_Typography;
5 use Elementor\Group_Control_Text_Stroke;
6
7 defined('ABSPATH') || die();
8
9 class Easyel_Counter_Widget extends \Elementor\Widget_Base {
10
11
12 public function get_name() {
13 return 'eel-counter';
14 }
15
16 public function get_title() {
17 return __( 'Counter Up', 'easy-elements' );
18 }
19
20 public function get_icon() {
21 return 'easyicon easyelIcon-counter';
22 }
23
24 public function get_categories() {
25 return [ 'easyelements_category' ];
26 }
27
28 public function get_keywords() {
29 return [ 'counter', 'funfact', 'counterup', 'count', 'text' ];
30 }
31
32 public function get_style_depends() {
33 return [
34 'eel-counter',
35 ];
36 }
37
38 public function get_script_depends() {
39 return [
40 'eel-counter',
41 ];
42 }
43
44 protected function register_controls()
45 {
46 $this->start_controls_section(
47 'section_counter',
48 [
49 'label' => esc_html__('Counter', 'easy-elements'),
50 ]
51 );
52
53 $this->add_control(
54 'number',
55 [
56 'label' => esc_html__('Ending Number', 'easy-elements'),
57 'type' => Controls_Manager::NUMBER,
58 'default' => 500,
59 'dynamic' => [
60 'active' => true,
61 ],
62 ]
63 );
64
65 $this->add_control(
66 'start_number',
67 [
68 'label' => esc_html__('Starting Number', 'easy-elements'),
69 'type' => Controls_Manager::NUMBER,
70 'default' => 0,
71 'dynamic' => [
72 'active' => true,
73 ],
74 ]
75 );
76
77 $this->add_control(
78 'prefix',
79 [
80 'label' => esc_html__('Number Prefix', 'easy-elements'),
81 'type' => Controls_Manager::TEXT,
82 'default' => '',
83 'dynamic' => [
84 'active' => true,
85 ],
86 ]
87 );
88
89 $this->add_control(
90 'suffix',
91 [
92 'label' => esc_html__('Number Suffix', 'easy-elements'),
93 'type' => Controls_Manager::TEXT,
94 'default' => '',
95 'dynamic' => [
96 'active' => true,
97 ],
98 ]
99 );
100
101 $this->add_control(
102 'duration',
103 [
104 'label' => esc_html__('Animation Duration (ms)', 'easy-elements'),
105 'type' => Controls_Manager::NUMBER,
106 'default' => 1000,
107 'placeholder' => 'Suffix',
108 ]
109 );
110
111 $this->add_control(
112 'format',
113 [
114 'label' => __('Separator', 'easy-elements'),
115 'type' => \Elementor\Controls_Manager::SELECT,
116 'default' => 'default',
117 'options' => [
118 'default' => __('Default', 'easy-elements'),
119 'comma' => __('Comma', 'easy-elements'),
120 'dot' => __('Dot', 'easy-elements'),
121 'space' => __('Space', 'easy-elements'),
122 'underline' => __('Underline', 'easy-elements'),
123 ],
124 ]
125 );
126
127 $this->add_control(
128 'animation_type',
129 [
130 'label' => esc_html__('Animation Style', 'easy-elements'),
131 'type' => \Elementor\Controls_Manager::SELECT,
132 'default' => 'counter',
133 'options' => [
134 'counter' => esc_html__('Counter', 'easy-elements'),
135 'odometer' => esc_html__('Odometer', 'easy-elements'),
136 ],
137 'description' => esc_html__('Counter: smooth count up. Odometer: rolling digits like a car odometer.', 'easy-elements'),
138 ]
139 );
140
141 $this->add_control(
142 'cnt-icon-enable',
143 [
144 'label' => esc_html__( 'Icon Show', 'easy-elements' ),
145 'type' => Controls_Manager::SWITCHER,
146 'label_on' => esc_html__( 'Yes', 'easy-elements' ),
147 'label_off' => esc_html__( 'No', 'easy-elements' ),
148 'return_value' => 'yes',
149 'default' => 'no',
150 ]
151 );
152
153 $this->add_control(
154 'cnt-icon',
155 [
156 'label' => esc_html__( 'Icon', 'easy-elements' ),
157 'type' => \Elementor\Controls_Manager::ICONS,
158 'default' => [
159 'value' => 'fas fa-layer-group',
160 'library' => 'fa-solid',
161 ],
162 'condition' => [
163 'cnt-icon-enable' => 'yes',
164 ]
165 ]
166 );
167
168 $this->add_control(
169 'title',
170 [
171 'label' => esc_html__('Title', 'easy-elements'),
172 'type' => Controls_Manager::TEXT,
173 'placeholder' => esc_html__('Label', 'easy-elements'),
174 'default' => esc_html__('Easy Elements', 'easy-elements'),
175 'label_block' => true,
176 'dynamic' => [
177 'active' => true,
178 ],
179 ]
180 );
181
182 $this->add_control(
183 'title_tag',
184 [
185 'label' => esc_html__('Select Title Tag', 'easy-elements'),
186 'type' => Controls_Manager::SELECT,
187 'default' => 'span',
188 'options' => [
189 'h1' => esc_html__('H1', 'easy-elements'),
190 'h2' => esc_html__('H2', 'easy-elements'),
191 'h3' => esc_html__('H3', 'easy-elements'),
192 'h4' => esc_html__('H4', 'easy-elements'),
193 'h5' => esc_html__('H5', 'easy-elements'),
194 'h6' => esc_html__('H6', 'easy-elements'),
195 'p' => esc_html__('P', 'easy-elements'),
196 'div' => esc_html__('div', 'easy-elements'),
197 'span' => esc_html__('span', 'easy-elements'),
198 ],
199 ]
200 );
201 $this->end_controls_section();
202
203 $this->start_controls_section(
204 'counter_styles',
205 [
206 'label' => esc_html__('Counter', 'easy-elements'),
207 'tab' => Controls_Manager::TAB_STYLE,
208 ]
209 );
210
211 $this->add_control(
212 'title_position',
213 [
214 'label' => esc_html__( 'Title Position', 'easy-elements' ),
215 'type' => \Elementor\Controls_Manager::CHOOSE,
216 'options' => [
217 'top' => [
218 'title' => esc_html__( 'Top', 'easy-elements' ),
219 'icon' => 'eicon-v-align-top',
220 ],
221 'bottom' => [
222 'title' => esc_html__( 'Bottom', 'easy-elements' ),
223 'icon' => 'eicon-v-align-bottom',
224 ],
225 'left' => [
226 'title' => esc_html__( 'Left', 'easy-elements' ),
227 'icon' => 'eicon-h-align-left',
228 ],
229 'right' => [
230 'title' => esc_html__( 'Right', 'easy-elements' ),
231 'icon' => 'eicon-h-align-right',
232 ],
233 ],
234 'default' => 'bottom',
235 'toggle' => false,
236 'prefix_class' => 'eel-cnt-title-pos-',
237 'condition' => [
238 'title!' => '',
239 ],
240 ]
241 );
242
243 $this->add_responsive_control(
244 'content_gap',
245 [
246 'label' => esc_html__( 'Content Gap', 'easy-elements' ),
247 'type' => \Elementor\Controls_Manager::SLIDER,
248 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
249 'selectors' => [
250 '{{WRAPPER}} .eel-cnt-content' => 'gap: {{SIZE}}{{UNIT}};',
251 '{{WRAPPER}} .eel-cnt-title' => 'margin-top: 0;',
252 ],
253 ]
254 );
255
256 $this->add_responsive_control(
257 'content_vertical_align',
258 [
259 'label' => esc_html__( 'Vertical Alignment', 'easy-elements' ),
260 'type' => \Elementor\Controls_Manager::CHOOSE,
261 'options' => [
262 'flex-start' => [
263 'title' => esc_html__( 'Top', 'easy-elements' ),
264 'icon' => 'eicon-v-align-top',
265 ],
266 'center' => [
267 'title' => esc_html__( 'Middle', 'easy-elements' ),
268 'icon' => 'eicon-v-align-middle',
269 ],
270 'flex-end' => [
271 'title' => esc_html__( 'Bottom', 'easy-elements' ),
272 'icon' => 'eicon-v-align-bottom',
273 ],
274 ],
275 'toggle' => true,
276 'selectors' => [
277 '{{WRAPPER}} .eel-cnt-content' => 'align-items: {{VALUE}};',
278 ],
279 'condition' => [
280 'title_position' => [ 'left', 'right' ],
281 'title!' => '',
282 ],
283 ]
284 );
285
286 $this->add_responsive_control(
287 'sub_pre_gap',
288 [
289 'label' => esc_html__( 'Prefix Suffix Gap', 'easy-elements' ),
290 'type' => \Elementor\Controls_Manager::SLIDER,
291 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
292 'selectors' => [
293 '{{WRAPPER}} .eel-cnt-number-wrap' => 'gap: {{SIZE}}{{UNIT}};',
294 ],
295 'conditions' => [
296 'relation' => 'or',
297 'terms' => [
298 [
299 'name' => 'prefix',
300 'operator' => '!=',
301 'value' => '',
302 ],
303 [
304 'name' => 'suffix',
305 'operator' => '!=',
306 'value' => '',
307 ],
308 ],
309 ],
310 ]
311 );
312
313 $this->add_responsive_control(
314 'wrap_df_hrzn_align',
315 [
316 'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ),
317 'type' => \Elementor\Controls_Manager::CHOOSE,
318 'options' => [
319 'start' => [
320 'title' => esc_html__( 'Start', 'easy-elements' ),
321 'icon' => 'eicon-h-align-left',
322 ],
323 'center' => [
324 'title' => esc_html__( 'Center', 'easy-elements' ),
325 'icon' => 'eicon-h-align-center',
326 ],
327 'end' => [
328 'title' => esc_html__( 'End', 'easy-elements' ),
329 'icon' => 'eicon-h-align-right',
330 ],
331 ],
332 'toggle' => true,
333 'selectors' => [
334 '{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};',
335 '{{WRAPPER}} .eel-cnt-number-wrap' => 'justify-content: {{VALUE}};',
336 ],
337 'condition' => [
338 'cnt-icon-enable!' => 'yes',
339 ]
340 ]
341 );
342
343 $this->add_responsive_control(
344 'icon_position',
345 [
346 'label' => esc_html__( 'Icon Position', 'easy-elements' ),
347 'type' => \Elementor\Controls_Manager::CHOOSE,
348 'separator' => 'before',
349 'default' => 'top',
350 'options' => [
351 'left' => [
352 'title' => esc_html__( 'Left', 'easy-elements' ),
353 'icon' => 'eicon-h-align-left',
354 ],
355 'top' => [
356 'title' => esc_html__( 'Top', 'easy-elements' ),
357 'icon' => 'eicon-v-align-top',
358 ],
359 'bottom' => [
360 'title' => esc_html__( 'Bottom', 'easy-elements' ),
361 'icon' => 'eicon-v-align-bottom',
362 ],
363 'right' => [
364 'title' => esc_html__( 'Right', 'easy-elements' ),
365 'icon' => 'eicon-h-align-right',
366 ],
367 ],
368 'toggle' => true,
369 'prefix_class' => 'eel-cnt-icon-pos-',
370 'condition' => [
371 'cnt-icon-enable' => 'yes',
372 ]
373 ]
374 );
375
376 $this->add_responsive_control(
377 'wrap_vrt_lr_align',
378 [
379 'label' => esc_html__( 'Vertical Alignment', 'easy-elements' ),
380 'type' => \Elementor\Controls_Manager::CHOOSE,
381 'options' => [
382 'start' => [
383 'title' => esc_html__( 'Top', 'easy-elements' ),
384 'icon' => 'eicon-h-align-left',
385 ],
386 'center' => [
387 'title' => esc_html__( 'Middle', 'easy-elements' ),
388 'icon' => 'eicon-h-align-center',
389 ],
390 'end' => [
391 'title' => esc_html__( 'Bottom', 'easy-elements' ),
392 'icon' => 'eicon-h-align-right',
393 ],
394 ],
395 'toggle' => true,
396 'selectors' => [
397 '{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};',
398 ],
399 'condition' => [
400 'icon_position' => [ 'left', 'right' ],
401 'cnt-icon-enable' => 'yes',
402 ],
403 ]
404 );
405
406 $this->add_responsive_control(
407 'wrap_hrzn_tb_alig',
408 [
409 'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ),
410 'type' => \Elementor\Controls_Manager::CHOOSE,
411 'options' => [
412 'start' => [
413 'title' => esc_html__( 'Start', 'easy-elements' ),
414 'icon' => 'eicon-h-align-left',
415 ],
416 'center' => [
417 'title' => esc_html__( 'Center', 'easy-elements' ),
418 'icon' => 'eicon-h-align-center',
419 ],
420 'end' => [
421 'title' => esc_html__( 'End', 'easy-elements' ),
422 'icon' => 'eicon-h-align-right',
423 ],
424 ],
425 'toggle' => true,
426 'selectors' => [
427 '{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};',
428 '{{WRAPPER}} .eel-cnt-number-wrap' => 'justify-content: {{VALUE}};',
429 ],
430 'condition' => [
431 'icon_position' => [ 'top', 'bottom' ],
432 'cnt-icon-enable' => 'yes',
433 ]
434 ]
435 );
436
437 $this->add_responsive_control(
438 'wrap_hrzn_lr_align',
439 [
440 'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ),
441 'type' => \Elementor\Controls_Manager::CHOOSE,
442 'options' => [
443 'start' => [
444 'title' => esc_html__( 'Start', 'easy-elements' ),
445 'icon' => 'eicon-h-align-left',
446 ],
447 'center' => [
448 'title' => esc_html__( 'Center', 'easy-elements' ),
449 'icon' => 'eicon-h-align-center',
450 ],
451 'end' => [
452 'title' => esc_html__( 'End', 'easy-elements' ),
453 'icon' => 'eicon-h-align-right',
454 ],
455 'space-between' => [
456 'title' => esc_html__( 'Stretch', 'easy-elements' ),
457 'icon' => 'eicon-grow',
458 ],
459 ],
460 'toggle' => true,
461 'selectors' => [
462 '{{WRAPPER}} .eel-cnt-wrap' => 'justify-content: {{VALUE}};',
463 ],
464 'condition' => [
465 'icon_position' => [ 'left', 'right' ],
466 'cnt-icon-enable' => 'yes',
467 ],
468 ]
469 );
470
471 $this->add_responsive_control(
472 'icon_gap',
473 [
474 'label' => esc_html__( 'Icon Gap', 'easy-elements' ),
475 'type' => \Elementor\Controls_Manager::SLIDER,
476 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
477 'selectors' => [
478 '{{WRAPPER}} .eel-cnt-wrap' => 'gap: {{SIZE}}{{UNIT}};',
479 ],
480 'condition' => [
481 'cnt-icon-enable' => 'yes',
482 ]
483 ]
484 );
485
486 $this->end_controls_section();
487
488 $this->start_controls_section(
489 'section_number',
490 [
491 'label' => esc_html__('Number', 'easy-elements'),
492 'tab' => Controls_Manager::TAB_STYLE,
493 'condition' => [
494 'number!' => ''
495 ]
496 ]
497 );
498
499 $this->add_control(
500 'number_color',
501 [
502 'label' => esc_html__('Color', 'easy-elements'),
503 'type' => Controls_Manager::COLOR,
504 'selectors' => [
505 '{{WRAPPER}} .eel-cnt-number-wrap' => 'color: {{VALUE}};',
506 ],
507 ]
508 );
509
510 $this->add_group_control(
511 Group_Control_Typography::get_type(),
512 [
513 'label' => esc_html__('Typography', 'easy-elements'),
514 'name' => 'number_typography',
515 'selector' => '{{WRAPPER}} .eel-cnt-number-wrap',
516 ]
517 );
518
519 $this->add_group_control(
520 \Elementor\Group_Control_Text_Stroke::get_type(),
521 [
522 'name' => 'number_stroke',
523 'selector' => '{{WRAPPER}} .eel-cnt-number-wrap',
524 ]
525 );
526
527 $this->add_group_control(
528 \Elementor\Group_Control_Text_Shadow::get_type(),
529 [
530 'name' => 'number_text_shadow',
531 'label' => esc_html__('Text Shadow', 'easy-elements'),
532 'selector' => '{{WRAPPER}} .eel-cnt-number-wrap',
533 ]
534 );
535 $this->end_controls_section();
536
537 $this->start_controls_section(
538 'prefix_styles',
539 [
540 'label' => esc_html__('Prefix', 'easy-elements'),
541 'tab' => Controls_Manager::TAB_STYLE,
542 'condition' => [
543 'prefix!' => '',
544 ]
545 ]
546 );
547 $this->add_control(
548 'prefix_color',
549 [
550 'label' => esc_html__('Color', 'easy-elements'),
551 'type' => Controls_Manager::COLOR,
552 'selectors' => [
553 '{{WRAPPER}} .eel-cnt-prefix' => 'color: {{VALUE}};',
554 ],
555 ]
556 );
557 $this->add_group_control(
558 Group_Control_Typography::get_type(),
559 [
560 'label' => esc_html__('Typography', 'easy-elements'),
561 'name' => 'prefix_typography',
562 'selector' => '{{WRAPPER}} .eel-cnt-prefix',
563 ]
564 );
565
566 $this->add_group_control(
567 \Elementor\Group_Control_Text_Shadow::get_type(),
568 [
569 'name' => 'prefix_text_shadow',
570 'label' => esc_html__('Text Shadow', 'easy-elements'),
571 'selector' => '{{WRAPPER}} .eel-cnt-prefix',
572 ]
573 );
574 $this->end_controls_section();
575
576 $this->start_controls_section(
577 'suffix_styles',
578 [
579 'label' => esc_html__('Suffix', 'easy-elements'),
580 'tab' => Controls_Manager::TAB_STYLE,
581 'condition' => [
582 'suffix!' => '',
583 ]
584 ]
585 );
586
587 $this->add_control(
588 'suffix_color',
589 [
590 'label' => esc_html__('Color', 'easy-elements'),
591 'type' => Controls_Manager::COLOR,
592 'selectors' => [
593 '{{WRAPPER}} .eel-cnt-suffix' => 'color: {{VALUE}};',
594 ],
595 ]
596 );
597
598 $this->add_group_control(
599 Group_Control_Typography::get_type(),
600 [
601 'label' => esc_html__('Typography', 'easy-elements'),
602 'name' => 'suffix_typography',
603 'selector' => '{{WRAPPER}} .eel-cnt-suffix',
604 ]
605 );
606
607 $this->add_group_control(
608 \Elementor\Group_Control_Text_Shadow::get_type(),
609 [
610 'name' => 'suffix_text_shadow',
611 'label' => esc_html__('Text Shadow', 'easy-elements'),
612 'selector' => '{{WRAPPER}} .eel-cnt-suffix',
613 ]
614 );
615 $this->end_controls_section();
616
617 $this->start_controls_section(
618 'title_styles',
619 [
620 'label' => esc_html__('Title', 'easy-elements'),
621 'tab' => Controls_Manager::TAB_STYLE,
622 'condition' => [
623 'title!' => '',
624 ]
625 ]
626 );
627
628 $this->add_control(
629 'title_color',
630 [
631 'label' => esc_html__('Color', 'easy-elements'),
632 'type' => Controls_Manager::COLOR,
633 'selectors' => [
634 '{{WRAPPER}} .eel-cnt-title' => 'color: {{VALUE}};',
635 ],
636 ]
637 );
638
639 $this->add_group_control(
640 Group_Control_Typography::get_type(),
641 [
642 'label' => esc_html__('Typography', 'easy-elements'),
643 'name' => 'title_typography',
644 'selector' => '{{WRAPPER}} .eel-cnt-title',
645 ]
646 );
647
648 $this->add_responsive_control(
649 'title_align',
650 [
651 'label' => esc_html__( 'Text Alignment', 'easy-elements' ),
652 'type' => \Elementor\Controls_Manager::CHOOSE,
653 'options' => [
654 'left' => [
655 'title' => esc_html__( 'Left', 'easy-elements' ),
656 'icon' => 'eicon-text-align-left',
657 ],
658 'center' => [
659 'title' => esc_html__( 'Center', 'easy-elements' ),
660 'icon' => 'eicon-text-align-center',
661 ],
662 'right' => [
663 'title' => esc_html__( 'Right', 'easy-elements' ),
664 'icon' => 'eicon-text-align-right',
665 ],
666 'justify' => [
667 'title' => esc_html__( 'Justified', 'easy-elements' ),
668 'icon' => 'eicon-text-align-justify',
669 ],
670 ],
671 'toggle' => true,
672 'selectors' => [
673 '{{WRAPPER}} .eel-cnt-title' => 'text-align: {{VALUE}};',
674 ],
675 ]
676 );
677
678 $this->add_group_control(
679 \Elementor\Group_Control_Text_Shadow::get_type(),
680 [
681 'name' => 'title_text_shadow',
682 'label' => esc_html__('Text Shadow', 'easy-elements'),
683 'selector' => '{{WRAPPER}} .eel-cnt-title',
684 ]
685 );
686 $this->end_controls_section();
687
688 $this->start_controls_section(
689 'icon_style',
690 [
691 'label' => esc_html__('Icon', 'easy-elements'),
692 'tab' => Controls_Manager::TAB_STYLE,
693 'condition' => [
694 'cnt-icon-enable' => 'yes',
695 ]
696 ]
697 );
698
699 $this->add_control(
700 'icon_color',
701 [
702 'label' => esc_html__('Color', 'easy-elements'),
703 'type' => Controls_Manager::COLOR,
704 'selectors' => [
705 '{{WRAPPER}} .eel-cnt-icon svg' => 'fill: {{VALUE}};',
706 '{{WRAPPER}} .eel-cnt-icon svg path' => 'fill: {{VALUE}};',
707 '{{WRAPPER}} .eel-cnt-icon i' => 'color: {{VALUE}};',
708 ],
709 ]
710 );
711
712 $this->add_control(
713 'icon_bgcolor',
714 [
715 'label' => esc_html__('Background', 'easy-elements'),
716 'type' => Controls_Manager::COLOR,
717 'selectors' => [
718 '{{WRAPPER}} .eel-cnt-icon' => 'background: {{VALUE}};',
719 ],
720 ]
721 );
722
723 $this->add_responsive_control(
724 'icon_box_size',
725 [
726 'label' => esc_html__( 'Size', 'easy-elements' ),
727 'type' => \Elementor\Controls_Manager::SLIDER,
728 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
729 'range' => [
730 'px' => [
731 'min' => 0,
732 'max' => 100,
733 'step' => 0,
734 ],
735 '%' => [
736 'min' => 0,
737 'max' => 100,
738 ],
739 ],
740 'selectors' => [
741 '{{WRAPPER}} .eel-cnt-icon' => 'width: {{SIZE}}{{UNIT}} !important;height: {{SIZE}}{{UNIT}} !important;',
742 ],
743 ]
744 );
745
746 $this->add_responsive_control(
747 'icon_size',
748 [
749 'label' => esc_html__( 'Icon Size', 'easy-elements' ),
750 'type' => \Elementor\Controls_Manager::SLIDER,
751 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
752 'range' => [
753 'px' => [
754 'min' => 0,
755 'max' => 100,
756 'step' => 0,
757 ],
758 '%' => [
759 'min' => 0,
760 'max' => 100,
761 ],
762 ],
763 'selectors' => [
764 '{{WRAPPER}} .eel-cnt-icon svg' => 'width: {{SIZE}}{{UNIT}} !important;height: {{SIZE}}{{UNIT}} !important;',
765 '{{WRAPPER}} .eel-cnt-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
766 ],
767 ]
768 );
769
770 $this->add_responsive_control(
771 'icon_border_radius',
772 [
773 'label' => esc_html__( 'Border Radius', 'easy-elements' ),
774 'type' => \Elementor\Controls_Manager::DIMENSIONS,
775 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
776 'selectors' => [
777 '{{WRAPPER}} .eel-cnt-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
778 ],
779 ]
780 );
781
782 $this->add_responsive_control(
783 'icon_padding',
784 [
785 'label' => esc_html__( 'Padding', 'easy-elements' ),
786 'type' => \Elementor\Controls_Manager::DIMENSIONS,
787 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
788 'selectors' => [
789 '{{WRAPPER}} .eel-cnt-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
790 ],
791 ]
792 );
793
794 $this->add_group_control(
795 \Elementor\Group_Control_Border::get_type(),
796 [
797 'name' => 'icon_border',
798 'selector' => '{{WRAPPER}} .eel-cnt-icon',
799 ]
800 );
801
802 $this->add_group_control(
803 \Elementor\Group_Control_Box_Shadow::get_type(),
804 [
805 'name' => 'icon_box_shadow',
806 'selector' => '{{WRAPPER}} .eel-cnt-icon',
807 ]
808 );
809 $this->end_controls_section();
810 }
811
812 protected function render() {
813 $settings = $this->get_settings_for_display();
814 $number = isset($settings['number']) && $settings['number'] !== '' ? $settings['number'] : 0;
815 $start = isset($settings['start_number']) && $settings['start_number'] !== '' ? $settings['start_number'] : 0;
816 $prefix = !empty($settings['prefix']) ? $settings['prefix'] : '';
817 $suffix = !empty($settings['suffix']) ? $settings['suffix'] : '';
818 $title = !empty($settings['title']) ? $settings['title'] : '';
819 $title_tag = !empty($settings['title_tag']) ? $settings['title_tag'] : 'span';
820
821 $duration = !empty($settings['duration']) ? intval($settings['duration']) : 1000;
822 $format = !empty($settings['format']) ? $settings['format'] : 'default';
823 $animation = !empty($settings['animation_type']) ? $settings['animation_type'] : 'counter';
824 if (!in_array($animation, ['counter', 'odometer'], true)) {
825 $animation = 'counter';
826 }
827
828 $allowed_tags = ['h1','h2','h3','h4','h5','h6','p','div','span'];
829 if (!in_array($title_tag, $allowed_tags, true)) {
830 $title_tag = 'span';
831 }
832
833 $icon_enabled = !empty($settings['cnt-icon-enable']) && $settings['cnt-icon-enable'] === 'yes';
834 $icon = $icon_enabled && !empty($settings['cnt-icon']['value']) ? $settings['cnt-icon'] : false;
835
836 // Add inline editing
837 $this->add_inline_editing_attributes('prefix', 'basic');
838 $this->add_render_attribute('prefix', 'class', 'eel-cnt-prefix');
839
840 $this->add_inline_editing_attributes('suffix', 'basic');
841 $this->add_render_attribute('suffix', 'class', 'eel-cnt-suffix');
842 ?>
843 <div class="eel-cnt-wrap">
844
845 <?php if ($icon) : ?>
846 <div class="eel-cnt-icon">
847 <?php \Elementor\Icons_Manager::render_icon($icon, [ 'aria-hidden' => 'true' ]); ?>
848 </div>
849 <?php endif; ?>
850
851 <div class="eel-cnt-content">
852
853 <?php if ($number !== '') : ?>
854 <div class="eel-cnt-number-wrap">
855
856 <?php if ($prefix !== '') :
857 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe, output contains trusted HTML attributes. ?>
858 <span <?php echo $this->print_render_attribute_string('prefix'); ?>>
859 <?php echo esc_html($prefix); ?>
860 </span>
861 <?php endif; ?>
862
863 <span class="eel-cnt-number eel-counter"
864 data-count="<?php echo esc_attr($number); ?>"
865 data-start="<?php echo esc_attr($start); ?>"
866 data-duration="<?php echo esc_attr($duration); ?>"
867 data-format="<?php echo esc_attr($format); ?>"
868 data-animation="<?php echo esc_attr($animation); ?>">
869 <?php echo esc_html($start); ?>
870 </span>
871
872 <?php if ($suffix !== '') :
873 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe, output contains trusted HTML attributes. ?>
874 <span <?php echo $this->print_render_attribute_string('suffix'); ?>>
875 <?php echo esc_html($suffix); ?>
876 </span>
877 <?php endif; ?>
878
879 </div>
880 <?php endif; ?>
881
882 <?php if ($title !== '') : ?>
883 <<?php echo esc_attr($title_tag); ?> class="eel-cnt-title">
884 <?php echo wp_kses_post($title); ?>
885 </<?php echo esc_attr($title_tag); ?>>
886 <?php endif; ?>
887
888 </div>
889 </div>
890 <?php
891 }
892 }
893