PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
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 / piechart / piechart.php
elementskit-lite / widgets / piechart Last commit date
piechart-handler.php 3 years ago piechart.php 3 weeks ago
piechart.php
847 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Piechart_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_Piechart extends Widget_Base {
11 use \ElementsKit_Lite\Widgets\Widget_Notice;
12
13 public $base;
14
15 public function __construct( $data = [], $args = null ) {
16 parent::__construct( $data, $args );
17 }
18
19 public function get_script_depends() {
20 return ['ekit-piechart', 'easy-pie-chart'];
21 }
22
23 public function get_style_depends() {
24 return ['ekit-piechart'];
25 }
26
27 public function get_name() {
28 return Handler::get_name();
29 }
30
31 public function get_title() {
32 return Handler::get_title();
33 }
34
35 public function get_icon() {
36 return Handler::get_icon();
37 }
38
39 public function get_categories() {
40 return Handler::get_categories();
41 }
42
43 public function get_keywords() {
44 return Handler::get_keywords();
45 }
46
47 public function get_help_url() {
48 return 'https://wpmet.com/doc/pie-chart/';
49 }
50 protected function is_dynamic_content(): bool {
51 return false;
52 }
53
54 protected function register_controls() {
55
56
57 // Content section
58
59 $this->start_controls_section(
60 'ekit_piechart_content_section',
61 [
62 'label' => esc_html__( 'Content', 'elementskit-lite' ),
63 'tab' => Controls_Manager::TAB_CONTENT,
64 ]
65 );
66
67 $this->add_control(
68 'ekit_piechart_style',
69 [
70 'label' => esc_html__( 'Pie Chart Style', 'elementskit-lite' ),
71 'type' => Controls_Manager::SELECT,
72 'default' => 'simple',
73 'options' => [
74 'simple' => esc_html__( 'Simple', 'elementskit-lite' ),
75 'withcontent' => esc_html__( 'With Content', 'elementskit-lite' ),
76 ],
77 ]
78 );
79
80 $this->add_control(
81 'ekit_piechart_content',
82 [
83 'label' => esc_html__( 'Chart Content', 'elementskit-lite' ),
84 'type' => Controls_Manager::SELECT,
85 'default' => 'ekit_piechart_percentage',
86 'options' => [
87 'ekit_piechart_percentage' => esc_html__( 'Percentage', 'elementskit-lite' ),
88 'icon' => esc_html__( 'Icon', 'elementskit-lite' ),
89 ],
90 ]
91 );
92
93 $this->add_control(
94 'ekit_piechart_percentage',
95 [
96 'label' => esc_html__( 'Percentage', 'elementskit-lite' ),
97 'type' => Controls_Manager::NUMBER,
98 'min' => 0,
99 'max' => 100,
100 'step' => 1,
101 'default' => 40,
102 ]
103 );
104
105 $this->add_control(
106 'ekit_piechart_icon_type',
107 [
108 'label' => esc_html__( 'Icon type', 'elementskit-lite' ),
109 'type' => Controls_Manager::SELECT,
110 'default' => 'icon',
111 'options' => [
112 'icon' => esc_html__( 'Icon', 'elementskit-lite' ),
113 'image' => esc_html__( 'Image', 'elementskit-lite' ),
114 ],
115 'condition' => [
116 'ekit_piechart_content' => 'icon'
117 ]
118 ]
119 );
120
121 $this->add_control(
122 'ekit_piechart_icons',
123 [
124 'label' => esc_html__( 'Icon', 'elementskit-lite' ),
125 'type' => Controls_Manager::ICONS,
126 'fa4compatibility' => 'ekit_piechart_icon',
127 'default' => [
128 'value' => 'icon icon-apartment',
129 'library' => 'ekiticons',
130 ],
131 'condition' => [
132 'ekit_piechart_icon_type' => 'icon',
133 'ekit_piechart_content' => 'icon'
134 ]
135 ]
136 );
137
138 $this->add_control(
139 'ekit_piechart_icon_image',
140 [
141 'label' => esc_html__( 'Choose Image', 'elementskit-lite' ),
142 'type' => Controls_Manager::MEDIA,
143 'dynamic' => [
144 'active' => true,
145 ],
146 'default' => [
147 'url' => Utils::get_placeholder_image_src(),
148 'id' => -1
149 ],
150 'condition' => [
151 'ekit_piechart_icon_type' => 'image',
152 'ekit_piechart_content' => 'icon'
153 ]
154 ]
155 );
156
157 $this->add_group_control(
158 Group_Control_Image_Size::get_type(),
159 [
160 'name' => 'ekit_piechart_icon_image_size_group',
161 'default' => 'thumbnail',
162 'condition' => [
163 'ekit_piechart_icon_type' => 'image',
164 'ekit_piechart_content' => 'icon'
165 ]
166 ]
167 );
168
169 $this->add_control(
170 'ekit_piechart_title',
171 [
172 'label' => esc_html__( 'Title', 'elementskit-lite' ),
173 'type' => Controls_Manager::TEXT,
174 'dynamic' => [
175 'active' => true,
176 ],
177 'default' => esc_html__( 'Default title', 'elementskit-lite' ),
178 'placeholder' => esc_html__( 'Type your title here', 'elementskit-lite' ),
179 'label_block' => true,
180 'condition' => [
181 'ekit_piechart_style' => 'withcontent'
182 ]
183 ]
184 );
185
186 $this->add_control(
187 'ekit_piechart_item_description',
188 [
189 'label' => esc_html__( 'Description', 'elementskit-lite' ),
190 'type' => Controls_Manager::TEXTAREA,
191 'rows' => 10,
192 'dynamic' => [
193 'active' => true,
194 ],
195 'default' => esc_html__( 'Default description', 'elementskit-lite' ),
196 'placeholder' => esc_html__( 'Type your description here', 'elementskit-lite' ),
197 'label_block' => true,
198 'condition' => [
199 'ekit_piechart_style' => 'withcontent'
200 ]
201 ]
202 );
203
204 $this->add_control(
205 'ekit_piechart_content_type',
206 [
207 'label' => esc_html__( 'Content type', 'elementskit-lite' ),
208 'type' => Controls_Manager::SELECT,
209 'default' => 'simple',
210 'options' => [
211 'simple' => esc_html__( 'Static', 'elementskit-lite' ),
212 'flip-card' => esc_html__( 'Flip Card', 'elementskit-lite' ),
213 ],
214 'condition' => [
215 'ekit_piechart_style' => 'withcontent'
216 ]
217 ]
218 );
219
220
221
222 $this->end_controls_section();
223
224 // Style
225
226 $this->start_controls_section(
227 'ekit_piechart_section_content',
228 [
229 'label' => esc_html__( 'Title ', 'elementskit-lite' ),
230 'tab' => controls_Manager::TAB_STYLE,
231 'condition' => [
232 'ekit_piechart_style' => 'withcontent'
233 ]
234 ]
235 );
236
237 $this->add_control(
238 'ekit_piechart_title_color',
239 [
240 'label' => esc_html__( 'Title Color', 'elementskit-lite' ),
241 'type' => Controls_Manager::COLOR,
242 'selectors' => [
243 '{{WRAPPER}} .ekit-piechart-title' => 'color: {{VALUE}}',
244 ],
245 'condition' => [
246 'ekit_piechart_style' => 'withcontent'
247 ],
248 'separator' => 'before',
249 ]
250 );
251
252 $this->add_group_control(
253 Group_Control_Typography::get_type(),
254 [
255 'name' => 'ekit_piechart_title_typography_group',
256 'label' => esc_html__( 'Title Typography', 'elementskit-lite' ),
257 'selector' => '{{WRAPPER}} .ekit-piechart-title',
258 'condition' => [
259 'ekit_piechart_style' => 'withcontent'
260 ],
261 ]
262 );
263 $this->add_responsive_control(
264 'ekit_piechart_title_margin',
265 [
266 'label' =>esc_html__( 'Title margin', 'elementskit-lite' ),
267 'type' => Controls_Manager::DIMENSIONS,
268 'size_units' => [ 'px', 'em', '%' ],
269 'default' => [
270 'top' => '0',
271 'right' => '0',
272 'bottom' => '20',
273 'left' => '0',
274 'unit' => 'px',
275 ],
276 'selectors' => [
277 '{{WRAPPER}} .ekit-piechart-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
278 ],
279 ]
280 );
281
282 $this->end_controls_section();
283
284 // Content
285
286 $this->start_controls_section(
287 'ekit_piechart_general_settings',
288 [
289 'label' => esc_html__( 'Content', 'elementskit-lite' ),
290 'tab' => controls_Manager::TAB_STYLE,
291 'condition' => [
292 'ekit_piechart_style' => 'withcontent'
293 ],
294 ]
295 );
296
297 $this->add_control(
298 'ekit_piechart_content_color',
299 [
300 'label' => esc_html__( 'Content Color', 'elementskit-lite' ),
301 'type' => Controls_Manager::COLOR,
302 'selectors' => [
303 '{{WRAPPER}} .ekit-single-piechart p' => 'color: {{VALUE}}',
304 ],
305 'condition' => [
306 'ekit_piechart_style' => 'withcontent'
307 ],
308 'separator' => 'before',
309 ]
310 );
311
312 $this->add_group_control(
313 Group_Control_Typography::get_type(),
314 [
315 'name' => 'ekit_piechart_content_typography_group',
316 'label' => esc_html__( 'Typography', 'elementskit-lite' ),
317 'selector' => '{{WRAPPER}} .withcontent p',
318 'condition' => [
319 'ekit_piechart_style' => 'withcontent'
320 ],
321 ]
322 );
323
324 $this->add_control(
325 'ekit_piechart_content_margin',
326 [
327 'label' => __( 'Margin', 'elementskit-lite' ),
328 'type' => Controls_Manager::DIMENSIONS,
329 'size_units' => [ 'px', '%', 'em' ],
330 'selectors' => [
331 '{{WRAPPER}} .ekit-single-piechart p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
332 ],
333 ]
334 );
335
336 $this->add_responsive_control(
337 'ekit_piechart_content_align',
338 [
339 'label' =>esc_html__( 'Content Alignment', 'elementskit-lite' ),
340 'type' => Controls_Manager::CHOOSE,
341 'options' => [
342 'left' => [
343 'title' =>esc_html__( 'Left', 'elementskit-lite' ),
344 'icon' => 'eicon-text-align-left',
345 ],
346 'center' => [
347 'title' =>esc_html__( 'Center', 'elementskit-lite' ),
348 'icon' => 'eicon-text-align-center',
349 ],
350 'right' => [
351 'title' =>esc_html__( 'Right', 'elementskit-lite' ),
352 'icon' => 'eicon-text-align-right',
353 ],
354 ],
355 'selectors' => [
356 '{{WRAPPER}} .ekit-single-piechart' => 'text-align: {{VALUE}};',
357 ],
358 'default' => 'center',
359 ]
360 );
361
362 $this->end_controls_section();
363
364 // Flip card
365
366 $this->start_controls_section(
367 'ekit_piechart_section_flip_card',
368 [
369 'label' => esc_html__( 'Flip Card ', 'elementskit-lite' ),
370 'tab' => controls_Manager::TAB_STYLE,
371 'condition' => [
372 'ekit_piechart_style' => 'withcontent',
373 'ekit_piechart_content_type' => 'flip-card',
374 ]
375 ]
376 );
377
378 $this->add_group_control(
379 Group_Control_Background::get_type(),
380 [
381 'name' => 'ekit_piechart_flip_background_group',
382 'label' => esc_html__( 'Background', 'elementskit-lite' ),
383 'types' => ['gradient'],
384 'selector' => '{{WRAPPER}} .flip-card .back',
385 ]
386 );
387
388 $this->add_responsive_control(
389 'ekit_piechart_flip_back_padding',
390 [
391 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
392 'type' => Controls_Manager::DIMENSIONS,
393 'size_units' => [ 'px', '%', 'em' ],
394 'selectors' => [
395 '{{WRAPPER}} .ekit-single-piechart.flip-card .back' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
396 ],
397 ]
398 );
399
400
401 $this->end_controls_section();
402
403 // Chart style
404
405 $this->start_controls_section(
406 'ekit_piechart_section_piechart',
407 [
408 'label' => esc_html__( 'Chart', 'elementskit-lite' ),
409 'tab' => controls_Manager::TAB_STYLE,
410 ]
411 );
412
413 $this->add_responsive_control(
414 'ekit_piechart_size',
415 [
416 'label' => esc_html__( 'Piechart Size', 'elementskit-lite' ),
417 'type' => Controls_Manager::SLIDER,
418 'size_units' => [ 'px' ],
419 'render_type' => 'template',
420 'range' => [
421 'px' => [
422 'min' => 100,
423 'max' => 250,
424 'step' => 1,
425 ],
426 ],
427 'default' => [
428 'size' => 150,
429 ],
430 'selectors' => [
431 '{{WRAPPER}} .ekit-wid-con .ekit-single-piechart > .piechart canvas' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
432 ],
433 ]
434 );
435 $this->add_control(
436 'ekit_piechart_border_size',
437 [
438 'label' => esc_html__( 'Border Size', 'elementskit-lite' ),
439 'type' => Controls_Manager::SLIDER,
440 'size_units' => [ 'px' ],
441 'range' => [
442 'px' => [
443 'min' => 1,
444 'max' => 50,
445 'step' => 1,
446 ],
447 ],
448 'default' => [
449 'unit' => 'px',
450 'size' => 5,
451 ],
452 ]
453 );
454
455 $this->add_control(
456 'ekit_piechart_color_style',
457 [
458 'label' => esc_html__( 'Color Type', 'elementskit-lite' ),
459 'type' => Controls_Manager::SELECT,
460 'default' => 'normal',
461 'options' => [
462 'normal' => esc_html__( 'Normal', 'elementskit-lite' ),
463 'gradient' => esc_html__( 'Gradient', 'elementskit-lite' ),
464 ],
465 ]
466 );
467
468 $this->add_control(
469 'ekit_piechart_line_color',
470 [
471 'label' => esc_html__( 'Bar Color', 'elementskit-lite' ),
472 'type' => Controls_Manager::COLOR,
473 'render_type' => 'template',
474 'condition' => [
475 'ekit_piechart_color_style' => 'normal'
476 ],
477 ]
478 );
479
480 $this->add_control(
481 'ekit_piechart_bar_color_bg',
482 [
483 'label' => esc_html__( 'Bar Background Color', 'elementskit-lite' ),
484 'type' => Controls_Manager::COLOR,
485 'render_type' => 'template',
486 ]
487 );
488
489 $this->add_control(
490 'ekit_piechart_gradientColor1',
491 [
492 'label' => esc_html__( 'Gradient Color1', 'elementskit-lite' ),
493 'type' => Controls_Manager::COLOR,
494 'render_type' => 'template',
495 'condition' => [
496 'ekit_piechart_color_style' => 'gradient'
497 ],
498 ]
499 );
500
501 $this->add_control(
502 'ekit_piechart_gradientColor2',
503 [
504 'label' => esc_html__( 'Gradient Color2', 'elementskit-lite' ),
505 'type' => Controls_Manager::COLOR,
506 'render_type' => 'template',
507 'condition' => [
508 'ekit_piechart_color_style' => 'gradient'
509 ],
510 ]
511 );
512
513 $this->add_control(
514 'ekit_piechart_iocn_color',
515 [
516 'label' => esc_html__( ' Icon Color', 'elementskit-lite' ),
517 'type' => Controls_Manager::COLOR,
518 'default' => '#333',
519 'selectors' => [
520 '{{WRAPPER}} .ekit-chart-content i' => 'color: {{VALUE}};',
521 '{{WRAPPER}} .ekit-chart-content svg' => 'fill: {{VALUE}};',
522 ],
523 'condition' => [
524 'ekit_piechart_icon_type!' => 'image',
525 'ekit_piechart_content' => 'icon',
526 ]
527 ]
528 );
529
530 $this->add_control(
531 'ekit_piechart_content_color_number',
532 [
533 'label' => esc_html__( ' Number Color', 'elementskit-lite' ),
534 'type' => Controls_Manager::COLOR,
535 'default' => '#000000',
536 'selectors' => [
537 '{{WRAPPER}} .ekit-single-piechart span.ekit-chart-content' => 'color: {{VALUE}}',
538 ],
539 'condition' => [
540 'ekit_piechart_content' => 'ekit_piechart_percentage',
541 ]
542 ]
543 );
544
545 $this->end_controls_section();
546 // Background
547
548 $this->start_controls_section(
549 'ekit_piechart_background',
550 [
551 'label' => esc_html__( 'Background ', 'elementskit-lite' ),
552 'tab' => controls_Manager::TAB_STYLE,
553 ]
554 );
555
556 $this->add_responsive_control(
557 'ekit_piechart_wrapper_padding',
558 [
559 'label' =>esc_html__( 'Wrapper Padding', 'elementskit-lite' ),
560 'type' => Controls_Manager::DIMENSIONS,
561 'size_units' => [ 'px', 'em', '%' ],
562 'default' => [
563 'top' => '60',
564 'right' => '0',
565 'bottom' => '60',
566 'left' => '0',
567 'unit' => 'px',
568 ],
569 'selectors' => [
570 '{{WRAPPER}} .ekit-single-piechart' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
571 ],
572 ]
573 );
574
575 $this->add_group_control(
576 Group_Control_Box_Shadow::get_type(),
577 [
578 'name' => 'ekit_piechart_wrapper_box_shadow_group',
579 'label' => esc_html__( 'Box Shadow', 'elementskit-lite' ),
580 'selector' => '{{WRAPPER}} .ekit-single-piechart',
581 'separator' => 'before',
582 'description' => esc_html__('Eg: 0px 28px 40px 0px rgba(0, 0, 0, .1)', 'elementskit-lite'),
583 ]
584 );
585
586 $this->start_controls_tabs('ekit_piechart_style_tabs');
587
588 $this->start_controls_tab(
589 'ekit_piechart_wrapper_bg_style_normal_tab',
590 [
591 'label' => esc_html__( 'Normal', 'elementskit-lite' ),
592 ]
593 );
594
595
596 $this->add_group_control(
597 Group_Control_Background::get_type(),
598 [
599 'name' => 'ekit_piechart_background_group',
600 'label' => esc_html__( 'Background', 'elementskit-lite' ),
601 'types' => [ 'classic', 'gradient', 'video' ],
602 'selector' => '{{WRAPPER}} .ekit-single-piechart',
603 ]
604 );
605
606 $this->end_controls_tab();
607
608 $this->start_controls_tab(
609 'ekit_piechart_bg_style_hover_tab',
610 [
611 'label' => esc_html__( 'Hover', 'elementskit-lite' ),
612 ]
613 );
614
615 $this->add_group_control(
616 Group_Control_Background::get_type(),
617 [
618 'name' => 'ekit_piechart_background_hover_group',
619 'label' => esc_html__( 'Background', 'elementskit-lite' ),
620 'types' => [ 'classic', 'gradient', 'video' ],
621 'selector' => '{{WRAPPER}} .ekit-single-piechart:hover',
622 ]
623 );
624
625 $this->add_control(
626 'ekit_piechart_bg_hover_animation',
627 [
628 'label' => esc_html__( 'Hover Animation', 'elementskit-lite' ),
629 'type' => Controls_Manager::HOVER_ANIMATION,
630 'prefix_class' => 'elementor-animation-',
631 ]
632 );
633
634
635 $this->end_controls_tab();
636 $this->end_controls_tabs();
637
638 $this->end_controls_section();
639
640 $this->insert_pro_message();
641 }
642
643 protected function render( ) {
644 echo '<div class="ekit-wid-con">';
645 $this->render_raw();
646 echo '</div>';
647 }
648
649 protected function render_raw( ) {
650 $settings = $this->get_settings_for_display();
651
652 $colors = $this->get_globals_colors($settings);
653
654 if($settings['ekit_piechart_bg_hover_animation'] != '') {
655 $this->add_render_attribute( 'pieechart', 'class', $settings['hover_animation'] );
656 }
657
658 $this->add_render_attribute( 'pieechart', 'class', 'ekit-single-piechart' );
659 if($settings['ekit_piechart_style'] == 'simple'){
660 $this->add_render_attribute( 'pieechart', 'class', 'text-center' );
661 }
662
663
664 if($settings['ekit_piechart_content_type'] == 'flip-card'){
665 $this->add_render_attribute( 'pieechart', 'class', $settings['ekit_piechart_content_type'] );
666 }
667
668 if(isset($settings['ekit_piechart_flip_background_group_background']) && $settings['ekit_piechart_flip_background_group_background'] == 'gradient'){
669 $this->add_render_attribute( 'pieechart', 'class', $settings['ekit_piechart_content_type'].' '.'flip-gradient-color' );
670 }
671
672 $this->add_render_attribute( 'pieechart', 'class', $settings['ekit_piechart_style'] );
673
674 $this->add_render_attribute( 'pieechartscreen', [
675 'class' => 'colorful-chart piechart',
676 'data-pie_color_style' => $settings['ekit_piechart_color_style'],
677 'data-gradientcolor1' => $colors['ekit_piechart_gradientColor1'],
678 'data-gradientcolor2' => $colors['ekit_piechart_gradientColor2'],
679 ] );
680
681 if($colors['ekit_piechart_line_color'] != '') {
682 $this->add_render_attribute( 'pieechartscreen', 'data-color', $colors['ekit_piechart_line_color'] );
683 }
684
685 if($colors['ekit_piechart_bar_color_bg'] != '') {
686 $this->add_render_attribute( 'pieechartscreen', 'data-barbg', $colors['ekit_piechart_bar_color_bg'] );
687 }
688
689 $piechart_size = $settings['ekit_piechart_size']['size'] != '' ? $settings['ekit_piechart_size']['size'] : 150;
690 $this->add_render_attribute( 'pieechartscreen', 'data-size', $piechart_size );
691
692 $line_size = $settings['ekit_piechart_border_size']['size'] != '' ? $settings['ekit_piechart_border_size']['size'] : 5;
693 $this->add_render_attribute( 'pieechartscreen', 'data-linewidth', $line_size );
694
695
696 if($settings['ekit_piechart_percentage'] != '') {
697 $this->add_render_attribute( 'pieechartscreen', 'data-percent', $settings['ekit_piechart_percentage'] );
698 }
699
700 if (!empty($settings['ekit_piechart_icon_image']['url'])) {
701 $this->add_render_attribute('image', 'src', $settings['ekit_piechart_icon_image']['url']);
702 $this->add_render_attribute('image', 'alt', Control_Media::get_image_alt($settings['ekit_piechart_icon_image']));
703 $this->add_render_attribute('image', 'title', Control_Media::get_image_title($settings['ekit_piechart_icon_image']));
704
705 $image_html = Group_Control_Image_Size::get_attachment_image_html($settings, 'ekit_piechart_icon_image_size_group', 'ekit_piechart_icon_image');
706 }
707
708 $flip_front_start = '';
709 $flip_front_end = '';
710 $flip_back_start = '';
711 $flip_back_end = '';
712
713 if($settings['ekit_piechart_style'] == 'withcontent' && $settings['ekit_piechart_content_type'] == 'flip-card'){
714 $flip_front_start .= '<div class="front"><div class="ekit-single-piechart_in">';
715 $flip_front_end .= '</div></div>';
716 $flip_back_start = '<div class="back">';
717 $flip_back_end = '</div>';
718 }
719
720 ?>
721 <div <?php echo $this->get_render_attribute_string( 'pieechart' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped by elementor ?>>
722
723 <?php echo wp_kses($flip_front_start, \ElementsKit_Lite\Utils::get_kses_array()); ?>
724
725 <div <?php echo $this->get_render_attribute_string( 'pieechartscreen' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped by elementor ?>>
726
727 <?php if($settings['ekit_piechart_percentage'] != '' && $settings['ekit_piechart_content'] == 'ekit_piechart_percentage') { ?>
728
729 <span class="ekit-chart-content"><?php echo esc_html($settings['ekit_piechart_percentage']); ?>&#37;</span>
730
731 <?php } ?>
732
733 <?php if($settings['ekit_piechart_content'] == 'icon' && $settings['ekit_piechart_icon_type'] == 'image') { ?>
734
735 <span class="ekit-chart-content">
736 <?php echo wp_kses($image_html, \ElementsKit_Lite\Utils::get_kses_array()); ?>
737 </span>
738
739 <?php } ?>
740
741 <?php if($settings['ekit_piechart_content'] == 'icon' && $settings['ekit_piechart_icon_type'] == 'icon') { ?>
742
743 <span class="ekit-chart-content">
744 <?php
745 // new icon
746 $migrated = isset( $settings['__fa4_migrated']['ekit_piechart_icons'] );
747 // Check if its a new widget without previously selected icon using the old Icon control
748 $is_new = empty( $settings['ekit_piechart_icon'] );
749 if ( $is_new || $migrated ) {
750 // new icon
751 Icons_Manager::render_icon( $settings['ekit_piechart_icons'], [ 'aria-hidden' => 'true' ] );
752 } else {
753 ?>
754 <i class="<?php echo esc_attr($settings['ekit_piechart_icon']); ?>" aria-hidden="true"></i>
755 <?php
756 }
757 ?>
758 </span>
759
760 <?php } ?>
761
762
763
764 </div>
765 <?php
766
767 echo wp_kses($flip_front_end.$flip_back_start, \ElementsKit_Lite\Utils::get_kses_array());
768
769
770 if($settings['ekit_piechart_style'] == 'withcontent' && $settings['ekit_piechart_title'] != '') { ?>
771 <h2 class="ekit-piechart-title"><?php echo esc_html($settings['ekit_piechart_title']); ?></h2>
772 <?php }
773
774 if($settings['ekit_piechart_style'] == 'withcontent' && $settings['ekit_piechart_item_description'] != '') { ?>
775
776 <p><?php echo wp_kses($settings['ekit_piechart_item_description'], \ElementsKit_Lite\Utils::get_kses_array()); ?></p>
777
778 <?php }
779
780 echo wp_kses($flip_back_end, \ElementsKit_Lite\Utils::get_kses_array());
781
782 ?>
783 </div>
784 <?php
785 }
786
787 protected function get_globals_colors($settings) {
788 $global_colors = [];
789 $kit_items = $this->get_kit_items();
790 $globals_vars = !empty($settings['__globals__']) ? array_filter($settings['__globals__']) : [];
791 if($globals_vars) {
792 foreach($globals_vars as $key => $globals_var) {
793 parse_str(wp_parse_url($globals_var, PHP_URL_QUERY), $queryParams);
794 if (isset($queryParams['id']) && isset($kit_items[$queryParams['id']]['value'])) {
795 $global_colors[$key] = $kit_items[$queryParams['id']]['value'];
796 }
797 }
798 }
799
800 $color_controls = [
801 'ekit_piechart_line_color',
802 'ekit_piechart_bar_color_bg',
803 'ekit_piechart_gradientColor1',
804 'ekit_piechart_gradientColor2'
805 ];
806
807 foreach($color_controls as $color_control) {
808 if(isset($global_colors[$color_control])) {
809 continue;
810 }
811
812 $global_colors[$color_control] = isset($settings[$color_control]) ? $settings[$color_control] : '';
813 }
814
815 return $global_colors;
816 }
817
818 protected function get_kit_items() {
819 $result = [];
820 $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
821
822 $system_items = $kit->get_settings_for_display( 'system_colors' );
823 $custom_items = $kit->get_settings_for_display( 'custom_colors' );
824
825 if ( ! $system_items ) {
826 $system_items = [];
827 }
828
829 if ( ! $custom_items ) {
830 $custom_items = [];
831 }
832
833 $items = array_merge( $system_items, $custom_items );
834
835 foreach ( $items as $index => $item ) {
836 $id = $item['_id'];
837 $result[ $id ] = [
838 'id' => $id,
839 'title' => $item['title'],
840 'value' => $item['color'],
841 ];
842 }
843
844 return $result;
845 }
846 }
847