| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handles the notification of security recommendations that need fixing. |
| 4 |
* |
| 5 |
* @package WP_Defender\Model\Notification |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WP_Defender\Model\Notification; |
| 9 |
|
| 10 |
use DateTime; |
| 11 |
use Countable; |
| 12 |
use Exception; |
| 13 |
use DateInterval; |
| 14 |
use Calotes\Helper\Array_Cache; |
| 15 |
use WP_Defender\Component\Mail; |
| 16 |
use WP_Defender\Component\Notification; |
| 17 |
use WP_Defender\Controller\Security_Tweaks; |
| 18 |
|
| 19 |
/** |
| 20 |
* Handles the notification of security recommendations that need fixing. |
| 21 |
*/ |
| 22 |
class Tweak_Reminder extends \WP_Defender\Model\Notification { |
| 23 |
|
| 24 |
/** |
| 25 |
* Table name. |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
protected $table = 'wd_security_tweaks_reminder'; |
| 30 |
/** |
| 31 |
* Slug identifier for the tweak reminder. |
| 32 |
* |
| 33 |
* @var string |
| 34 |
*/ |
| 35 |
public const SLUG = 'tweak-reminder'; |
| 36 |
|
| 37 |
/** |
| 38 |
* Constructor method. |
| 39 |
* Sets default values for the class. |
| 40 |
*/ |
| 41 |
protected function before_load(): void { |
| 42 |
$params = array( |
| 43 |
'slug' => self::SLUG, |
| 44 |
'title' => esc_html__( 'Hardening - Alert', 'defender-security' ), |
| 45 |
'status' => self::STATUS_DISABLED, |
| 46 |
'description' => esc_html__( |
| 47 |
'Get email alerts if/when a hardening item needs fixing.', |
| 48 |
'defender-security' |
| 49 |
), |
| 50 |
// @since 3.0.0 Fix 'Guest'-line. |
| 51 |
'in_house_recipients' => array(), |
| 52 |
'out_house_recipients' => array(), |
| 53 |
'type' => 'report', |
| 54 |
'frequency' => 'weekly', |
| 55 |
'day' => 'sunday', |
| 56 |
'day_n' => 1, |
| 57 |
'time' => '4:00', |
| 58 |
'est_timestamp' => 0, |
| 59 |
'dry_run' => false, |
| 60 |
'configs' => array( |
| 61 |
'reminder' => 'weekly', |
| 62 |
), |
| 63 |
); |
| 64 |
$this->import( $params ); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Define settings labels. |
| 69 |
* |
| 70 |
* @return array |
| 71 |
*/ |
| 72 |
public function labels(): array { |
| 73 |
return array( |
| 74 |
'notification' => esc_html__( 'Hardening - Alert', 'defender-security' ), |
| 75 |
'notification_repeat' => esc_html__( 'Frequency', 'defender-security' ), |
| 76 |
'subscribers' => esc_html__( 'Recipients', 'defender-security' ), |
| 77 |
); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Additional converting rules. |
| 82 |
* |
| 83 |
* @param array $configs The configuration data. |
| 84 |
* |
| 85 |
* @return array The type-casted configuration data. |
| 86 |
* @since 3.1.0 |
| 87 |
*/ |
| 88 |
public function type_casting( $configs ): array { |
| 89 |
return is_array( $configs ) ? $configs : array(); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Normalizes tweak reminder data after loading. |
| 94 |
*/ |
| 95 |
protected function after_load(): void { |
| 96 |
parent::after_load(); |
| 97 |
$this->title = esc_html__( 'Hardening report', 'defender-security' ); |
| 98 |
} |
| 99 |
} |
| 100 |
|