UploadZipSecurity   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 3 1
A disabled_upload_zip_files() 0 7 3
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\Loadable;
13
14
class UploadZipSecurity implements Loadable
15
{
16
    /**
17
     * Load module (perform any tasks that should be done immediately on plugin load).
18
     */
19
    public function load()
20
    {
21
        add_action('check_admin_referer', [$this, 'disabled_upload_zip_files'], 99, 2);
0 ignored issues
show
Bug introduced by
The function add_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

21
        /** @scrutinizer ignore-call */ 
22
        add_action('check_admin_referer', [$this, 'disabled_upload_zip_files'], 99, 2);
Loading history...
22
    }
23
24
    /**
25
     * Disabled upload zip files ( plugins & themes ) via admin account.
26
     *
27
     * @param $action
28
     * @param $result
29
     */
30
    public function disabled_upload_zip_files($action, $result)
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed. ( Ignorable by Annotation )

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

30
    public function disabled_upload_zip_files($action, /** @scrutinizer ignore-unused */ $result)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
        if (!\in_array($action, ['theme-upload', 'plugin-upload'])) {
33
            return;
34
        }
35
36
        wp_die($action === 'theme-upload' ? __('Sorry, you are not allowed to install plugins on this site.') : __('Sorry, you are not allowed to install themes on this site.'));
0 ignored issues
show
Bug introduced by
The function __ 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

36
        wp_die($action === 'theme-upload' ? /** @scrutinizer ignore-call */ __('Sorry, you are not allowed to install plugins on this site.') : __('Sorry, you are not allowed to install themes on this site.'));
Loading history...
Bug introduced by
The function wp_die 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

36
        /** @scrutinizer ignore-call */ 
37
        wp_die($action === 'theme-upload' ? __('Sorry, you are not allowed to install plugins on this site.') : __('Sorry, you are not allowed to install themes on this site.'));
Loading history...
37
    }
38
}
39