From ea5666318b320f30733c99f01118179c107cd6f2 Mon Sep 17 00:00:00 2001 From: Vladimir Bryzgalov Date: Tue, 21 Apr 2026 17:14:56 +0500 Subject: [PATCH] feat(admin): silent-drop block in settings page (dry-run, hard-rule, threshold, stats, reset) --- admin/class-settings-page.php | 19 +++++++++++ admin/views/settings.php | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/admin/class-settings-page.php b/admin/class-settings-page.php index aded85d..d6a1886 100644 --- a/admin/class-settings-page.php +++ b/admin/class-settings-page.php @@ -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'); diff --git a/admin/views/settings.php b/admin/views/settings.php index 409e857..d536d53 100644 --- a/admin/views/settings.php +++ b/admin/views/settings.php @@ -13,6 +13,8 @@ if (($_GET['test'] ?? '') === 'err') $notice = '
'; if (isset($_GET['retried'])) $notice = '

Перезапущено с ошибкой: ' . (int)$_GET['retried'] . '.

'; if (isset($_GET['purged'])) $notice = '

Удалено отправленных: ' . (int)$_GET['purged'] . '.

'; +if (isset($_GET['drop_saved'])) $notice = '

Настройки silent drop сохранены.

'; +if (isset($_GET['drop_reset'])) $notice = '

Счётчики silent drop сброшены.

'; ?>

CF7 Spam → Telegram

@@ -108,4 +110,64 @@ if (isset($_GET['purged'])) $notice = '
+ +
+ +

Silent drop

+

+ Заявки, удовлетворяющие правилам, не отправляются в Telegram. + Подробности правил — в docs/superpowers/specs/2026-04-21-cf7stg-silent-drop-design.md. +

+ + + +
+ + + + + + + + + + + + + + + +
Dry-run mode + +

Включён по умолчанию. Снимите галочку только убедившись по TG-сообщениям, что среди дропов нет реальных клиентов.

+
Hard-rule override + +
+ +

Дефолт −5. Заявка с score ≤ этого значения дропается даже без hard-rule.

+
+ +
+ +

Статистика

+

+ Всего дропнуто:
+ Сегодня (real): · сегодня (dry-run):
+ Вчера (real): · вчера (dry-run):
+ Счётчик с: +

+
+ + + +