diff --git a/admin/class-dashboard-widget.php b/admin/class-dashboard-widget.php index 04ffa09..8f89d9d 100644 --- a/admin/class-dashboard-widget.php +++ b/admin/class-dashboard-widget.php @@ -30,6 +30,8 @@ final class Dashboard_Widget $pending = Queue::count_by_status(Queue::STATUS_PENDING); $sent_24h = Queue::count_sent_last_24h(); $configured = Settings::is_configured(); + $dry_run_on = Settings::is_dry_run_drop(); + $drop_counters = Settings::get_drop_counters(); $settings_url = admin_url('options-general.php?page=cf7stg-settings'); include CF7STG_PLUGIN_DIR . 'admin/views/dashboard-widget.php'; } 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/dashboard-widget.php b/admin/views/dashboard-widget.php index 2bc3993..1a0056d 100644 --- a/admin/views/dashboard-widget.php +++ b/admin/views/dashboard-widget.php @@ -5,6 +5,8 @@ /** @var int $sent_24h */ /** @var bool $configured */ /** @var string $settings_url */ +/** @var bool $dry_run_on */ +/** @var array $drop_counters */ ?>

⚙️ Плагин не настроен — укажите Bot Token и Chat ID в настройках.

@@ -20,6 +22,14 @@

+

+ + Dry-run: за сегодня было бы дропнуто , всего . + + Дропнуто сегодня: (вчера , всего ). + +

+ 0): ?>

Последние ошибки доставки (TG-API):