Test Failed
Push — develop ( 9873ab...1da57b )
by Paul
13:43
created

Hooks::isInstalled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Divi;
4
5
use GeminiLabs\SiteReviews\Hooks\AbstractHooks;
6
7
class Hooks extends AbstractHooks
8
{
9
    public function run(): void
10
    {
11
        if (!$this->isInstalled()) {
12
            return;
13
        }
14
        $this->hook(Controller::class, [
15
            ['filterDynamicAssets', 'et_dynamic_assets_modules_atf', 10, 2],
16
            ['filterPaginationLinks', 'site-reviews/paginate_links', 10, 2],
17
            ['registerDiviModules', 'divi_extensions_init'],
18
        ]);
19
        if ($this->isWooEnabled()) {
20
            $this->hook(Controller::class, [
21
                ['filterInlineWooStyles', 'site-reviews/enqueue/public/inline-styles'],
22
            ]);
23
        }
24
    }
25
26
    protected function isInstalled(): bool
27
    {
28
        return 'Divi' === wp_get_theme(get_template())->get('Name');
29
    }
30
31
    protected function isWooEnabled(): bool
32
    {
33
        return 'yes' === $this->option('integrations.woocommerce.enabled')
34
            && 'yes' === get_option('woocommerce_enable_reviews', 'yes')
35
            && class_exists('WooCommerce')
36
            && function_exists('WC');
37
    }
38
}
39