| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handles global ip lockout settings. |
| 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 global ip lockout settings. |
| 14 |
*/ |
| 15 |
class Global_Ip_Lockout extends Setting { |
| 16 |
|
| 17 |
/** |
| 18 |
* Option name. |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
protected $table = 'wd_global_ip_settings'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Is module enabled. |
| 26 |
* |
| 27 |
* @var bool |
| 28 |
* @defender_property |
| 29 |
*/ |
| 30 |
public $enabled = false; |
| 31 |
|
| 32 |
/** |
| 33 |
* Allow self unlock? |
| 34 |
* |
| 35 |
* @var bool |
| 36 |
* @defender_property |
| 37 |
*/ |
| 38 |
public bool $allow_self_unlock = true; |
| 39 |
|
| 40 |
/** |
| 41 |
* Table column for autosync. |
| 42 |
* |
| 43 |
* @var bool |
| 44 |
* @defender_property |
| 45 |
*/ |
| 46 |
public $blocklist_autosync = false; |
| 47 |
|
| 48 |
/** |
| 49 |
* Validation rules. |
| 50 |
* |
| 51 |
* @var array |
| 52 |
*/ |
| 53 |
protected $rules = array( |
| 54 |
array( array( 'enabled', 'blocklist_autosync', 'allow_self_unlock' ), 'boolean' ), |
| 55 |
); |
| 56 |
|
| 57 |
/** |
| 58 |
* Define settings labels. |
| 59 |
* |
| 60 |
* @return array |
| 61 |
*/ |
| 62 |
public function labels(): array { |
| 63 |
return array( |
| 64 |
'enabled' => self::get_module_name(), |
| 65 |
'blocklist_autosync' => esc_html__( 'Permanently Blocked IPs', 'defender-security' ), |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get the module name. |
| 71 |
* |
| 72 |
* @return string The module name. |
| 73 |
*/ |
| 74 |
public static function get_module_name(): string { |
| 75 |
return esc_html__( 'Custom IP List', 'defender-security' ); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Get the module state based on the given flag. |
| 80 |
* |
| 81 |
* @param bool $flag The flag indicating the module state. |
| 82 |
* |
| 83 |
* @return string The module state, either 'active' or 'inactive'. |
| 84 |
*/ |
| 85 |
public static function get_module_state( $flag ): string { |
| 86 |
return $flag ? esc_html__( 'active', 'defender-security' ) : esc_html__( 'inactive', 'defender-security' ); |
| 87 |
} |
| 88 |
} |
| 89 |
|