Completed
Pull Request — master (#14)
by Gorka
12:44 queued 10:15
created

Kernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
registerClasses() 0 1 ?
A __construct() 0 12 1
A register() 0 6 1
A xmlrpc() 0 8 3
A adminHead() 0 4 1
A removeOrderFromPostAttributesBox() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the WPFoundation library.
5
 *
6
 * Copyright (c) 2015-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\WPFoundation;
15
16
/**
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
abstract class Kernel
20
{
21
    abstract public function registerClasses() : void;
22
23
    public function __construct()
24
    {
25
        $this->register();
26
        $this->xmlrpc();
27
28
        add_action('admin_head', [$this, 'adminHead']);
0 ignored issues
show
Unused Code introduced by
The call to the function add_action() seems unnecessary as the function has no side-effects.
Loading history...
29
30
        add_theme_support('post-thumbnails');
0 ignored issues
show
Unused Code introduced by
The call to the function add_theme_support() seems unnecessary as the function has no side-effects.
Loading history...
31
32
        add_filter('theme_page_templates', [$this, 'templates']);
0 ignored issues
show
Unused Code introduced by
The call to the function add_filter() seems unnecessary as the function has no side-effects.
Loading history...
33
        add_filter('timber_context', [$this, 'context']);
0 ignored issues
show
Unused Code introduced by
The call to the function add_filter() seems unnecessary as the function has no side-effects.
Loading history...
34
    }
35
36
    private function register() : void
37
    {
38
        $this->registerClasses();
39
        new AuthorizationChecker();
40
        new Translator();
41
    }
42
43
    private function xmlrpc() : void
44
    {
45
        $xmlrpc = !defined('XMLRPC_ENABLED') || XMLRPC_ENABLED === true
46
            ? '__return_true'
47
            : '__return_false';
48
49
        add_filter('xmlrpc_enabled', $xmlrpc);
0 ignored issues
show
Unused Code introduced by
The call to the function add_filter() seems unnecessary as the function has no side-effects.
Loading history...
50
    }
51
52
    protected function adminHead() : void
53
    {
54
        $this->removeOrderFromPostAttributesBox();
55
    }
56
57
    public function removeOrderFromPostAttributesBox() : void
58
    {
59
        echo '<style>label[for="menu_order"], input[name="menu_order"] {display:none;}</style>';
60
    }
61
}
62