feat(admin): silent-drop block in settings page (dry-run, hard-rule, threshold, stats, reset)

This commit is contained in:
Vladimir Bryzgalov
2026-04-21 17:14:56 +05:00
parent 2fcebcc756
commit ea5666318b
2 changed files with 81 additions and 0 deletions
+19
View File
@@ -16,6 +16,8 @@ final class Settings_Page
add_action('admin_post_cf7stg_retro', [$this, 'handle_retro']);
add_action('admin_post_cf7stg_retry_failed', [$this, 'handle_retry_failed']);
add_action('admin_post_cf7stg_purge_sent', [$this, 'handle_purge_sent']);
add_action('admin_post_cf7stg_save_drop', [$this, 'handle_save_drop']);
add_action('admin_post_cf7stg_reset_drop_counters', [$this, 'handle_reset_drop_counters']);
}
public function add_menu(): void
@@ -92,6 +94,23 @@ final class Settings_Page
$this->redirect_back(['purged' => $n]);
}
public function handle_save_drop(): void
{
$this->guard('cf7stg_save_drop');
Settings::set_dry_run_drop(!empty($_POST['dry_run_drop']));
Settings::set_hard_drop_enabled(!empty($_POST['hard_drop_enabled']));
$threshold = (int)($_POST['drop_score_threshold'] ?? -5);
Settings::set_drop_score_threshold($threshold);
$this->redirect_back(['drop_saved' => 1]);
}
public function handle_reset_drop_counters(): void
{
$this->guard('cf7stg_reset_drop_counters');
Settings::reset_drop_counters();
$this->redirect_back(['drop_reset' => 1]);
}
private function guard(string $action): void
{
if (!current_user_can('manage_options')) wp_die('forbidden');