feat(activator): seed silent-drop options (dry-run on by default) on activate

This commit is contained in:
Vladimir Bryzgalov
2026-04-21 16:26:38 +05:00
parent 0034531a3a
commit 24367c1ccb
+22
View File
@@ -12,6 +12,7 @@ final class Activator
{ {
self::guard_requirements(); self::guard_requirements();
self::install_table(); self::install_table();
self::seed_silent_drop_options();
self::schedule_events(); self::schedule_events();
} }
@@ -64,6 +65,27 @@ final class Activator
update_option(self::DB_VERSION_OPTION, self::DB_VERSION); 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 private static function schedule_events(): void
{ {
// Register the custom 60-second schedule here — Dispatcher::register_hooks() // Register the custom 60-second schedule here — Dispatcher::register_hooks()