Passed
Push — develop ( c34e50...445d6d )
by Paul
06:42
created

SiteReviewsTinymce   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 62
dl 0
loc 95
ccs 0
cts 89
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B fields() 0 86 1
A shortcode() 0 3 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Tinymce;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Modules\Rating;
7
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
8
9
class SiteReviewsTinymce extends TinymceGenerator
10
{
11
    public function fields(): array
12
    {
13
        return [
14
            [
15
                'label' => esc_html_x('Assigned Pages', 'admin-text', 'site-reviews'),
16
                'name' => 'assigned_posts',
17
                'tooltip' => sprintf(esc_html_x('Limit reviews to those assigned to a Post ID. You may also enter %s to use the Post ID of the current page.', 'admin-text', 'site-reviews'), '"post_id"'),
18
                'type' => 'textbox',
19
            ],
20
            [
21
                'label' => esc_html_x('Assigned Categories', 'admin-text', 'site-reviews'),
22
                'name' => 'assigned_terms',
23
                'tooltip' => esc_html_x('Limit reviews to those assigned to a category. You may enter a Term ID or slug.', 'admin-text', 'site-reviews'),
24
                'type' => 'textbox',
25
            ],
26
            [
27
                'label' => esc_html_x('Assigned Users', 'admin-text', 'site-reviews'),
28
                'name' => 'assigned_users',
29
                'tooltip' => sprintf(esc_html_x('Limit reviews to those assigned to a User ID. You may also enter %s to use the ID of the logged-in user.', 'admin-text', 'site-reviews'), '"user_id"'),
30
                'type' => 'textbox',
31
            ],
32
            [
33
                'label' => esc_html_x('Terms Accepted', 'admin-text', 'site-reviews'),
34
                'name' => 'terms',
35
                'options' => $this->shortcode->options('terms'),
36
                'tooltip' => esc_html_x('Limit Reviews by Accepted Terms', 'admin-text', 'site-reviews'),
37
                'type' => 'listbox',
38
            ],
39
            [
40
                'label' => esc_html_x('Review Type', 'admin-text', 'site-reviews'),
41
                'name' => 'type',
42
                'options' => $this->shortcode->options('type'),
43
                'tooltip' => esc_html_x('Limit Reviews by review type', 'admin-text', 'site-reviews'),
44
                'type' => 'listbox',
45
            ],
46
            [
47
                'label' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'),
48
                'name' => 'rating',
49
                'options' => glsr(Rating::class)->optionsArray(),
50
                'tooltip' => esc_html_x('The minimum rating to display (default: 1 star)', 'admin-text', 'site-reviews'),
51
                'type' => 'listbox',
52
            ],
53
            [
54
                'label' => esc_html_x('Display', 'admin-text', 'site-reviews'),
55
                'maxLength' => 5,
56
                'name' => 'display',
57
                'size' => 3,
58
                'text' => '10',
59
                'tooltip' => esc_html_x('The number of reviews to display per page (default: 10)', 'admin-text', 'site-reviews'),
60
                'type' => 'textbox',
61
            ],
62
            [
63
                'label' => esc_html_x('Pagination', 'admin-text', 'site-reviews'),
64
                'name' => 'pagination',
65
                'options' => $this->shortcode->options('pagination'),
66
                'type' => 'listbox',
67
            ],
68
            [
69
                'label' => esc_html_x('Schema', 'admin-text', 'site-reviews'),
70
                'name' => 'schema',
71
                'options' => [
72
                    '' => esc_html_x('Disabled', 'admin-text', 'site-reviews'),
73
                    'true' => esc_html_x('Enabled', 'admin-text', 'site-reviews'),
74
                ],
75
                'tooltip' => esc_html_x('Rich snippets are disabled by default.', 'admin-text', 'site-reviews'),
76
                'type' => 'listbox',
77
            ],
78
            [
79
                'columns' => 2,
80
                'items' => $this->hideOptions(),
81
                'label' => esc_html_x('Hide', 'admin-text', 'site-reviews'),
82
                'layout' => 'grid',
83
                'spacing' => 5,
84
                'type' => 'container',
85
            ],
86
            [
87
                'label' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'),
88
                'name' => 'id',
89
                'tooltip' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'),
90
                'type' => 'textbox',
91
            ],
92
            [
93
                'label' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'),
94
                'name' => 'class',
95
                'tooltip' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'),
96
                'type' => 'textbox',
97
            ],
98
        ];
99
    }
100
101
    public function shortcode(): ShortcodeContract
102
    {
103
        return glsr(SiteReviewsShortcode::class);
1 ignored issue
show
Bug Best Practice introduced by
The expression return glsr(GeminiLabs\S...eviewsShortcode::class) could return the type callable which is incompatible with the type-hinted return GeminiLabs\SiteReviews\Contracts\ShortcodeContract. Consider adding an additional type-check to rule them out.
Loading history...
104
    }
105
}
106