PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.0
Defender Security – Malware Scanner, Login Security & Firewall v6.2.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 / traits / security-tweaks-option.php

security-tweaks-option.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.0, at src/traits/security-tweaks-option.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle persistent storage of security tweak option.
4 *
5 * @package WP_Defender\Traits
6 */
7
8 namespace WP_Defender\Traits;
9
10 trait Security_Tweaks_Option {
11
12 /**
13 * Generic method to update security tweak site option.
14 *
15 * @param string $key Name of the security tweak option.
16 * @param mixed $value Value of the security tweak option.
17 *
18 * @return bool True if the value was updated, false otherwise.
19 */
20 public function update_option( $key, $value ) {
21 $option_name = self::OPTION_PREFIX . $this->slug;
22
23 $options = (array) get_site_option( $option_name, array() );
24
25 $options[ $key ] = $value;
26
27 return $this->update_all_option( $options );
28 }
29
30 /**
31 * Generic method to update all option value of specific security tweak.
32 *
33 * @param mixed $value Value of the security tweak option.
34 *
35 * @return bool True if the value was updated, false otherwise.
36 */
37 public function update_all_option( $value ) {
38 $option_name = self::OPTION_PREFIX . $this->slug;
39
40 return update_site_option( $option_name, $value );
41 }
42
43 /**
44 * Generic method to get security tweak site option value.
45 *
46 * @param string $key Name of the security tweak option.
47 *
48 * @return mixed Value of the security tweak option.
49 */
50 public function get_option( $key ) {
51 $options = $this->get_all_option();
52
53 return array_key_exists( $key, $options ) ? $options[ $key ] : null;
54 }
55
56 /**
57 * Generic method to get all option value of specific security tweak.
58 *
59 * @return mixed All value of the specific security tweak.
60 */
61 public function get_all_option() {
62 $option_name = self::OPTION_PREFIX . $this->slug;
63
64 return get_site_option( $option_name, array() );
65 }
66
67 /**
68 * Generic method to delete option of a specific security tweak.
69 *
70 * @return bool True if the option was deleted, false otherwise.
71 */
72 public function delete_all_option() {
73 $option_name = self::OPTION_PREFIX . $this->slug;
74
75 return delete_site_option( $option_name );
76 }
77 }
78