WordPress_Security_Txt_Activator::activate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 16
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Fired during plugin activation
5
 *
6
 * @link       https://github.com/austinheap/wordpress-security-txt
7
 * @since      1.0.0
8
 *
9
 * @package    WordPress_Security_Txt
10
 * @subpackage WordPress_Security_Txt/includes
11
 */
12
13
/**
14
 * Fired during plugin activation.
15
 *
16
 * This class defines all code necessary to run during the plugin's activation.
17
 *
18
 * @since      1.0.0
19
 * @package    WordPress_Security_Txt
20
 * @subpackage WordPress_Security_Txt/includes
21
 * @author     Austin Heap <[email protected]>
22
 */
23
class WordPress_Security_Txt_Activator
24
{
25
26
    /**
27
     * Short Description. (use period)
28
     *
29
     * Long Description.
30
     *
31
     * @since    1.0.0
32
     */
33
    public static function activate()
34
    {
35
        require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-wordpress-security-txt-admin.php';
0 ignored issues
show
Bug introduced by
The function plugin_dir_path 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

35
        require_once /** @scrutinizer ignore-call */ plugin_dir_path(dirname(__FILE__)) . 'admin/class-wordpress-security-txt-admin.php';
Loading history...
36
37
        flush_rewrite_rules();
0 ignored issues
show
Bug introduced by
The function flush_rewrite_rules 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

37
        /** @scrutinizer ignore-call */ 
38
        flush_rewrite_rules();
Loading history...
38
39
        $opts    = [];
40
        $options = WordPress_Security_Txt_Admin::get_options_list();
41
42
        foreach ($options as $option) {
43
            $opts[ $option[0] ] = $option[2];
44
        }
45
46
        update_option('wordpress-security-txt-options', $opts);
0 ignored issues
show
Bug introduced by
The function update_option 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

46
        /** @scrutinizer ignore-call */ 
47
        update_option('wordpress-security-txt-options', $opts);
Loading history...
47
48
        WordPress_Security_Txt::event(__FUNCTION__);
49
    }
50
}
51