CoreSecurity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A remove_wp_ver_css_js() 0 7 2
A init() 0 10 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 CoreSecurity implements Initializable
15
{
16
    /**
17
     * Initialize module (perform any tasks that should be done init hook).
18
     */
19
    public function init()
20
    {
21
        // Remove the WordPress version from the <head> tag
22
        add_filter('the_generator', '__return_empty_string');
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('the_generator', '__return_empty_string');
Loading history...
23
        // remove really simple discovery link
24
        remove_action('wp_head', 'rsd_link');
0 ignored issues
show
Bug introduced by
The function remove_action 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

24
        /** @scrutinizer ignore-call */ 
25
        remove_action('wp_head', 'rsd_link');
Loading history...
25
26
        // remove version from assets url.
27
        add_filter('style_loader_src', [$this, 'remove_wp_ver_css_js'], 9999);
28
        add_filter('script_loader_src', [$this, 'remove_wp_ver_css_js'], 9999);
29
    }
30
31
    /**
32
     * remove version from assets url.
33
     *
34
     * @param $src
35
     *
36
     * @return string
37
     */
38
    public function remove_wp_ver_css_js($src)
39
    {
40
        if (\strpos($src, 'ver=' . get_bloginfo('version'))) {
0 ignored issues
show
Bug introduced by
The function get_bloginfo 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

40
        if (\strpos($src, 'ver=' . /** @scrutinizer ignore-call */ get_bloginfo('version'))) {
Loading history...
41
            $src = remove_query_arg('ver', $src);
0 ignored issues
show
Bug introduced by
The function remove_query_arg 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

41
            $src = /** @scrutinizer ignore-call */ remove_query_arg('ver', $src);
Loading history...
42
        }
43
44
        return $src;
45
    }
46
}
47