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 / password-protection.php

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

89 lines 1.8 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 Password_Protection extends Setting {
8 public $table = 'wd_password_protection_settings';
9
10 /**
11 * Feature status
12 *
13 * @defender_property
14 * @var bool
15 */
16 public $enabled = false;
17
18 /**
19 * @defender_property
20 * @var array
21 */
22 public $user_roles = array();
23
24 /**
25 * @defender_property
26 * @var array
27 */
28 public $pwned_actions = array();
29
30 /**
31 * @return array
32 */
33 public function get_default_values() {
34
35 return array(
36 'message' => __( 'You are required to change your password because the password you are using exists on database breach records.', 'wpdef' ),
37 );
38 }
39
40 protected function before_load() {
41 $default_values = $this->get_default_values();
42 // Default we will load all rules.
43 if ( function_exists( 'get_editable_roles' ) ) {
44 // We only need this inside admin, no need to load the user.php everywhere.
45 $this->user_roles = array_keys( get_editable_roles() );
46 } else {
47 // Define defaults user roles.
48 $this->user_roles = array( 'administrator' );
49 }
50 $this->pwned_actions = array(
51 'force_change_message' => $default_values['message'],
52 );
53 }
54
55 /**
56 * Define labels for settings key.
57 *
58 * @param string|null $key
59 *
60 * @return string|array|null
61 */
62 public function labels( $key = null ) {
63 $labels = array(
64 'enabled' => __( 'Pwned Passwords', 'wpdef' ),
65 'pwned_actions' => __( 'Force password change', 'wpdef' ),
66 'user_roles' => __( 'User Roles', 'wpdef' ),
67 );
68
69 if ( ! is_null( $key ) ) {
70 return $labels[ $key ] ?? null;
71 }
72
73 return $labels;
74 }
75
76 /**
77 * Check if the model is activated.
78 *
79 * @return bool
80 */
81 public function is_active() {
82
83 return apply_filters(
84 'wd_password_protection_enable',
85 $this->enabled && count( $this->user_roles ) > 0
86 );
87 }
88 }
89