Test Failed
Push — develop ( c0d6f9...325b33 )
by Paul
08:37
created

Hooks::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 19
rs 9.7666
cc 3
nc 3
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Bricks;
4
5
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks;
6
use GeminiLabs\SiteReviews\Modules\Sanitizer;
7
8
class Hooks extends IntegrationHooks
9
{
10
    public function run(): void
11
    {
12
        if (!$this->isInstalled()) {
13
            return;
14
        }
15
        if (!$this->isVersionSupported()) {
16
            $this->notify('Bricks');
17
            return;
18
        }
19
        $this->hook(Controller::class, [
20
            ['filterBuilderI18n', 'bricks/builder/i18n'],
21
            ['filterSettingsMultiCheckbox', 'bricks/element/settings', 10, 2],
22
            ['filterSettingsPrefixedId', 'bricks/element/settings', 10, 2],
23
            ['printInlineStyles', 'wp_enqueue_scripts', 15],
24
            ['registerElements', 'init', 11],
25
            ['searchAssignedPosts', 'wp_ajax_bricks_glsr_assigned_posts'],
26
            ['searchAssignedTerms', 'wp_ajax_bricks_glsr_assigned_terms'],
27
            ['searchAssignedUsers', 'wp_ajax_bricks_glsr_assigned_users'],
28
            ['searchPostId', 'wp_ajax_bricks_glsr_post_id'],
29
        ]);
30
    }
31
32
    protected function isInstalled(): bool
33
    {
34
        return 'bricks' === wp_get_theme(get_template())->get('TextDomain');
35
    }
36
37
    protected function supportedVersion(): string
38
    {
39
        return '1.11';
40
    }
41
42
    protected function version(): string
43
    {
44
        if ($this->isInstalled()) {
45
            return (string) wp_get_theme(get_template())->get('Version');
46
        }
47
        return '';
48
    }
49
}
50