PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.1.0
Defender Security – Malware Scanner, Login Security & Firewall v3.1.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / model / setting / security-tweaks.php

security-tweaks.php in Defender Security – Malware Scanner, Login Security & Firewall 3.1.0, at src/model/setting/security-tweaks.php

107 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WP_Defender\Model\Setting;
4
5 use Calotes\Model\Setting;
6
7 class Security_Tweaks extends Setting {
8 public $table = 'hardener_settings';
9
10 /**
11 * Store a list of issues tweaks, as slug.
12 * @var array
13 */
14 public $issues = array();
15
16 /**
17 * Store a list of fixed tweaks, as slug.
18 * @var array
19 */
20 public $fixed = array();
21
22 /**
23 * Store a list of ignored tweaks, as slug.
24 * @var array
25 */
26 public $ignore = array();
27
28 /**
29 * Contains all the data generated by rules.
30 * @var array
31 */
32 public $data = array();
33
34 /**
35 * Last time visit into the hardener page.
36 * @var integer
37 */
38 public $last_seen;
39
40 /**
41 * Last notification sent out.
42 * @var integer
43 */
44 public $last_sent;
45
46 public $automate = false;
47
48 /**
49 * @param $slug
50 *
51 * @return bool
52 */
53 public function is_tweak_ignore( $slug ) {
54 // Empty ignored tweak is string on old versions, so change it to array.
55 if ( is_string( $this->ignore ) ) {
56 $this->ignore = empty( $this->ignore ) ? array() : array( $this->ignore );
57 $this->save();
58 }
59 return in_array( $slug, $this->ignore, true );
60 }
61
62 /**
63 * @param $as
64 * @param $slug
65 */
66 public function mark( $as, $slug ) {
67 foreach ( [ 'issues', 'fixed', 'ignore' ] as $list ) {
68 $arr = $this->$list;
69 $index = array_search( $slug, $arr, true );
70 if ( $index !== false ) {
71 unset( $arr[ $index ] );
72 }
73 $this->$list = $arr;
74 }
75 if ( \WP_Defender\Controller\Security_Tweaks::STATUS_RESTORE === $as ) {
76 $as = \WP_Defender\Controller\Security_Tweaks::STATUS_ISSUES;
77 }
78 $list = $this->{$as};
79 $list[] = $slug;
80 $this->{$as} = $list;
81 $this->save();
82 }
83
84 /**
85 * Define labels for settings key.
86 *
87 * @param string|null $key
88 *
89 * @return string|array|null
90 */
91 public function labels( $key = null ) {
92 $labels = array(
93 'data' => 'data',
94 'fixed' => __( 'Actioned', 'wpdef' ),
95 'issues' => __( 'Recommendations', 'wpdef' ),
96 'ignore' => __( 'Ignored', 'wpdef' ),
97 'automate' => 'automate',
98 );
99
100 if ( ! is_null( $key ) ) {
101 return $labels[ $key ] ?? null;
102 }
103
104 return $labels;
105 }
106 }
107