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

Hooks::supportedVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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