Test Failed
Push — develop ( 1da57b...1707fa )
by Paul
07:25
created

Hooks   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 7
eloc 22
dl 0
loc 40
ccs 0
cts 24
cp 0
rs 10
c 2
b 2
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isInstalled() 0 3 1
A run() 0 20 3
A supportedVersion() 0 3 1
A version() 0 5 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Elementor;
4
5
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks;
6
7
class Hooks extends IntegrationHooks
8
{
9
    public function run(): void
10
    {
11
        if (!$this->isInstalled()) {
12
            return;
13
        }
14
        if (!$this->isVersionSupported()) {
15
            $this->notify('Elementor');
16
            return;
17
        }
18
        $this->hook(Controller::class, [
19
            ['filterElementorPublicInlineScript', 'site-reviews/enqueue/public/inline-script/after', 1],
20
            ['filterElementorStarRatingDefaults', 'site-reviews/defaults/star-rating/defaults'],
21
            ['filterGeneratedSchema', 'site-reviews/schema/generate'],
22
            ['parseElementCss', 'elementor/element/parse_css', 10, 2],
23
            ['registerElementorCategory', 'elementor/elements/categories_registered'],
24
            ['registerElementorWidgets', 'elementor/widgets/register'],
25
            ['registerInlineStyles', 'admin_enqueue_scripts', 20],
26
            ['registerInlineStyles', 'elementor/editor/after_enqueue_styles'],
27
            ['registerInlineStyles', 'elementor/preview/enqueue_styles'],
28
            ['registerScripts', 'elementor/editor/after_enqueue_scripts'],
29
        ]);
30
    }
31
32
    protected function isInstalled(): bool
33
    {
34
        return class_exists('Elementor\Plugin');
35
    }
36
37
    protected function supportedVersion(): string
38
    {
39
        return '3.19.0';
40
    }
41
42
    protected function version(): string
43
    {
44
        return defined('ELEMENTOR_VERSION')
45
            ? (string) \ELEMENTOR_VERSION
46
            : '';
47
    }
48
}
49