Passed
Push — develop ( 39ad60...0ca1de )
by Paul
14:09
created

BricksSiteReviewsSummary::designConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Bricks\Elements;
4
5
use GeminiLabs\SiteReviews\Helpers\Arr;
6
use GeminiLabs\SiteReviews\Integrations\Bricks\BricksElement;
7
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsSummaryShortcode;
8
9
class BricksSiteReviewsSummary extends BricksElement
10
{
11
    public function designConfig(): array
12
    {
13
        return [
14
            'style_align' => [
15
                'exclude' => ['stretch', 'auto'],
16
                'group' => 'design',
17
                'inline' => true,
18
                'label' => esc_html__('Align', 'bricks'),
19
                'rerender' => true,
20
                'tab' => 'style',
21
                'themeStyle' => true,
22
                'type' => 'align-items',
23
            ],
24
        ];
25
    }
26
27
    public function elementConfig(): array
28
    {
29
        $controls = parent::elementConfig();
30
        $controls = Arr::insertBefore('text', $controls, [
31
            'text_notice' => [
32
                'content' => esc_html_x('The recommended way to change these values is to use the Site Reviews → Settings → Strings page.', 'admin-text', 'site-reviews'),
33
                'group' => 'text',
34
                'tab' => 'content',
35
                'type' => 'info',
36
            ],
37
        ]);
38
        return $controls;
39
    }
40
41
    public function render()
42
    {
43
        if (!$this->shortcodeInstance()->hasVisibleFields($this->settings)) {
44
            $this->render_element_placeholder([
45
                'title' => esc_html_x('You have hidden all of the fields.', 'admin-text', 'site-reviews'),
46
            ]);
47
            return;
48
        }
49
        parent::render();
50
    }
51
52
    public static function shortcodeClass(): string
53
    {
54
        return SiteReviewsSummaryShortcode::class;
55
    }
56
}
57