XmlrpcDisabled   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A disablePingbacks() 0 5 1
1
<?php
2
3
/*
4
 * Copyright (c) 2017 Salah Alkhwlani <[email protected]>
5
 *
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Yemenifree\WpSecurity\Modules;
11
12
use Yemenifree\WpSecurity\Interfaces\Initializable;
13
14
class XmlrpcDisabled implements Initializable
15
{
16
    /**
17
     * Initialize module (perform any tasks that should be done init hook).
18
     */
19
    public function init()
20
    {
21
        // Disable pingbacks
22
        add_filter('xmlrpc_methods', [$this, 'disablePingbacks']);
0 ignored issues
show
Bug introduced by
The function add_filter was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        add_filter('xmlrpc_methods', [$this, 'disablePingbacks']);
Loading history...
23
        // Disable all XML-RPC methods requiring authentication
24
        add_filter('xmlrpc_enabled', '__return_false');
25
    }
26
27
    /**
28
     * Remove pingback.ping from allowed/supported XML-RPC methods.
29
     *
30
     * @param array $methods
31
     *
32
     * @return array
33
     */
34
    public function disablePingbacks($methods)
35
    {
36
        unset($methods['pingback.ping']);
37
38
        return $methods;
39
    }
40
}
41