Test Failed
Push — develop ( 6a684d...5c54e5 )
by Paul
08:51
created

Hooks::isInstalled()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 4
nc 4
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\ProfilePress;
4
5
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks;
6
use GeminiLabs\SiteReviews\Integrations\ProfilePress\Controllers\AccountController;
7
use GeminiLabs\SiteReviews\Integrations\ProfilePress\Controllers\Controller;
8
use GeminiLabs\SiteReviews\Integrations\ProfilePress\Controllers\DirectoryController;
9
use GeminiLabs\SiteReviews\Integrations\ProfilePress\Controllers\ProfileController;
10
11
class Hooks extends IntegrationHooks
12
{
13
    public function run(): void
14
    {
15
        $this->hook(Controller::class, [
16
            ['filterSettings', 'site-reviews/settings'],
17
            ['filterSettingsCallback', 'site-reviews/settings/sanitize', 10, 2],
18
            ['filterSubsubsub', 'site-reviews/integration/subsubsub'],
19
            ['renderNotice', 'admin_init'],
20
            ['renderSettings', 'site-reviews/settings/profilepress'],
21
        ]);
22
        if ($this->isInstalled()) {
23
            $this->hook(Controller::class, [
24
                ['filterProfileId', 'site-reviews/assigned_users/profile_id', 5],
25
            ]);
26
            $this->hook(DirectoryController::class, [
27
                ['registerProfileRatingShortcode', 'ppress_register_profile_shortcode'],
28
            ]);
29
        }
30
        if ($this->isEnabled()) {
31
            $this->hook(AccountController::class, [
32
                ['filterAccountTabs', 'ppress_myaccount_tabs'],
33
            ]);
34
            $this->hook(DirectoryController::class, [
35
                ['filterAvailableShortcodes', 'ppress_user_profile_available_shortcodes'],
36
                ['filterInlineStyles', 'site-reviews/enqueue/public/inline-styles'],
37
                ['filterMemberDirectoryArgs', 'ppress_member_directory_wp_user_args'],
38
                ['filterMemberDirectoryTheme', 'ppress_register_dnd_form_class', 10, 3],
39
                ['filterMetaBoxSettings', 'ppress_form_builder_meta_box_settings'],
40
                ['insertPreviewCss', 'wp_ajax_pp-builder-preview', 5],
41
                ['registerProfileBuilderField', 'admin_init'],
42
            ]);
43
            $this->hook(ProfileController::class, [
44
                ['filterInlineScript', 'site-reviews/enqueue/public/inline-script/after'],
45
                ['filterInlineStyles', 'site-reviews/enqueue/public/inline-styles'],
46
                ['filterProfileTabs', 'ppress_profile_tabs'],
47
                ['filterSavedTabs', 'ppress_dpf_saved_tabs'],
48
                ['renderReviewsTab', 'ppress_profile_tab_content_'.ProfileController::REVIEWS_TAB],
49
            ]);
50
        }
51
    }
52
53
    protected function isEnabled(): bool
54
    {
55
        return $this->isInstalled()
56
            && 'yes' === $this->option('integrations.profilepress.enabled');
57
    }
58
59
    protected function isInstalled(): bool
60
    {
61
        return function_exists('ppress_get_frontend_profile_url')
62
            && function_exists('ppress_post_content_has_shortcode')
63
            && function_exists('ppress_var_obj')
64
            && defined('PPRESS_VERSION_NUMBER');
65
    }
66
}
67