Completed
Branch new-addon-api (b7bde0)
by
unknown
18:29 queued 08:41
created

ThirdPartyPluginHandler::loadPlugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\addon\api;
4
5
use EventEspresso\core\services\request\RequestInterface;
6
7
class ThirdPartyPluginHandler
8
{
9
10
    /**
11
     * @var RequestInterface $request
12
     */
13
    private $request;
14
15
16
    /**
17
     * ThirdPartyPluginHandler constructor.
18
     *
19
     * @param RequestInterface $request
20
     */
21
    public function __construct(RequestInterface $request)
22
    {
23
        $this->request = $request;
24
    }
25
26
27
    public function loadPlugins()
28
    {
29
        $this->wpApiBasicAuth();
30
    }
31
32
33
    private function wpApiBasicAuth()
34
    {
35
        // if the WP API basic auth plugin isn't already loaded, load it now.
36
        // We want it for mobile apps. Just include the entire plugin
37
        // also, don't load the basic auth when a plugin is getting activated, because
38
        // it could be the basic auth plugin, and it doesn't check if its methods are already defined
39
        // and causes a fatal error
40
        if (($this->request->isWordPressApi() || $this->request->isApi())
41
            && ! $this->request->isActivation()
42
            && ! function_exists('json_basic_auth_handler')
43
            && ! function_exists('json_basic_auth_error')
44
        ) {
45
            include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php';
46
        }
47
    }
48
}
49