dbdfc9afa9
- 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>
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Cf7stg;
|
|
|
|
final class Dashboard_Widget
|
|
{
|
|
public function register(): void
|
|
{
|
|
add_action('wp_dashboard_setup', [$this, 'register_widget']);
|
|
}
|
|
|
|
public function register_widget(): void
|
|
{
|
|
$failed_count = Queue::count_failed();
|
|
$title = $failed_count > 0
|
|
? '⚠️ CF7 Spam → Telegram: ошибки доставки'
|
|
: 'CF7 Spam → Telegram';
|
|
wp_add_dashboard_widget(
|
|
'cf7stg_dashboard_status',
|
|
$title,
|
|
[$this, 'render']
|
|
);
|
|
}
|
|
|
|
public function render(): void
|
|
{
|
|
$failed = Queue::list_failed(10);
|
|
$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';
|
|
}
|
|
}
|