PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.83
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.83
51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 All 39 releases
← All changes | includes/widgets/Testimonial/Testimonial.php +1226 -0 51.1.251.1.83 View file →
@@ -1,0 +1,1226 @@
1 +<?php /** @noinspection SpellCheckingInspection, DuplicatedCode, PhpUnused */
2 +
3 +namespace King_Addons;
4 +
5 +use Elementor\Controls_Manager;
6 +use Elementor\Group_Control_Background;
7 +use Elementor\Group_Control_Border;
8 +use Elementor\Group_Control_Box_Shadow;
9 +use Elementor\Group_Control_Css_Filter;
10 +use Elementor\Group_Control_Image_Size;
11 +use Elementor\Group_Control_Typography;
12 +use Elementor\Icons_Manager;
13 +use Elementor\Utils;
14 +use Elementor\Widget_Base;
15 +
16 +if (!defined('ABSPATH')) {
17 + exit; // Exit if accessed directly.
18 +}
19 +
20 +
21 +
22 +class Testimonial extends Widget_Base
23 +{
24 +
25 +
26 + public function get_name(): string
27 + {
28 + return 'king-addons-testimonial';
29 + }
30 +
31 + public function get_title(): string
32 + {
33 + return esc_html__('Testimonial & Review', 'king-addons');
34 + }
35 +
36 + public function get_icon(): string
37 + {
38 + return 'king-addons-icon king-addons-testimonial';
39 + }
40 +
41 + public function get_style_depends(): array
42 + {
43 + return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-testimonial-style'];
44 + }
45 +
46 + public function get_categories(): array
47 + {
48 + return ['king-addons'];
49 + }
50 +
51 + public function get_keywords(): array
52 + {
53 + return ['testimonial', 'review', 'rating', 'stars', 'rate', 'star',
54 + 'king addons', 'king', 'addons', 'kingaddons', 'king-addons'];
55 + }
56 +
57 + public function get_custom_help_url()
58 + {
59 + return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
60 + }
61 +
62 + protected function register_controls(): void
63 + {
64 +
65 + $this->start_controls_section(
66 + 'king_addons_testimonial_layout_section',
67 + [
68 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Layout', 'king-addons'),
69 + 'tab' => Controls_Manager::TAB_CONTENT
70 + ]
71 + );
72 +
73 + // selector - testimonial layouts
74 + $this->add_control(
75 + 'king_addons_testimonial_layout',
76 + array(
77 + 'label' => '<b>' . esc_html__('Layout', 'king-addons') . '</b>',
78 + 'type' => Controls_Manager::SELECT,
79 + 'options' => array(
80 + 'layout-1' => esc_html__('Default - Image, Desc, Rating, Bio', 'king-addons'),
81 + 'layout-8' => esc_html__('Default Centered - Image, Desc, Rating, Bio', 'king-addons'),
82 + 'layout-2' => esc_html__('Classic - Desc, Bio, Rating, Image', 'king-addons'),
83 + 'layout-3' => esc_html__('Desc, Image, Bio, Rating', 'king-addons'),
84 + 'layout-4' => esc_html__('Image | Content', 'king-addons'),
85 + 'layout-5' => esc_html__('Content | Image', 'king-addons'),
86 + 'layout-6' => esc_html__('Desc | Bottom Bio', 'king-addons'),
87 + 'layout-7' => esc_html__('Top Bio | Desc', 'king-addons'),
88 + ),
89 + 'render_type' => 'template',
90 + 'default' => 'layout-1',
91 + )
92 + );
93 +
94 + $this->end_controls_section();
95 +
96 + $this->start_controls_section(
97 + 'king_addons_testimonial_image_section',
98 + [
99 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Image', 'king-addons'),
100 + 'tab' => Controls_Manager::TAB_CONTENT
101 + ]
102 + );
103 +
104 + $this->add_control(
105 + 'king_addons_testimonial_image_switcher',
106 + array(
107 + 'label' => esc_html__('Show Image', 'king-addons'),
108 + 'type' => Controls_Manager::SWITCHER,
109 + 'default' => 'yes',
110 + 'return_value' => 'yes',
111 + )
112 + );
113 +
114 + $this->add_control(
115 + 'king_addons_testimonial_image',
116 + [
117 + 'label' => esc_html__('Upload Image', 'king-addons'),
118 + 'type' => Controls_Manager::MEDIA,
119 + 'separator' => 'before',
120 + 'dynamic' => array('active' => true),
121 + 'default' => array(
122 + 'url' => Utils::get_placeholder_image_src(),
123 + ),
124 + 'show_external' => true,
125 + 'condition' => array(
126 + 'king_addons_testimonial_image_switcher' => 'yes',
127 + ),
128 + ]
129 + );
130 +
131 + $this->add_group_control(
132 + Group_Control_Image_Size::get_type(),
133 + [
134 + 'name' => 'king_addons_testimonial_image_size',
135 + 'default' => 'medium',
136 + 'condition' => array(
137 + 'king_addons_testimonial_image_switcher' => 'yes',
138 + ),
139 + ]
140 + );
141 +
142 + $this->end_controls_section();
143 +
144 + // RATING =================================================
145 + $this->start_controls_section(
146 + 'king_addons_testimonial_section_rating',
147 + [
148 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Rating', 'king-addons'),
149 + 'tab' => Controls_Manager::TAB_CONTENT,
150 + ]
151 + );
152 +
153 + $this->add_control(
154 + 'king_addons_testimonial_rating_switcher',
155 + array(
156 + 'label' => esc_html__('Show Rating', 'king-addons'),
157 + 'type' => Controls_Manager::SWITCHER,
158 + 'default' => 'yes',
159 + 'return_value' => 'yes',
160 + )
161 + );
162 +
163 + $this->add_control(
164 + 'king_addons_testimonial_rating_scale',
165 + [
166 + 'label' => esc_html__('Rating Scale', 'king-addons'),
167 + 'type' => Controls_Manager::SLIDER,
168 + 'range' => [
169 + 'px' => [
170 + 'min' => 1,
171 + 'max' => 10,
172 + ],
173 + ],
174 + 'default' => [
175 + 'size' => 5,
176 + ],
177 + 'condition' => array(
178 + 'king_addons_testimonial_rating_switcher' => 'yes',
179 + ),
180 + 'separator' => 'before',
181 + ]
182 + );
183 +
184 + $this->add_control(
185 + 'king_addons_testimonial_rating_value',
186 + [
187 + 'label' => esc_html__('Rating', 'king-addons'),
188 + 'type' => Controls_Manager::NUMBER,
189 + 'min' => 0,
190 + 'max' => 10,
191 + 'default' => 5,
192 + 'step' => 0.25,
193 + 'dynamic' => [
194 + 'active' => true,
195 + ],
196 + 'condition' => array(
197 + 'king_addons_testimonial_rating_switcher' => 'yes',
198 + ),
199 + ]
200 + );
201 +
202 + $this->add_control(
203 + 'king_addons_testimonial_rating_icon',
204 + [
205 + 'label' => esc_html__('Icon', 'king-addons'),
206 + 'type' => Controls_Manager::ICONS,
207 + 'fa4compatibility' => 'icon',
208 + 'skin' => 'inline',
209 + 'label_block' => false,
210 + 'skin_settings' => [
211 + 'inline' => [
212 + 'icon' => [
213 + 'icon' => 'eicon-star',
214 + ],
215 + ],
216 + ],
217 + 'default' => [
218 + 'value' => 'eicon-star',
219 + 'library' => 'eicons',
220 + ],
221 + 'separator' => 'before',
222 + 'exclude_inline_options' => ['none'],
223 + 'condition' => array(
224 + 'king_addons_testimonial_rating_switcher' => 'yes',
225 + ),
226 + ]
227 + );
228 +
229 + $this->end_controls_section();
230 + // END: RATING ============================================
231 +
232 + $this->start_controls_section(
233 + 'king_addons_testimonial_content_section',
234 + [
235 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Content', 'king-addons'),
236 + 'tab' => Controls_Manager::TAB_CONTENT
237 + ]
238 + );
239 +
240 + $this->add_control(
241 + 'king_addons_testimonial_title',
242 + [
243 + 'label' => '<b>' . esc_html__('Title', 'king-addons') . '</b>',
244 + 'type' => Controls_Manager::TEXT,
245 + 'label_block' => true,
246 + 'default' => esc_html__('Title', 'king-addons'),
247 + ]
248 + );
249 +
250 + $this->add_control(
251 + 'king_addons_testimonial_subtitle',
252 + [
253 + 'label' => '<b>' . esc_html__('Subtitle', 'king-addons') . '</b>',
254 + 'type' => Controls_Manager::TEXT,
255 + 'label_block' => true,
256 + 'default' => esc_html__('Subtitle', 'king-addons'),
257 + 'separator' => 'before'
258 + ]
259 + );
260 +
261 + $this->add_control(
262 + 'king_addons_testimonial_description_title',
263 + [
264 + 'label' => '<b>' . esc_html__('Description', 'king-addons') . '</b>',
265 + 'type' => Controls_Manager::RAW_HTML,
266 + 'separator' => 'before',
267 + ]
268 + );
269 +
270 + $this->add_control(
271 + 'king_addons_testimonial_description',
272 + [
273 + 'label' => '<b>' . esc_html__('Description', 'king-addons') . '</b>',
274 + 'type' => Controls_Manager::WYSIWYG,
275 + 'show_label' => false,
276 + 'default' => esc_html__('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'king-addons'),
277 + 'placeholder' => esc_html__('Type the description here', 'king-addons'),
278 + ]
279 + );
280 +
281 + $this->end_controls_section();
282 +
283 + /** ========================================================== */
284 + /** ========================================================== */
285 + /** ========================================================== */
286 + /** STYLES */
287 +
288 + // IMAGE
289 + $this->start_controls_section(
290 + 'king_addons_testimonial_section_image_style',
291 + [
292 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Image', 'king-addons'),
293 + 'tab' => Controls_Manager::TAB_STYLE,
294 + ]
295 + );
296 +
297 + $this->add_responsive_control(
298 + 'king_addons_testimonial_image_width',
299 + [
300 + 'label' => esc_html__('Width (px)', 'king-addons'),
301 + 'type' => Controls_Manager::NUMBER,
302 + 'min' => 0,
303 + 'step' => 1,
304 + 'default' => 70,
305 + 'selectors' => [
306 + '{{WRAPPER}} .king-addons-testimonial-image img' => 'width: {{SIZE}}px;',
307 + '{{WRAPPER}} .king-addons-testimonial-layout-4 .king-addons-testimonial-image' => 'flex: 0 0 {{SIZE}}px;',
308 + ],
309 + ]
310 + );
311 +
312 + $this->add_responsive_control(
313 + 'king_addons_testimonial_image_height',
314 + [
315 + 'label' => esc_html__('Height (px)', 'king-addons'),
316 + 'type' => Controls_Manager::NUMBER,
317 + 'min' => 0,
318 + 'step' => 1,
319 + 'default' => 70,
320 + 'selectors' => [
321 + '{{WRAPPER}} .king-addons-testimonial-image img' => 'height: {{SIZE}}px;'
322 + ],
323 + ]
324 + );
325 +
326 + $this->add_responsive_control(
327 + 'king_addons_testimonial_whole_testimonial_gap',
328 + [
329 + 'label' => esc_html__('Gap between Image and Content (px)', 'king-addons'),
330 + 'type' => Controls_Manager::NUMBER,
331 + 'min' => 0,
332 + 'step' => 1,
333 + 'default' => 20,
334 + 'selectors' => [
335 + '{{WRAPPER}} .king-addons-testimonial-layout-4,
336 + {{WRAPPER}} .king-addons-testimonial-layout-5' => 'gap: {{SIZE}}px;'
337 + ],
338 + 'condition' => [
339 + 'king_addons_testimonial_layout' => ['layout-4', 'layout-5']
340 + ],
341 + ]
342 + );
343 +
344 + $this->add_responsive_control(
345 + 'king_addons_testimonial_whole_testimonial_gap_2',
346 + [
347 + 'label' => esc_html__('Gap between Image and Content (px)', 'king-addons'),
348 + 'type' => Controls_Manager::NUMBER,
349 + 'min' => 0,
350 + 'step' => 1,
351 + 'default' => 15,
352 + 'selectors' => [
353 + '{{WRAPPER}} .king-addons-testimonial-layout-1,
354 + {{WRAPPER}} .king-addons-testimonial-layout-2,
355 + {{WRAPPER}} .king-addons-testimonial-layout-3,
356 + {{WRAPPER}} .king-addons-testimonial-layout-8' => 'gap: {{SIZE}}px;'
357 + ],
358 + 'condition' => [
359 + 'king_addons_testimonial_layout' => ['layout-1', 'layout-2', 'layout-3', 'layout-8']
360 + ],
361 + ]
362 + );
363 +
364 + $this->add_group_control(
365 + Group_Control_Css_Filter::get_type(),
366 + [
367 + 'label' => esc_html__('CSS Filter', 'king-addons'),
368 + 'name' => 'king_addons_testimonial_image_css_filters',
369 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-image img',
370 + ]
371 + );
372 +
373 + $this->add_group_control(
374 + Group_Control_Box_Shadow::get_type(),
375 + [
376 + 'name' => 'king_addons_testimonial_image_box_shadow',
377 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-image img',
378 + ]
379 + );
380 +
381 + $this->add_group_control(
382 + Group_Control_Border::get_type(),
383 + [
384 + 'name' => 'king_addons_testimonial_image_border',
385 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-image img',
386 + 'fields_options' => [
387 + 'border' => [
388 + 'default' => 'none',
389 + ],
390 + ],
391 + ]
392 + );
393 +
394 + $this->add_responsive_control(
395 + 'king_addons_testimonial_image_border_radius',
396 + [
397 + 'label' => esc_html__('Border Radius', 'king-addons'),
398 + 'type' => Controls_Manager::DIMENSIONS,
399 + 'size_units' => ['px', '%'],
400 + 'default' => [
401 + 'top' => 100,
402 + 'right' => 100,
403 + 'bottom' => 100,
404 + 'left' => 100,
405 + 'unit' => '%',
406 + ],
407 + 'selectors' => [
408 + '{{WRAPPER}} .king-addons-testimonial-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
409 + ]
410 + ]
411 + );
412 +
413 + $this->end_controls_section();
414 +
415 + // TITLE
416 + $this->start_controls_section(
417 + 'king_addons_testimonial_section_title_style',
418 + [
419 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Title', 'king-addons'),
420 + 'tab' => Controls_Manager::TAB_STYLE,
421 + ]
422 + );
423 +
424 + // title - typography
425 + $this->add_group_control(
426 + Group_Control_Typography::get_type(),
427 + [
428 + 'label' => esc_html__('Typography', 'king-addons'),
429 + 'name' => 'king_addons_testimonial_title_typography',
430 + 'fields_options' => [
431 + 'font_size' => [
432 + 'default' => [
433 + 'size' => 18,
434 + 'unit' => 'px'
435 + ],
436 + ],
437 + 'font_weight' => [
438 + 'default' => 600,
439 + ],
440 + 'typography' => [
441 + 'default' => 'custom',
442 + ]
443 + ],
444 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-title',
445 + ]
446 + );
447 +
448 + // title - color
449 + $this->add_control(
450 + 'king_addons_testimonial_title_color',
451 + [
452 + 'label' => esc_html__('Color', 'king-addons'),
453 + 'type' => Controls_Manager::COLOR,
454 + 'default' => '#000000',
455 + 'selectors' => [
456 + '{{WRAPPER}} .king-addons-testimonial-title' => 'color: {{VALUE}};',
457 + ],
458 + ]
459 + );
460 +
461 + // title - margin
462 + $this->add_responsive_control(
463 + 'king_addons_testimonial_title_margin',
464 + [
465 + 'label' => esc_html__('Margin', 'king-addons'),
466 + 'type' => Controls_Manager::DIMENSIONS,
467 + 'size_units' => ['px', 'em', '%'],
468 + 'default' => [
469 + 'top' => 0,
470 + 'right' => 5,
471 + 'bottom' => 0,
472 + 'left' => 0,
473 + 'unit' => 'px',
474 + ],
475 + 'selectors' => [
476 + '{{WRAPPER}} .king-addons-testimonial-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
477 + ]
478 + ]
479 + );
480 +
481 + $this->end_controls_section();
482 +
483 + $this->start_controls_section(
484 + 'king_addons_testimonial_section_subtitle_style',
485 + [
486 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Subtitle', 'king-addons'),
487 + 'tab' => Controls_Manager::TAB_STYLE,
488 + ]
489 + );
490 +
491 + // subtitle - typography
492 + $this->add_group_control(
493 + Group_Control_Typography::get_type(),
494 + [
495 + 'label' => esc_html__('Typography', 'king-addons'),
496 + 'name' => 'king_addons_testimonial_subtitle_typography',
497 + 'fields_options' => [
498 + 'font_size' => [
499 + 'default' => [
500 + 'size' => 15,
501 + 'unit' => 'px'
502 + ],
503 + ],
504 + 'font_weight' => [
505 + 'default' => 400,
506 + ],
507 + 'typography' => [
508 + 'default' => 'custom',
509 + ]
510 + ],
511 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-subtitle',
512 + ]
513 + );
514 +
515 + // subtitle - color
516 + $this->add_control(
517 + 'king_addons_testimonial_subtitle_color',
518 + [
519 + 'label' => esc_html__('Color', 'king-addons'),
520 + 'type' => Controls_Manager::COLOR,
521 + 'default' => '#888888',
522 + 'selectors' => [
523 + '{{WRAPPER}} .king-addons-testimonial-subtitle' => 'color: {{VALUE}};',
524 + ],
525 + ]
526 + );
527 +
528 + // subtitle - margin
529 + $this->add_responsive_control(
530 + 'king_addons_testimonial_subtitle_margin',
531 + [
532 + 'label' => esc_html__('Margin', 'king-addons'),
533 + 'type' => Controls_Manager::DIMENSIONS,
534 + 'size_units' => ['px', 'em', '%'],
535 + 'default' => [
536 + 'top' => 0,
537 + 'right' => 0,
538 + 'bottom' => 0,
539 + 'left' => 0,
540 + 'unit' => 'px',
541 + ],
542 + 'selectors' => [
543 + '{{WRAPPER}} .king-addons-testimonial-subtitle' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
544 + ]
545 + ]
546 + );
547 +
548 + // subtitle - margin
549 + $this->add_responsive_control(
550 + 'king_addons_testimonial_title_subtitle_margin',
551 + [
552 + 'label' => esc_html__('Title-Subtitle Block Margin', 'king-addons'),
553 + 'type' => Controls_Manager::DIMENSIONS,
554 + 'size_units' => ['px', 'em', '%'],
555 + 'default' => [
556 + 'top' => 0,
557 + 'right' => 0,
558 + 'bottom' => 15,
559 + 'left' => 0,
560 + 'unit' => 'px',
561 + ],
562 + 'selectors' => [
563 + '{{WRAPPER}} .king-addons-testimonial-person-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
564 + ],
565 + 'separator' => 'before',
566 + 'condition' => [
567 + 'king_addons_testimonial_layout' => ['layout-2']
568 + ],
569 + ]
570 + );
571 +
572 + $this->add_responsive_control(
573 + 'king_addons_testimonial_title_subtitle_margin_2',
574 + [
575 + 'label' => esc_html__('Title-Subtitle Block Margin', 'king-addons'),
576 + 'type' => Controls_Manager::DIMENSIONS,
577 + 'size_units' => ['px', 'em', '%'],
578 + 'default' => [
579 + 'top' => 0,
580 + 'right' => 0,
581 + 'bottom' => 10,
582 + 'left' => 0,
583 + 'unit' => 'px',
584 + ],
585 + 'selectors' => [
586 + '{{WRAPPER}} .king-addons-testimonial-person-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
587 + ],
588 + 'separator' => 'before',
589 + 'condition' => [
590 + 'king_addons_testimonial_layout' => ['layout-6', 'layout-7']
591 + ],
592 + ]
593 + );
594 +
595 + $this->end_controls_section();
596 +
597 + $this->start_controls_section(
598 + 'king_addons_testimonial_section_description_style',
599 + [
600 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Description', 'king-addons'),
601 + 'tab' => Controls_Manager::TAB_STYLE,
602 + ]
603 + );
604 +
605 + // description - typography
606 + $this->add_group_control(
607 + Group_Control_Typography::get_type(),
608 + [
609 + 'label' => esc_html__('Typography', 'king-addons'),
610 + 'name' => 'king_addons_testimonial_description_typography',
611 + 'fields_options' => [
612 + 'font_size' => [
613 + 'default' => [
614 + 'size' => 16,
615 + 'unit' => 'px'
616 + ],
617 + ],
618 + 'font_weight' => [
619 + 'default' => 400,
620 + ],
621 + 'typography' => [
622 + 'default' => 'custom',
623 + ]
624 + ],
625 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-description',
626 + ]
627 + );
628 +
629 + // description - color
630 + $this->add_control(
631 + 'king_addons_testimonial_description_color',
632 + [
633 + 'label' => esc_html__('Color', 'king-addons'),
634 + 'type' => Controls_Manager::COLOR,
635 + 'default' => '#000000',
636 + 'selectors' => [
637 + '{{WRAPPER}} .king-addons-testimonial-description' => 'color: {{VALUE}};',
638 + ],
639 + ]
640 + );
641 +
642 + // description - margin
643 + $this->add_responsive_control(
644 + 'king_addons_testimonial_description_margin',
645 + [
646 + 'label' => esc_html__('Margin', 'king-addons'),
647 + 'type' => Controls_Manager::DIMENSIONS,
648 + 'size_units' => ['px', 'em', '%'],
649 + 'default' => [
650 + 'top' => 0,
651 + 'right' => 0,
652 + 'bottom' => 10,
653 + 'left' => 0,
654 + 'unit' => 'px',
655 + ],
656 + 'selectors' => [
657 + '{{WRAPPER}} .king-addons-testimonial-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
658 + ],
659 + 'condition' => [
660 + 'king_addons_testimonial_layout' => ['layout-1', 'layout-2', 'layout-3', 'layout-4', 'layout-5', 'layout-8']
661 + ],
662 + ]
663 + );
664 +
665 + $this->end_controls_section();
666 +
667 + // STYLE: RATING ============================================
668 + $this->start_controls_section(
669 + 'king_addons_testimonial_section_icon_style',
670 + [
671 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Rating', 'king-addons'),
672 + 'tab' => Controls_Manager::TAB_STYLE,
673 + ]
674 + );
675 +
676 + $this->add_responsive_control(
677 + 'king_addons_testimonial_icon_size',
678 + [
679 + 'label' => esc_html__('Size', 'king-addons'),
680 + 'type' => Controls_Manager::SLIDER,
681 + 'size_units' => ['px', 'em', 'rem', 'vw', 'custom'],
682 + 'range' => [
683 + 'px' => [
684 + 'max' => 100,
685 + ],
686 + 'em' => [
687 + 'min' => 0,
688 + 'max' => 10,
689 + ],
690 + 'rem' => [
691 + 'min' => 0,
692 + 'max' => 10,
693 + ],
694 + ],
695 + 'selectors' => [
696 + '{{WRAPPER}} .king-addons-testimonial-rating-general' => '--king-addons-testimonial-rating-icon-font-size: {{SIZE}}{{UNIT}}',
697 + ],
698 + ]
699 + );
700 +
701 + $this->add_responsive_control(
702 + 'king_addons_testimonial_icon_gap',
703 + [
704 + 'label' => esc_html__('Spacing', 'king-addons'),
705 + 'type' => Controls_Manager::SLIDER,
706 + 'size_units' => ['px', 'em', 'rem', 'vw', 'custom'],
707 + 'range' => [
708 + 'px' => [
709 + 'max' => 100,
710 + ],
711 + 'em' => [
712 + 'min' => 0,
713 + 'max' => 10,
714 + ],
715 + 'rem' => [
716 + 'min' => 0,
717 + 'max' => 10,
718 + ],
719 + ],
720 + 'selectors' => [
721 + '{{WRAPPER}} .king-addons-testimonial-rating-general' => '--king-addons-testimonial-rating-gap: {{SIZE}}{{UNIT}}',
722 + ],
723 + ]
724 + );
725 +
726 + $this->add_control(
727 + 'king_addons_testimonial_icon_color',
728 + [
729 + 'label' => esc_html__('Color', 'king-addons'),
730 + 'type' => Controls_Manager::COLOR,
731 + 'selectors' => [
732 + '{{WRAPPER}} .king-addons-testimonial-rating-general' => '--king-addons-testimonial-rating-icon-marked-color: {{VALUE}}',
733 + ],
734 + 'separator' => 'before',
735 + ]
736 + );
737 +
738 + $this->add_control(
739 + 'king_addons_testimonial_icon_unmarked_color',
740 + [
741 + 'label' => esc_html__('Unmarked Color', 'king-addons'),
742 + 'type' => Controls_Manager::COLOR,
743 + 'selectors' => [
744 + '{{WRAPPER}} .king-addons-testimonial-rating-general' => '--king-addons-testimonial-rating-icon-color: {{VALUE}}',
745 + ],
746 + ]
747 + );
748 +
749 + // rating - margin
750 + $this->add_responsive_control(
751 + 'king_addons_testimonial_icon_margin',
752 + [
753 + 'label' => esc_html__('Margin', 'king-addons'),
754 + 'type' => Controls_Manager::DIMENSIONS,
755 + 'size_units' => ['px', '%'],
756 + 'default' => [
757 + 'top' => 0,
758 + 'right' => 0,
759 + 'bottom' => 10,
760 + 'left' => 0,
761 + 'unit' => 'px',
762 + ],
763 + 'selectors' => [
764 + '{{WRAPPER}} .king-addons-testimonial-rating-general' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
765 + ],
766 + 'condition' => [
767 + 'king_addons_testimonial_layout' => ['layout-1', 'layout-2', 'layout-4', 'layout-5', 'layout-8']
768 + ],
769 + ]
770 + );
771 +
772 + $this->end_controls_section();
773 + // END: RATING ============================================
774 +
775 + $this->start_controls_section(
776 + 'king_addons_testimonial_section_whole_testimonial_style',
777 + [
778 + 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Whole Testimonial', 'king-addons'),
779 + 'tab' => Controls_Manager::TAB_STYLE,
780 + ]
781 + );
782 +
783 +
784 + $this->add_group_control(
785 + Group_Control_Background::get_type(),
786 + [
787 + 'name' => 'king_addons_testimonial_whole_testimonial_bg',
788 + 'fields_options' => [
789 + 'color' => [
790 + 'default' => '#FFFFFF',
791 + ],
792 + 'background' => [
793 + 'default' => 'classic',
794 + ]
795 + ],
796 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-layout'
797 + ]
798 + );
799 +
800 + $this->add_responsive_control(
801 + 'king_addons_testimonial_whole_testimonial_gap_3',
802 + [
803 + 'label' => esc_html__('Space between Bio and Description (px)', 'king-addons'),
804 + 'type' => Controls_Manager::NUMBER,
805 + 'min' => 0,
806 + 'step' => 1,
807 + 'default' => 25,
808 + 'separator' => 'before',
809 + 'selectors' => [
810 + '{{WRAPPER}} .king-addons-testimonial-layout-6,
811 + {{WRAPPER}} .king-addons-testimonial-layout-7' => 'gap: {{SIZE}}px;'
812 + ],
813 + 'condition' => [
814 + 'king_addons_testimonial_layout' => ['layout-6', 'layout-7']
815 + ],
816 + ]
817 + );
818 +
819 + $this->add_responsive_control(
820 + 'king_addons_testimonial_whole_testimonial_gap_4',
821 + [
822 + 'label' => esc_html__('Space between Image and Title + Subtitle, Rating (px)', 'king-addons'),
823 + 'type' => Controls_Manager::NUMBER,
824 + 'min' => 0,
825 + 'step' => 1,
826 + 'default' => 20,
827 + 'selectors' => [
828 + '{{WRAPPER}} .king-addons-testimonial-layout-6 .king-addons-testimonial-content,
829 + {{WRAPPER}} .king-addons-testimonial-layout-7 .king-addons-testimonial-content' => 'gap: {{SIZE}}px;'
830 + ],
831 + 'condition' => [
832 + 'king_addons_testimonial_layout' => ['layout-6', 'layout-7']
833 + ],
834 + ]
835 + );
836 +
837 + $this->add_responsive_control(
838 + 'king_addons_testimonial_whole_testimonial_padding',
839 + [
840 + 'label' => esc_html__('Padding', 'king-addons'),
841 + 'type' => Controls_Manager::DIMENSIONS,
842 + 'size_units' => ['px', '%'],
843 + 'default' => [
844 + 'top' => 30,
845 + 'right' => 30,
846 + 'bottom' => 30,
847 + 'left' => 30,
848 + 'unit' => 'px',
849 + ],
850 + 'separator' => 'before',
851 + 'selectors' => [
852 + '{{WRAPPER}} .king-addons-testimonial-layout' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
853 + ]
854 + ]
855 + );
856 +
857 + $this->add_responsive_control(
858 + 'king_addons_testimonial_whole_testimonial_margin',
859 + [
860 + 'label' => esc_html__('Margin', 'king-addons'),
861 + 'type' => Controls_Manager::DIMENSIONS,
862 + 'size_units' => ['px', '%'],
863 + 'default' => [
864 + 'top' => 0,
865 + 'right' => 0,
866 + 'bottom' => 0,
867 + 'left' => 0,
868 + 'unit' => 'px',
869 + ],
870 + 'selectors' => [
871 + '{{WRAPPER}} .king-addons-testimonial-layout' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
872 + ]
873 + ]
874 + );
875 +
876 + $this->add_group_control(
877 + Group_Control_Box_Shadow::get_type(),
878 + [
879 + 'name' => 'king_addons_testimonial_whole_testimonial_box_shadow',
880 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-layout',
881 + 'fields_options' => [
882 + 'box_shadow' => [
883 + 'default' => [
884 + 'horizontal' => 0,
885 + 'vertical' => 3,
886 + 'blur' => 40,
887 + 'spread' => 0,
888 + 'color' => 'rgba(36, 36, 36, 0.1)',
889 + ],
890 + ],
891 + 'box_shadow_type' => [
892 + 'default' => 'yes',
893 + ],
894 + ],
895 + ]
896 + );
897 +
898 + $this->add_group_control(
899 + Group_Control_Border::get_type(),
900 + [
901 + 'name' => 'king_addons_testimonial_whole_testimonial_border',
902 + 'selector' => '{{WRAPPER}} .king-addons-testimonial-layout',
903 + 'fields_options' => [
904 + 'border' => [
905 + 'default' => 'none',
906 + ],
907 + ],
908 + ]
909 + );
910 +
911 + $this->add_responsive_control(
912 + 'king_addons_testimonial_whole_testimonial_border_radius',
913 + [
914 + 'label' => esc_html__('Border Radius', 'king-addons'),
915 + 'type' => Controls_Manager::DIMENSIONS,
916 + 'size_units' => ['px', '%'],
917 + 'default' => [
918 + 'top' => 8,
919 + 'right' => 8,
920 + 'bottom' => 8,
921 + 'left' => 8,
922 + 'unit' => 'px',
923 + ],
924 + 'selectors' => [
925 + '{{WRAPPER}} .king-addons-testimonial-layout' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
926 + ]
927 + ]
928 + );
929 +
930 + $this->end_controls_section();
931 +
932 + // quote symbol
933 + }
934 +
935 + protected function render(): void
936 + {
937 + $settings = Core::displaySettings($this);
938 +
939 + // Define allowed tags and attributes
940 + $allowed_tags = wp_kses_allowed_html('post');
941 + $allowed_tags['img']['srcset'] = true; // Allow srcset attribute for img tag
942 + $allowed_tags['img']['sizes'] = true; // Allow sizes attribute for img tag
943 + $allowed_tags['img']['decoding'] = true; // Allow decoding attribute for img tag
944 + $allowed_tags['img']['loading'] = true; // Allow loading attribute for img tag. It is for the lazy loading possibility.
945 +
946 + $layout = $settings['king_addons_testimonial_layout'];
947 + $title = $settings['king_addons_testimonial_title'];
948 + $subtitle = $settings['king_addons_testimonial_subtitle'];
949 + $description = $settings['king_addons_testimonial_description'];
950 +
951 + echo '<div class="king-addons-testimonial-layout king-addons-testimonial-' . esc_attr($layout) . '">';
952 +
953 + if ($layout === 'layout-1') {
954 +
955 + $this->renderImage($settings, $allowed_tags);
956 +
957 + echo '<div class="king-addons-testimonial-content">';
958 +
959 + $this->renderDescription($description);
960 +
961 + $this->renderStars($settings);
962 +
963 + $this->renderPerson($title, $subtitle);
964 +
965 + echo '</div>';
966 + }
967 +
968 + if ($layout === 'layout-2') {
969 +
970 + echo '<div class="king-addons-testimonial-content">';
971 +
972 + $this->renderDescription($description);
973 +
974 + $this->renderPerson($title, $subtitle);
975 +
976 + $this->renderStars($settings);
977 +
978 + echo '</div>';
979 +
980 + $this->renderImage($settings, $allowed_tags);
981 + }
982 +
983 + if ($layout === 'layout-3') {
984 +
985 + $this->renderDescription($description);
986 +
987 + $this->renderImage($settings, $allowed_tags);
988 +
989 + $this->renderPerson($title, $subtitle);
990 +
991 + $this->renderStars($settings);
992 +
993 + }
994 +
995 + if ($layout === 'layout-4') {
996 +
997 + $this->renderImage($settings, $allowed_tags);
998 +
999 + echo '<div class="king-addons-testimonial-content">';
1000 +
1001 + $this->renderDescription($description);
1002 +
1003 + $this->renderStars($settings);
1004 +
1005 + $this->renderPerson($title, $subtitle);
1006 +
1007 + echo '</div>';
1008 + }
1009 +
1010 + if ($layout === 'layout-5') {
1011 +
1012 + echo '<div class="king-addons-testimonial-content">';
1013 +
1014 + $this->renderDescription($description);
1015 +
1016 + $this->renderStars($settings);
1017 +
1018 + $this->renderPerson($title, $subtitle);
1019 +
1020 + echo '</div>';
1021 +
1022 + $this->renderImage($settings, $allowed_tags);
1023 + }
1024 +
1025 + if ($layout === 'layout-6') {
1026 +
1027 + $this->renderDescription($description);
1028 +
1029 + echo '<div class="king-addons-testimonial-content">';
1030 +
1031 + $this->renderImage($settings, $allowed_tags);
1032 +
1033 + echo '<div class="king-addons-testimonial-content-inner">';
1034 +
1035 + $this->renderPerson($title, $subtitle);
1036 +
1037 + $this->renderStars($settings);
1038 +
1039 + echo '</div>';
1040 +
1041 + echo '</div>';
1042 + }
1043 +
1044 + if ($layout === 'layout-7') {
1045 +
1046 + echo '<div class="king-addons-testimonial-content">';
1047 +
1048 + $this->renderImage($settings, $allowed_tags);
1049 +
1050 + echo '<div class="king-addons-testimonial-content-inner">';
1051 +
1052 + $this->renderPerson($title, $subtitle);
1053 +
1054 + $this->renderStars($settings);
1055 +
1056 + echo '</div>';
1057 +
1058 + echo '</div>';
1059 +
1060 + $this->renderDescription($description);
1061 + }
1062 +
1063 + if ($layout === 'layout-8') {
1064 +
1065 + $this->renderImage($settings, $allowed_tags);
1066 +
1067 + echo '<div class="king-addons-testimonial-content">';
1068 +
1069 + $this->renderDescription($description);
1070 +
1071 + $this->renderStars($settings);
1072 +
1073 + $this->renderPerson($title, $subtitle);
1074 +
1075 + echo '</div>';
1076 + }
1077 +
1078 + echo '</div>';
1079 +
1080 + }
1081 +
1082 + public function renderImage($settings, $allowed_tags): void
1083 + {
1084 + if ($settings['king_addons_testimonial_image_switcher'] == 'yes') {
1085 + $image = Group_Control_Image_Size::get_attachment_image_html($settings, 'king_addons_testimonial_image_size', 'king_addons_testimonial_image');
1086 + echo '<div class="king-addons-testimonial-image">';
1087 + echo wp_kses($image, $allowed_tags);
1088 + echo '</div>';
1089 + }
1090 + }
1091 +
1092 + public function renderPerson($title, $subtitle): void
1093 + {
1094 + echo '<div class="king-addons-testimonial-person-wrapper">';
1095 +
1096 + echo '<div class="king-addons-testimonial-title">';
1097 + echo esc_html($title);
1098 + echo '</div>';
1099 +
1100 + echo '<div class="king-addons-testimonial-subtitle">';
1101 + echo esc_html($subtitle);
1102 + echo '</div>';
1103 +
1104 + echo '</div>';
1105 + }
1106 +
1107 + public function renderDescription($description): void
1108 + {
1109 + echo '<div class="king-addons-testimonial-description">';
1110 + echo wp_kses_post($description);
1111 + echo '</div>';
1112 + }
1113 +
1114 + public function renderStars($settings): void
1115 + {
1116 + if ($settings['king_addons_testimonial_rating_switcher'] == 'yes') {
1117 + echo '<div class="king-addons-testimonial-stars">';
1118 + echo '<div class="king-addons-testimonial-rating-general">';
1119 + $this->renderRating();
1120 + echo '</div>';
1121 + echo '</div>';
1122 + }
1123 + }
1124 +
1125 + protected function get_rating_value(): float
1126 + {
1127 + $initial_value = $this->get_rating_scale();
1128 + $rating_value = $this->get_settings_for_display('king_addons_testimonial_rating_value');
1129 +
1130 + if ('' === $rating_value) {
1131 + $rating_value = $initial_value;
1132 + }
1133 +
1134 + $rating_value = floatval($rating_value);
1135 +
1136 + return round($rating_value, 2);
1137 + }
1138 +
1139 + protected function get_rating_scale(): int
1140 + {
1141 + return intval($this->get_settings_for_display('king_addons_testimonial_rating_scale')['size']);
1142 + }
1143 +
1144 + protected function get_icon_marked_width($icon_index): string
1145 + {
1146 + $rating_value = $this->get_rating_value();
1147 +
1148 + $width = '0%';
1149 +
1150 + if ($rating_value >= $icon_index) {
1151 + $width = '100%';
1152 + } elseif (intval(ceil($rating_value)) === $icon_index) {
1153 + $width = ($rating_value - ($icon_index - 1)) * 100 . '%';
1154 + }
1155 +
1156 + return $width;
1157 + }
1158 +
1159 + protected function get_icon_markup(): string
1160 + {
1161 + $icon = $this->get_settings_for_display('king_addons_testimonial_rating_icon');
1162 + $rating_scale = $this->get_rating_scale();
1163 +
1164 + ob_start();
1165 +
1166 + for ($index = 1; $index <= $rating_scale; $index++) {
1167 + $this->add_render_attribute('icon_marked_' . $index, [
1168 + 'class' => 'king-addons-testimonial-icon-wrapper king-addons-testimonial-icon-marked',
1169 + ]);
1170 +
1171 + $icon_marked_width = $this->get_icon_marked_width($index);
1172 +
1173 + if ('100%' !== $icon_marked_width) {
1174 + $this->add_render_attribute('icon_marked_' . $index, [
1175 + 'style' => '--king-addons-testimonial-rating-icon-marked-width: ' . $icon_marked_width . ';',
1176 + ]);
1177 + }
1178 + ?>
1179 + <div class="king-addons-testimonial-icon">
1180 + <div <?php $this->print_render_attribute_string('icon_marked_' . $index); ?>>
1181 + <?php echo Icons_Manager::try_get_icon_html($icon, ['aria-hidden' => 'true']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1182 + </div>
1183 + <div class="king-addons-testimonial-icon-wrapper king-addons-testimonial-icon-unmarked">
1184 + <?php echo Icons_Manager::try_get_icon_html($icon, ['aria-hidden' => 'true']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1185 + </div>
1186 + </div>
1187 + <?php
1188 + }
1189 +
1190 + return ob_get_clean();
1191 + }
1192 +
1193 + protected function renderRating(): void
1194 + {
1195 + $this->add_render_attribute('widget', [
1196 + 'class' => 'king-addons-testimonial-rating',
1197 + 'itemtype' => 'https://schema.org/Rating',
1198 + 'itemscope' => '',
1199 + 'itemprop' => 'reviewRating',
1200 + ]);
1201 +
1202 + $this->add_render_attribute('widget_wrapper', [
1203 + 'class' => 'king-addons-testimonial-rating-wrapper',
1204 + 'itemprop' => 'ratingValue',
1205 + 'content' => $this->get_rating_value(),
1206 + 'role' => 'img',
1207 + /* translators: %1$s is rating value, %2$s is rating scale */
1208 + 'aria-label' => sprintf(esc_html__('Rated %1$s out of %2$s', 'king-addons'),
1209 + $this->get_rating_value(),
1210 + $this->get_rating_scale()
1211 + ),
1212 + ]);
1213 + ?>
1214 + <div <?php $this->print_render_attribute_string('widget'); ?>>
1215 + <meta itemprop="worstRating" content="0">
1216 + <meta itemprop="bestRating"
1217 + content="<?php echo $this->get_rating_scale(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1218 + ?>">
1219 + <div <?php $this->print_render_attribute_string('widget_wrapper'); ?>>
1220 + <?php echo $this->get_icon_markup(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1221 + ?>
1222 + </div>
1223 + </div>
1224 + <?php
1225 + }
1226 +}