feat(admin): always-on dashboard widget + default retro days = 0
- Dashboard widget is now registered unconditionally. Header + content adapt: shows '⚠️ ошибки доставки' only when failed > 0, otherwise plain title with queue state (pending / sent-24h / failed). Pilot feedback: the conditional widget felt like the plugin was missing — users expect a persistent status readout. - Retro default window changed from 7 days to 0 (no limit). Most pilot uses were 'dump everything since install', so 0 is the more useful default. User can still narrow to N days in the form. - Spec §10 + §14 updated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,15 +7,18 @@ final class Dashboard_Widget
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
add_action('wp_dashboard_setup', [$this, 'maybe_register_widget']);
|
||||
add_action('wp_dashboard_setup', [$this, 'register_widget']);
|
||||
}
|
||||
|
||||
public function maybe_register_widget(): void
|
||||
public function register_widget(): void
|
||||
{
|
||||
if (Queue::count_failed() === 0) return;
|
||||
$failed_count = Queue::count_failed();
|
||||
$title = $failed_count > 0
|
||||
? '⚠️ CF7 Spam → Telegram: ошибки доставки'
|
||||
: 'CF7 Spam → Telegram';
|
||||
wp_add_dashboard_widget(
|
||||
'cf7stg_dashboard_errors',
|
||||
'⚠️ CF7 Spam → Telegram: ошибки доставки',
|
||||
'cf7stg_dashboard_status',
|
||||
$title,
|
||||
[$this, 'render']
|
||||
);
|
||||
}
|
||||
@@ -23,7 +26,10 @@ final class Dashboard_Widget
|
||||
public function render(): void
|
||||
{
|
||||
$failed = Queue::list_failed(10);
|
||||
$count = Queue::count_failed();
|
||||
$failed_count = Queue::count_failed();
|
||||
$pending = Queue::count_by_status(Queue::STATUS_PENDING);
|
||||
$sent_24h = Queue::count_sent_last_24h();
|
||||
$configured = Settings::is_configured();
|
||||
$settings_url = admin_url('options-general.php?page=cf7stg-settings');
|
||||
include CF7STG_PLUGIN_DIR . 'admin/views/dashboard-widget.php';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user