PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
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 / class-strong-password.php

class-strong-password.php in Defender Security – Malware Scanner, Login Security & Firewall 5.3.1, at src/model/setting/class-strong-password.php

103 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 * Handle strong password module.
4 *
5 * @package WP_Defender\Model\Setting
6 */
7
8 namespace WP_Defender\Model\Setting;
9
10 use Calotes\Model\Setting;
11
12 /**
13 * Model for strong password module.
14 */
15 class Strong_Password extends Setting {
16
17 /**
18 * Option name.
19 *
20 * @var string
21 */
22 protected $table = 'wd_strong_password_settings';
23
24 /**
25 * Feature status
26 *
27 * @defender_property
28 * @var bool
29 */
30 public $enabled = false;
31
32 /**
33 * List of user roles.
34 *
35 * @defender_property
36 * @var array
37 */
38 public $user_roles = array();
39
40 /**
41 * Default message.
42 *
43 * @defender_property
44 * @var string
45 */
46 public $message = '';
47
48 /**
49 * Check if the model is activated.
50 *
51 * @return bool
52 */
53 public function is_active(): bool {
54 return (bool) apply_filters(
55 'wd_strong_password_enable',
56 $this->enabled && count( $this->user_roles ) > 0
57 );
58 }
59
60 /**
61 * Initializes the object before loading.
62 *
63 * @return void
64 */
65 protected function before_load(): void {
66 $this->user_roles = $this->get_default_roles();
67 $this->message = $this->get_message();
68 }
69
70 /**
71 * Get applicable user roles.
72 */
73 protected function get_default_roles(): array {
74 if ( ! function_exists( 'get_editable_roles' ) ) {
75 return array( 'administrator' );
76 }
77
78 return array_keys( get_editable_roles() );
79 }
80
81 /**
82 * Get error message to show in ui.
83 *
84 * @return string
85 */
86 public function get_message(): string {
87 if ( empty( $this->message ) ) {
88 return $this->get_default_message();
89 }
90 return $this->message;
91 }
92
93 /**
94 * Get localized default message.
95 */
96 protected function get_default_message(): string {
97 return __(
98 "You are required to change your password because your password doesn't meet the strong password guidelines set by the administrator.",
99 'defender-security'
100 );
101 }
102 }
103