Test Failed
Push — develop ( 11959d...0f24e8 )
by Paul
09:06
created

ElementorSiteReviews::transformControl()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 20
rs 9.7998
cc 3
nc 2
nop 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Elementor\Widgets;
4
5
use Elementor\Controls_Manager;
6
use Elementor\Group_Control_Typography;
7
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
8
9
class ElementorSiteReviews extends ElementorWidget
10
{
11
    public function get_icon(): string
12
    {
13
        return 'eicon-glsr-reviews';
14
    }
15
16
    public static function shortcodeClass(): string
17
    {
18
        return SiteReviewsShortcode::class;
19
    }
20
21
    protected function styleConfig(): array
22
    {
23
        return [
24
            'style_align' => [
25
                'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'),
26
                'label_block' => false,
27
                'default' => 'left',
28
                'options' => [
29
                    'left' => [
30
                        'icon' => 'eicon-flex eicon-align-start-h',
31
                        'title' => esc_html_x('Start', 'admin-text', 'site-reviews'),
32
                    ],
33
                    'center' => [
34
                        'icon' => 'eicon-flex eicon-align-center-h',
35
                        'title' => esc_html_x('Center', 'admin-text', 'site-reviews'),
36
                    ],
37
                    'right' => [
38
                        'icon' => 'eicon-flex eicon-align-end-h',
39
                        'title' => esc_html_x('End', 'admin-text', 'site-reviews'),
40
                    ],
41
                ],
42
                'prefix_class' => 'items-justified-',
43
                'selectors' => [
44
                    '{{WRAPPER}} .glsr-summary-text' => 'text-align: {{VALUE}};',
45
                ],
46
                'type' => Controls_Manager::CHOOSE,
47
            ],
48
            'style_row_gap' => [
49
                'is_responsive' => true,
50
                'label' => esc_html_x('Row Gap', 'admin-text', 'site-reviews'),
51
                'selectors' => [
52
                    '{{WRAPPER}}' => '--glsr-review-row-gap: {{SIZE}}{{UNIT}};',
53
                ],
54
                'size_units' => ['px', 'em', 'rem', 'custom'],
55
                'type' => Controls_Manager::SLIDER,
56
            ],
57
            'style_heading' => [
58
                'label' => esc_html_x('Heading', 'admin-text', 'site-reviews'),
59
                'selector' => '{{WRAPPER}} .glsr:not([data-theme]) h2, {{WRAPPER}} .glsr:not([data-theme]) h3, {{WRAPPER}} .glsr:not([data-theme]) h4',
60
                'type' => Group_Control_Typography::get_type(),
61
            ],
62
            'style_text' => [
63
                'label' => esc_html_x('Text', 'admin-text', 'site-reviews'),
64
                'selector' => '{{WRAPPER}} .glsr:not([data-theme])',
65
                'type' => Group_Control_Typography::get_type(),
66
            ],
67
            'style_rating_size' => [
68
                'is_responsive' => true,
69
                'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'),
70
                'selectors' => [
71
                    '{{WRAPPER}}' => '--glsr-review-star: {{SIZE}}{{UNIT}};',
72
                ],
73
                'size_units' => ['px', 'em', 'rem', 'custom'],
74
                'type' => Controls_Manager::SLIDER,
75
            ],
76
            'style_rating_color' => [
77
                'label' => esc_html_x('Star Color', 'admin-text', 'site-reviews'),
78
                'selectors' => [
79
                    '{{WRAPPER}} .glsr:not([data-theme])' => '--glsr-review-star-bg: {{VALUE}};',
80
                ],
81
                'type' => Controls_Manager::COLOR,
82
            ],
83
        ];
84
    }
85
86
    protected function transformControl(string $name, array $args): array
87
    {
88
        $control = parent::transformControl($name, $args);
89
        if ('pagination' === $name) {
90
            $icons = [
91
                'ajax' => 'eicon eicon-spinner',
92
                'loadmore' => 'eicon eicon-button',
93
                'true' => 'eicon eicon-redo',
94
            ];
95
            $control['label'] = _x('Pagination', 'admin-text', 'site-reviews');
96
            $control['label_block'] = false;
97
            $control['type'] = Controls_Manager::CHOOSE;
98
            foreach ($control['options'] as $key => $value) {
99
                $control['options'][$key] = [
100
                    'icon' => $icons[$key] ?? $icons['ajax'],
101
                    'title' => $value,
102
                ];
103
            }
104
        }
105
        return $control;
106
    }
107
}
108