Test Failed
Push — develop ( c74868...df43c9 )
by Paul
09:13
created

Hooks::hasPluginsLoaded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 1
c 2
b 0
f 2
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Breakdance;
4
5
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks;
6
7
class Hooks extends IntegrationHooks
8
{
9
    public function hasPluginsLoaded(): bool
10
    {
11
        return true;
12
    }
13
14
    /**
15
     * @action plugins_loaded:0
16
     */
17
    public function onPluginsLoaded(): void
18
    {
19
        if (!$this->isInstalled()) {
20
            return;
21
        }
22
        if (!$this->isVersionSupported()) {
23
            $this->notify('Breakdance');
24
            return;
25
        }
26
        $this->hook(Controller::class, [
27
            ['interceptGetPostsQuery', 'breakdance_ajax_breakdance_get_posts', 1],
28
            ['interceptGetPostsQuery', 'wp_ajax_breakdance_get_posts', 1],
29
            ['interceptGetPostsQuery', 'wp_ajax_nopriv_breakdance_get_posts', 1],
30
            ['printInlineStyles', 'unofficial_i_am_kevin_geary_master_of_all_things_css_and_html'],
31
            ['registerDesignControls', 'init'],
32
            ['registerElements', 'breakdance_loaded', 5],
33
            ['registerRoutes', 'breakdance_loaded'],
34
        ]);
35
    }
36
37
    protected function isInstalled(): bool
38
    {
39
        return class_exists('Breakdance\Elements\Element')
40
            && function_exists('Breakdance\AJAX\get_nonce_for_ajax_requests')
41
            && function_exists('Breakdance\AJAX\get_nonce_key_for_ajax_requests')
42
            && function_exists('Breakdance\AJAX\register_handler')
43
            && function_exists('Breakdance\Elements\c')
44
            && function_exists('Breakdance\Elements\PresetSections\getPresetSection')
45
            && function_exists('Breakdance\Elements\registerCategory')
46
            && function_exists('Breakdance\Permissions\hasMinimumPermission');
47
    }
48
49
    protected function supportedVersion(): string
50
    {
51
        return '2.2.0';
52
    }
53
54
    protected function version(): string
55
    {
56
        return defined('__BREAKDANCE_VERSION')
57
            ? (string) \__BREAKDANCE_VERSION
0 ignored issues
show
Bug introduced by
The constant __BREAKDANCE_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
58
            : '';
59
    }
60
}
61