| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handles audit logging 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 audit logging settings. |
| 14 |
*/ |
| 15 |
class Audit_Logging extends Setting { |
| 16 |
|
| 17 |
/** |
| 18 |
* Option name. |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
protected $table = 'wd_audit_settings'; |
| 23 |
/** |
| 24 |
* Is module enabled? |
| 25 |
* |
| 26 |
* @defender_property |
| 27 |
* @var bool |
| 28 |
*/ |
| 29 |
public $enabled = false; |
| 30 |
/** |
| 31 |
* Table column for storage days. |
| 32 |
* |
| 33 |
* @defender_property |
| 34 |
* @var string |
| 35 |
*/ |
| 36 |
public $storage_days = '6 months'; |
| 37 |
|
| 38 |
/** |
| 39 |
* Define settings labels. |
| 40 |
* |
| 41 |
* @return array |
| 42 |
*/ |
| 43 |
public function labels(): array { |
| 44 |
return array( |
| 45 |
'enabled' => self::get_module_name(), |
| 46 |
'storage_days' => esc_html__( 'Storage for', 'defender-security' ), |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Checks if the audit logging is active. |
| 52 |
* |
| 53 |
* @return bool Returns true if the audit logging is active, false otherwise. |
| 54 |
* @since 2.6.5 |
| 55 |
*/ |
| 56 |
public function is_active(): bool { |
| 57 |
$enabled = apply_filters( 'wd_audit_enable', $this->enabled ); |
| 58 |
|
| 59 |
return is_bool( $enabled ) ? $enabled : (bool) $enabled; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Retrieves the module name for audit logging. |
| 64 |
* |
| 65 |
* @return string The module name for audit logging. |
| 66 |
*/ |
| 67 |
public static function get_module_name(): string { |
| 68 |
return esc_html__( 'Audit Logging', 'defender-security' ); |
| 69 |
} |
| 70 |
} |
| 71 |
|