Home: counts plus the most important open items. */ final class DashboardWidget { private const MAX_ITEMS = 4; /** * Register hooks. */ public function register(): void { add_action( 'wp_dashboard_setup', array( $this, 'add' ) ); } /** * Add the widget for administrators. */ public function add(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } wp_add_dashboard_widget( 'keepwatch_status', __( 'Keepwatch', 'keepwatch' ), array( $this, 'render' ) ); } /** * Render the widget. */ public function render(): void { $groups = Registry::run( Registry::checks() ); $summary = Registry::summary( $groups ); $open = array(); foreach ( $groups as $results ) { foreach ( $results as $result ) { if ( Result::GOOD !== $result->status ) { $open[] = $result; } } } usort( $open, static function ( Result $a, Result $b ): int { return $a->weight() <=> $b->weight(); } ); echo '
', esc_url( admin_url( 'tools.php?page=' . Menu::SLUG ) ), esc_html__( 'Open Keepwatch', 'keepwatch' ) ); } }