traceBoundary( ABJ_404_Solution_HookInstrumentationLifecycleTracer::PHASE_REGISTRATION, 'admin_notices', static function (): void { add_action('admin_notices', array(self::class, 'echoNotice')); }); } } /** * admin_notices callback. * * @return void */ public static function echoNotice(): void { if (!defined('ABJ404_PP') || !abj404_current_user_is_plugin_admin()) { return; } if (ABJ_404_Solution_RequestInputNormalizer::readText($_GET, array('name' => 'page')) !== ABJ404_PP || ABJ_404_Solution_RequestInputNormalizer::readText($_GET, array('name' => 'subpage')) === 'abj404_tools') { return; } if (!ABJ_404_Solution_TimeLimitFatalStore::hasUnseen()) { return; } echo ABJ_404_Solution_TimeLimitReportView::notice( '?page=' . ABJ404_PP . '&subpage=abj404_tools#' . ABJ_404_Solution_TimeLimitReportView::ANCHOR); } /** * The Tools card, or null when there is no record (the card then does * not exist). Building it marks the records seen. * * @param int $now epoch seconds. * @return array{html: string, unseen: bool}|null unseen: whether it held * a record the admin had not seen (the card opens expanded then). */ public static function toolsCard(int $now): ?array { $entries = ABJ_404_Solution_TimeLimitFatalStore::read(); if ($entries === array()) { return null; } $unseen = ABJ_404_Solution_TimeLimitFatalStore::hasUnseen(); $html = ABJ_404_Solution_TimeLimitReportView::card($entries, ABJ_404_Solution_TimeLimitFatalStore::readSlowCallbacks()); if ($unseen) { ABJ_404_Solution_TimeLimitFatalStore::markSeen($now); } return array('html' => $html, 'unseen' => $unseen); } }