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

Hooks   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
eloc 17
dl 0
loc 36
rs 10
c 1
b 0
f 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 3
A isInstalled() 0 3 1
A version() 0 6 2
A supportedVersion() 0 3 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Flatsome;
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('Flatsome');
16
            return;
17
        }
18
        $this->hook(Controller::class, [
19
            ['printInlineScripts', 'ux_builder_enqueue_scripts'],
20
            ['printInlineStyles', 'ux_builder_enqueue_scripts'],
21
            ['registerShortcodes', 'init'],
22
            ['searchAssignedPosts', 'wp_ajax_ux_builder_search_posts', 1],
23
            ['searchAssignedUsers', 'wp_ajax_ux_builder_search_posts', 2],
24
        ]);
25
    }
26
27
    protected function isInstalled(): bool
28
    {
29
        return 'flatsome' === wp_get_theme(get_template())->get('TextDomain');
30
    }
31
32
    protected function supportedVersion(): string
33
    {
34
        return '3.19.0';
35
    }
36
37
    protected function version(): string
38
    {
39
        if ($this->isInstalled()) {
40
            return (string) wp_get_theme(get_template())->get('Version');
41
        }
42
        return '';
43
    }
44
}
45