39 lines
1.1 KiB
PHP
39 lines
1.1 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();
|
|
$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';
|
|
}
|
|
}
|