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

Hooks   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isInstalled() 0 3 1
A version() 0 6 2
A run() 0 19 3
A supportedVersion() 0 3 1
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