Passed
Push — master ( 197c27...f2cc15 )
by Paul
22:24 queued 07:48
created

FormWidget::settings_basic()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 46
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 37
c 0
b 0
f 0
dl 0
loc 46
ccs 0
cts 46
cp 0
rs 9.328
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Elementor\Widgets;
4
5
use GeminiLabs\SiteReviews\Integrations\Elementor\Widget;
6
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode;
7
8
class FormWidget extends Widget
9
{
10
    /**
11
     * @return string
12
     */
13
    public function get_shortcode()
14
    {
15
        return SiteReviewsFormShortcode::class;
16
    }
17
18
    public function get_title()
19
    {
20
        return _x('Submit a Review', 'admin-text', 'site-reviews');
21
    }
22
23
    protected function settings_basic()
24
    {
25
        $options = [
26
            'assigned_posts' => [
27
                'default' => '',
28
                'label' => _x('Assign Reviews to a Page', 'admin-text', 'site-reviews'),
29
                'label_block' => true,
30
                'options' => $this->assigned_posts_options(),
31
                'type' => \Elementor\Controls_Manager::SELECT2,
32
            ],
33
            'assigned_posts_custom' => [
34
                'condition' => ['assigned_posts' => 'custom'],
35
                'description' => _x('Separate with commas.', 'admin-text', 'site-reviews'),
36
                'label_block' => true,
37
                'placeholder' => _x('Enter the Post IDs', 'admin-text', 'site-reviews'),
38
                'show_label' => false,
39
                'type' => \Elementor\Controls_Manager::TEXT,
40
            ],
41
            'assigned_terms' => [
42
                'default' => '',
43
                'label' => _x('Assign Reviews to a Category', 'admin-text', 'site-reviews'),
44
                'label_block' => true,
45
                'multiple' => true,
46
                'options' => $this->assigned_terms_options(),
47
                'type' => \Elementor\Controls_Manager::SELECT2,
48
            ],
49
            'assigned_users' => [
50
                'default' => '',
51
                'label' => _x('Assign Reviews to a User', 'admin-text', 'site-reviews'),
52
                'label_block' => true,
53
                'multiple' => true,
54
                'options' => $this->assigned_users_options(),
55
                'type' => \Elementor\Controls_Manager::SELECT2,
56
            ],
57
        ];
58
        $hideOptions = $this->get_shortcode_instance()->getHideOptions();
59
        foreach ($hideOptions as $key => $label) {
60
            $separator = $key === key(array_slice($hideOptions, 0, 1)) ? 'before' : 'default';
61
            $options['hide-'.$key] = [
62
                'label' => $label,
63
                'separator' => $separator,
64
                'return_value' => '1',
65
                'type' => \Elementor\Controls_Manager::SWITCHER,
66
            ];
67
        }
68
        return $options;
69
    }
70
}
71