From 24367c1ccb3712894390ab7d32c1c279cda3f7bb Mon Sep 17 00:00:00 2001 From: Vladimir Bryzgalov Date: Tue, 21 Apr 2026 16:26:38 +0500 Subject: [PATCH] feat(activator): seed silent-drop options (dry-run on by default) on activate --- includes/class-activator.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/includes/class-activator.php b/includes/class-activator.php index a6d8911..eccb13e 100644 --- a/includes/class-activator.php +++ b/includes/class-activator.php @@ -12,6 +12,7 @@ final class Activator { self::guard_requirements(); self::install_table(); + self::seed_silent_drop_options(); self::schedule_events(); } @@ -64,6 +65,27 @@ final class Activator update_option(self::DB_VERSION_OPTION, self::DB_VERSION); } + /** + * Seed safe defaults for silent-drop options. Uses add_option (not update_option), + * so existing values from prior versions or user customisations are preserved. + * Runs on every activate() call — fresh installs and upgrades alike. + */ + private static function seed_silent_drop_options(): void + { + add_option(Settings::OPT_DRY_RUN_DROP, true); + add_option(Settings::OPT_DROP_THRESHOLD, -5); + add_option(Settings::OPT_HARD_DROP_ENABLED, true); + add_option(Settings::OPT_DROP_COUNTERS, [ + 'total' => 0, + 'real_today' => 0, + 'real_yesterday' => 0, + 'dry_today' => 0, + 'dry_yesterday' => 0, + 'today_date' => wp_date('Y-m-d'), + 'reset_at' => wp_date('Y-m-d'), + ]); + } + private static function schedule_events(): void { // Register the custom 60-second schedule here — Dispatcher::register_hooks()