$input * @param array $formatters * @return array */ public function build(array $input, array $formatters): array { $scan = is_array($input['scan'] ?? null) ? $input['scan'] : []; $issues = $this->arrays_only($input['issues'] ?? []); $all_issues = $this->arrays_only($input['all_issues'] ?? []); $suggestions = $this->arrays_only($input['suggestions'] ?? []); $all_suggestions = $this->arrays_only($input['all_suggestions'] ?? []); $reviewed_items = $this->arrays_only($input['reviewed_items'] ?? []); $passed = $this->arrays_only($input['passed'] ?? []); $evaluation_results = AIFQ_SR_Evaluation_Result::normalize_list($input['evaluation_results'] ?? []); $coverage_results = (new AIFQ_SR_Coverage_Projector())->normalize_results($scan['coverage_results'] ?? []); $meaningful_changes = is_array($input['meaningful_changes'] ?? null) ? $input['meaningful_changes'] : []; $external_tls_human = is_array($input['external_tls_human'] ?? null) ? $input['external_tls_human'] : null; $external_http_human = is_array($input['external_http_human'] ?? null) ? $input['external_http_human'] : null; $issue_title = $formatters['issue_title'] ?? static fn(array $item): string => (string) ($item['title'] ?? ''); $issue_preview = $formatters['issue_preview'] ?? static fn(array $item): string => (string) ($item['description'] ?? ''); $passed_title = $formatters['passed_title'] ?? static fn(array $item): string => (string) ($item['title'] ?? ''); $passed_description = $formatters['passed_description'] ?? static fn(array $item): string => (string) ($item['description'] ?? ''); $capability_title = $formatters['capability_title'] ?? static fn(string $id): string => $id; $last_checked = $formatters['last_checked'] ?? static fn(int $timestamp): string => ''; $reviewed_keys = []; foreach ($reviewed_items as $item) { $key = sanitize_key((string) ($item['key'] ?? '')); if ($key !== '') { $reviewed_keys[$key] = true; } } $entries = []; $represented_capabilities = []; foreach ($all_issues as $item) { $key = sanitize_key((string) ($item['key'] ?? '')); $state = ($key !== '' && isset($reviewed_keys[$key])) ? 'reviewed' : 'attention'; $entries[] = $this->finding_entry( $item, $state, (string) $issue_title($item), (string) $issue_preview($item) ); $capability_id = AIFQ_SR_Capability_Catalog::capability_id_for_finding($key); if ($capability_id !== '') { $represented_capabilities[$capability_id] = true; } } foreach ($all_suggestions as $item) { $key = sanitize_key((string) ($item['key'] ?? '')); $state = ($key !== '' && isset($reviewed_keys[$key])) ? 'reviewed' : 'review'; $entries[] = $this->finding_entry( $item, $state, (string) $issue_title($item), (string) $issue_preview($item) ); $capability_id = AIFQ_SR_Capability_Catalog::capability_id_for_finding($key); if ($capability_id !== '') { $represented_capabilities[$capability_id] = true; } } foreach ($passed as $item) { $entries[] = $this->finding_entry( $item, 'good', (string) $passed_title($item), (string) $passed_description($item) ); } foreach ($evaluation_results as $result) { $capability_id = sanitize_key((string) ($result['capability_id'] ?? '')); if ( ($result['evaluability'] ?? '') === AIFQ_SR_Capability_Catalog::EVALUABILITY_EVALUATED && ($result['outcome'] ?? '') === AIFQ_SR_Capability_Catalog::OUTCOME_FINDING_PRESENT && isset($represented_capabilities[$capability_id]) ) { continue; } $entries[] = $this->capability_entry( $result, (string) $capability_title($capability_id) ); } if ($coverage_results !== []) { $coverage_view = $this->coverage_view($coverage_results, $reviewed_keys); $areas = $coverage_view['areas']; $coverage_summary = $coverage_view['summary']; $good_count = (int) $coverage_summary['good']; $unknown_count = (int) $coverage_summary['unknown']; } else { $areas = $this->group_areas($entries); $unknown_count = 0; $good_count = 0; foreach ($entries as $entry) { if (($entry['state'] ?? '') === 'good') { $good_count++; } if (in_array(($entry['state'] ?? ''), ['unknown', 'error'], true)) { $unknown_count++; } } $coverage_summary = [ 'total_checks' => count($entries), 'good' => $good_count, 'attention' => count($issues), 'review' => count($suggestions), 'reviewed' => count($reviewed_items), 'informational' => 0, 'not_applicable' => 0, 'unknown' => $unknown_count, 'not_run' => 0, 'items' => [], ]; } $active_attention = []; foreach ($issues as $item) { $key = sanitize_key((string) ($item['key'] ?? '')); $coverage_area = $coverage_results !== [] ? $this->coverage_area_for_finding_key($key, $coverage_results) : ''; $coverage_id = $coverage_results !== [] ? $this->coverage_id_for_finding_key($key, $coverage_results) : ''; $active_attention[] = [ 'title' => (string) $issue_title($item), 'preview' => (string) $issue_preview($item), 'area' => $coverage_area !== '' ? $coverage_area : $this->area_for_item($item, (string) ($item['category_id'] ?? $item['category'] ?? '')), 'key' => $key, 'coverage_id' => $coverage_id, ]; } $active_review_count = count($suggestions); $headline = $this->headline(count($active_attention), $active_review_count, $unknown_count); $coverage_summary['last_checked'] = (string) $last_checked((int) ($scan['created_at'] ?? 0)); $positive_highlights = $coverage_results !== [] ? $this->positive_highlights($coverage_results, $reviewed_keys) : $this->positive_highlights_from_entries($entries); return [ 'headline' => $headline, 'summary' => $coverage_summary, 'needs_attention' => $active_attention, 'areas' => $areas, 'positive_highlights' => $positive_highlights, 'site_context' => $this->site_context($external_tls_human, $external_http_human), 'changes' => $this->changes($meaningful_changes, $issue_title), ]; } /** * Turn immutable coverage states into the compact Current presentation. * * Reviewed is a workflow overlay only; it never rewrites canonical coverage. * * @param array> $coverage * @param array $reviewed_keys * @return array{areas:array>,summary:array} */ private function coverage_view(array $coverage, array $reviewed_keys): array { $area_labels = [ AIFQ_SR_Coverage_Catalog::AREA_WORDPRESS => __('WordPress', 'aifq-site-review'), AIFQ_SR_Coverage_Catalog::AREA_PUBLIC_SITE => __('Public site', 'aifq-site-review'), AIFQ_SR_Coverage_Catalog::AREA_BACKGROUND => __('Background work', 'aifq-site-review'), AIFQ_SR_Coverage_Catalog::AREA_SECURITY => __('Security basics', 'aifq-site-review'), AIFQ_SR_Coverage_Catalog::AREA_DATABASE => __('Database', 'aifq-site-review'), AIFQ_SR_Coverage_Catalog::AREA_MAINTENANCE => __('Maintenance', 'aifq-site-review'), ]; $summary = [ 'total_checks' => 0, 'good' => 0, 'attention' => 0, 'review' => 0, 'reviewed' => 0, 'informational' => 0, 'not_applicable' => 0, 'unknown' => 0, 'not_run' => 0, ]; $areas = []; foreach ($area_labels as $area_id => $label) { $areas[$area_id] = [ 'id' => $area_id, 'label' => $label, 'checks' => 0, 'good' => 0, 'attention' => 0, 'review' => 0, 'reviewed' => 0, 'informational' => 0, 'not_applicable' => 0, 'unknown' => 0, 'not_run' => 0, ]; } foreach ($coverage as $entry) { $area_id = (string) ($entry['area_id'] ?? ''); if (!isset($areas[$area_id])) { continue; } $state = $this->coverage_display_state($entry, $reviewed_keys); $summary['total_checks']++; $areas[$area_id]['checks']++; if (!array_key_exists($state, $summary)) { $state = 'unknown'; } $summary[$state]++; $areas[$area_id][$state]++; $areas[$area_id]['items'][] = [ 'id' => (string) ($entry['coverage_id'] ?? ''), 'title' => (string) ($entry['label'] ?? ''), 'state' => $state, ]; } $result = []; foreach ($areas as $area) { if ((int) $area['checks'] < 1) { continue; } $area['result'] = $this->coverage_area_result($area); if ((int) $area['attention'] > 0) { $area['tone'] = 'attention'; } elseif ((int) $area['unknown'] > 0 || (int) $area['not_run'] > 0) { $area['tone'] = 'unknown'; } elseif ((int) $area['review'] > 0) { $area['tone'] = 'review'; } elseif ((int) $area['reviewed'] > 0) { $area['tone'] = 'reviewed'; } else { $area['tone'] = 'good'; } $result[] = $area; } return [ 'areas' => $result, 'summary' => $summary, ]; } /** * Keep Current positive feedback intentionally small and meaningful. * This is presentation selection over canonical good Coverage, not new truth. * * @param array> $coverage * @param array $reviewed_keys * @return array */ private function positive_highlights(array $coverage, array $reviewed_keys): array { $by_id = []; foreach ($coverage as $entry) { $id = (string) ($entry['coverage_id'] ?? ''); if ($id === '' || $this->coverage_display_state($entry, $reviewed_keys) !== 'good') { continue; } $by_id[$id] = $entry; } $priority = [ 'external.tls_certificate', 'local.search_visibility', 'local.wordpress_core_update_state', 'local.action_scheduler_overdue', 'capability.core_database_integrity', 'local.site_url_home_match', 'local.wordpress_https_signal', 'local.object_cache_presence', ]; $result = []; $selected = []; foreach ($priority as $coverage_id) { if (!isset($by_id[$coverage_id])) { continue; } $entry = $by_id[$coverage_id]; $result[] = [ 'id' => $coverage_id, 'title' => (string) ($entry['label'] ?? $coverage_id), 'area' => (string) ($entry['area_id'] ?? ''), ]; $selected[$coverage_id] = true; if (count($result) >= 8) { break; } } // The priority list controls which positive checks appear first, but it // must not leave the section artificially short when other completed // good checks are available. if (count($result) < 8) { foreach ($by_id as $coverage_id => $entry) { if (isset($selected[$coverage_id])) { continue; } $result[] = [ 'id' => $coverage_id, 'title' => (string) ($entry['label'] ?? $coverage_id), 'area' => (string) ($entry['area_id'] ?? ''), ]; if (count($result) >= 8) { break; } } } return $result; } /** * Legacy-review fallback for Current positive feedback when Coverage was not recorded. * * @param array> $entries * @return array */ private function positive_highlights_from_entries(array $entries): array { $result = []; foreach ($entries as $entry) { if (($entry['state'] ?? '') !== 'good') { continue; } $id = (string) ($entry['id'] ?? ''); if ($id === '') { continue; } $result[] = [ 'id' => $id, 'title' => (string) ($entry['title'] ?? $id), 'area' => (string) ($entry['area'] ?? ''), ]; if (count($result) >= 8) { break; } } return $result; } /** * @param array $entry * @param array $reviewed_keys */ private function coverage_display_state(array $entry, array $reviewed_keys): string { if (($entry['applicability'] ?? '') === AIFQ_SR_Coverage_Projector::NOT_APPLICABLE) { return 'not_applicable'; } $knowledge = (string) ($entry['knowledge_state'] ?? ''); if ($knowledge === AIFQ_SR_Coverage_Projector::KNOWLEDGE_NOT_RUN) { return 'not_run'; } if (in_array($knowledge, [ AIFQ_SR_Coverage_Projector::KNOWLEDGE_UNOBSERVABLE, AIFQ_SR_Coverage_Projector::KNOWLEDGE_ERROR, ], true)) { return 'unknown'; } $outcome = (string) ($entry['outcome'] ?? ''); if (in_array($outcome, [ AIFQ_SR_Coverage_Projector::OUTCOME_ATTENTION, AIFQ_SR_Coverage_Projector::OUTCOME_REVIEW, ], true)) { foreach ((array) ($entry['finding_refs'] ?? []) as $ref) { $key = sanitize_key((string) $ref); if ($key !== '' && isset($reviewed_keys[$key])) { return 'reviewed'; } } } if ($outcome === AIFQ_SR_Coverage_Projector::OUTCOME_GOOD) { return 'good'; } if ($outcome === AIFQ_SR_Coverage_Projector::OUTCOME_ATTENTION) { return 'attention'; } if ($outcome === AIFQ_SR_Coverage_Projector::OUTCOME_REVIEW) { return 'review'; } if ($outcome === AIFQ_SR_Coverage_Projector::OUTCOME_INFORMATIONAL) { return 'informational'; } return 'unknown'; } private function coverage_area_result(array $area): string { $parts = []; $attention = (int) ($area['attention'] ?? 0); $review = (int) ($area['review'] ?? 0); $unknown = (int) ($area['unknown'] ?? 0); $not_run = (int) ($area['not_run'] ?? 0); if ($attention > 0) { $parts[] = sprintf( /* translators: %d: number of checks needing attention. */ _n('%d needs attention', '%d need attention', $attention, 'aifq-site-review'), $attention ); } if ($review > 0) { $parts[] = sprintf( /* translators: %d: number of checks worth reviewing. */ _n('%d worth reviewing', '%d worth reviewing', $review, 'aifq-site-review'), $review ); } if ($parts !== []) { return implode(' · ', $parts); } // Knowledge gaps are not action claims, but must never be presented as // "No action needed" because the current state was not fully verified. if ($unknown > 0 || $not_run > 0) { return __('Could not verify everything', 'aifq-site-review'); } return __('No action needed', 'aifq-site-review'); } /** * Return the explicit coverage area for a finding instead of inferring an * area from copy/category text. * * @param array> $coverage */ /** * Return the stable Coverage identity backing a finding when available. * * @param array> $coverage */ private function coverage_id_for_finding_key(string $finding_key, array $coverage): string { if ($finding_key === '') { return ''; } foreach ($coverage as $entry) { foreach ((array) ($entry['finding_refs'] ?? []) as $ref) { if (sanitize_key((string) $ref) === $finding_key) { return (string) ($entry['coverage_id'] ?? ''); } } } return ''; } private function coverage_area_for_finding_key(string $finding_key, array $coverage): string { if ($finding_key === '') { return ''; } foreach ($coverage as $entry) { foreach ((array) ($entry['finding_refs'] ?? []) as $ref) { if (sanitize_key((string) $ref) === $finding_key) { return (string) ($entry['area_id'] ?? ''); } } } return ''; } /** * @param mixed $items * @return array> */ private function arrays_only($items): array { return array_values(array_filter(is_array($items) ? $items : [], 'is_array')); } /** * @return array */ private function finding_entry(array $item, string $state, string $title, string $description): array { $key = sanitize_key((string) ($item['key'] ?? '')); $category = (string) ($item['category_id'] ?? $item['category'] ?? ''); return [ 'id' => $key !== '' ? $key : sanitize_title($title), 'key' => $key, 'title' => $title !== '' ? $title : __('Recorded check', 'aifq-site-review'), 'description' => $description, 'state' => $state, 'area' => $this->area_for_item($item, $category), ]; } /** * @return array */ private function capability_entry(array $result, string $title): array { $capability_id = sanitize_key((string) ($result['capability_id'] ?? '')); $evaluability = sanitize_key((string) ($result['evaluability'] ?? '')); $outcome = sanitize_key((string) ($result['outcome'] ?? '')); if ($evaluability === AIFQ_SR_Capability_Catalog::EVALUABILITY_EVALUATED) { $state = $outcome === AIFQ_SR_Capability_Catalog::OUTCOME_NO_FINDING ? 'good' : 'review'; } elseif ($evaluability === AIFQ_SR_Capability_Catalog::EVALUABILITY_ERROR) { $state = 'error'; } elseif ($evaluability === AIFQ_SR_Capability_Catalog::EVALUABILITY_NOT_APPLICABLE) { $state = 'not_applicable'; } else { $state = 'unknown'; } return [ 'id' => $capability_id, 'key' => $capability_id, 'title' => $title !== '' ? $title : __('Operational integrity check', 'aifq-site-review'), 'description' => '', 'state' => $state, 'area' => $this->area_for_token($capability_id, 'reliability'), ]; } /** * @param array> $entries * @return array> */ private function group_areas(array $entries): array { $definitions = [ 'wordpress' => __('WordPress', 'aifq-site-review'), 'public' => __('Public site', 'aifq-site-review'), 'background' => __('Background work', 'aifq-site-review'), 'security' => __('Security basics', 'aifq-site-review'), 'database' => __('Database', 'aifq-site-review'), 'maintenance' => __('Maintenance', 'aifq-site-review'), ]; $grouped = []; foreach ($definitions as $id => $label) { $grouped[$id] = [ 'id' => $id, 'label' => $label, 'checks' => 0, 'good' => 0, 'attention' => 0, 'review' => 0, 'reviewed' => 0, 'unknown' => 0, 'not_applicable' => 0, ]; } foreach ($entries as $entry) { $area = isset($grouped[$entry['area'] ?? '']) ? (string) $entry['area'] : 'wordpress'; $state = (string) ($entry['state'] ?? 'unknown'); $grouped[$area]['checks']++; if ($state === 'good') { $grouped[$area]['good']++; } elseif ($state === 'attention') { $grouped[$area]['attention']++; } elseif ($state === 'review') { $grouped[$area]['review']++; } elseif ($state === 'reviewed') { $grouped[$area]['reviewed']++; } elseif ($state === 'not_applicable') { $grouped[$area]['not_applicable']++; } else { $grouped[$area]['unknown']++; } } $result = []; foreach ($grouped as $area) { if ($area['checks'] < 1) { continue; } $area['result'] = $this->area_result($area); $area['tone'] = $area['attention'] > 0 ? 'attention' : ($area['unknown'] > 0 ? 'unknown' : ($area['review'] > 0 ? 'review' : 'good')); $result[] = $area; } return $result; } private function area_result(array $area): string { $parts = []; if ($area['good'] > 0) { $parts[] = sprintf( /* translators: 1: good checks, 2: total checks */ __('%1$d/%2$d good', 'aifq-site-review'), (int) $area['good'], (int) $area['checks'] ); } if ($area['attention'] > 0) { $parts[] = sprintf( /* translators: %d: number of checks needing attention. */ _n('%d attention', '%d attention', (int) $area['attention'], 'aifq-site-review'), (int) $area['attention'] ); } if ($area['review'] > 0) { $parts[] = sprintf( /* translators: %d: number of checks worth reviewing. */ _n('%d worth reviewing', '%d worth reviewing', (int) $area['review'], 'aifq-site-review'), (int) $area['review'] ); } if ($area['reviewed'] > 0) { $parts[] = sprintf( /* translators: %d: number of reviewed findings. */ _n('%d reviewed', '%d reviewed', (int) $area['reviewed'], 'aifq-site-review'), (int) $area['reviewed'] ); } if ($area['unknown'] > 0) { $parts[] = sprintf( /* translators: %d: number of checks whose current state is not fully known. */ _n('%d not fully known', '%d not fully known', (int) $area['unknown'], 'aifq-site-review'), (int) $area['unknown'] ); } if ($parts === []) { $parts[] = __('No current result', 'aifq-site-review'); } return implode(' · ', $parts); } private function area_for_item(array $item, string $category): string { $token = implode(' ', [ sanitize_key((string) ($item['key'] ?? '')), sanitize_key((string) ($item['title'] ?? '')), sanitize_key($category), ]); return $this->area_for_token($token, $category); } private function area_for_token(string $token, string $category): string { $token = strtolower($token . ' ' . $category); foreach (['external_http', 'external_tls', 'public_dns', 'search_visibility', 'robots', 'http_', 'tls_', 'ssl'] as $needle) { if (str_contains($token, $needle)) { return 'public'; } } foreach (['action_scheduler', 'wp_cron', 'cron', 'background', 'loopback', 'scheduler', 'queue', 'backwpup', 'updraftplus'] as $needle) { if (str_contains($token, $needle)) { return 'background'; } } foreach (['database', 'db_integrity', 'autoload'] as $needle) { if (str_contains($token, $needle)) { return 'database'; } } if (str_contains($token, 'security')) { return 'security'; } if (str_contains($token, 'performance')) { return 'maintenance'; } foreach (['cache', 'plugin', 'image', 'revision', 'maintenance', 'elementor', 'seo'] as $needle) { if (str_contains($token, $needle)) { return 'maintenance'; } } return 'wordpress'; } /** * @return array */ private function site_context(?array $tls_human, ?array $http_human): array { $active_plugins = (array) get_option('active_plugins', []); if (is_multisite()) { $active_plugins = array_unique(array_merge( $active_plugins, array_keys((array) get_site_option('active_sitewide_plugins', [])) )); } $theme = wp_get_theme(); $items = [ ['label' => __('WordPress', 'aifq-site-review'), 'value' => (string) get_bloginfo('version')], ['label' => __('PHP', 'aifq-site-review'), 'value' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION], /* translators: %d: number of active plugins. */ ['label' => __('Plugins', 'aifq-site-review'), 'value' => sprintf(__('%d active', 'aifq-site-review'), count($active_plugins))], ['label' => __('Theme', 'aifq-site-review'), 'value' => (string) $theme->get('Name')], ['label' => __('WooCommerce', 'aifq-site-review'), 'value' => class_exists('WooCommerce') ? __('Active', 'aifq-site-review') : __('Not active', 'aifq-site-review')], ['label' => __('Multisite', 'aifq-site-review'), 'value' => is_multisite() ? __('Yes', 'aifq-site-review') : __('No', 'aifq-site-review')], ]; $http = $this->http_status($http_human); if ($http !== '') { $items[] = ['label' => __('HTTP', 'aifq-site-review'), 'value' => $http]; } $tls = $this->tls_status($tls_human); if ($tls !== '') { $items[] = ['label' => __('TLS', 'aifq-site-review'), 'value' => $tls]; } $items[] = [ 'label' => __('Object cache', 'aifq-site-review'), 'value' => wp_using_ext_object_cache() ? __('Active', 'aifq-site-review') : __('Not active', 'aifq-site-review'), ]; if (class_exists('ActionScheduler')) { $items[] = ['label' => __('Scheduler', 'aifq-site-review'), 'value' => __('Available', 'aifq-site-review')]; } return $items; } private function http_status(?array $human): string { if (!is_array($human) || !is_array($human['summary']['site_context'] ?? null)) { return ''; } foreach ($human['summary']['site_context'] as $item) { if (!is_array($item) || !is_array($item['external_http'] ?? null)) { continue; } $http = $item['external_http']; if ((string) ($http['knowledge_state'] ?? '') !== 'evaluated') { return __('Not verified', 'aifq-site-review'); } $homepage = is_array($http['homepage'] ?? null) ? $http['homepage'] : []; if (is_int($homepage['status'] ?? null)) { return (string) $homepage['status']; } return __('Observed', 'aifq-site-review'); } return ''; } private function tls_status(?array $human): string { if (!is_array($human) || !is_array($human['summary']['situations'] ?? null)) { return ''; } foreach ($human['summary']['situations'] as $item) { if (!is_array($item) || !is_array($item['current'] ?? null)) { continue; } $id = (string) ($item['identity']['situation_id'] ?? ''); if ($id !== AIFQ_SR_Next_External_TLS_Evaluator::SITUATION_ID) { continue; } $current = $item['current']; if ((string) ($current['knowledge_state'] ?? '') !== 'evaluated') { return __('Not verified', 'aifq-site-review'); } if ((string) ($current['health_claim'] ?? '') === 'unhealthy') { return __('Needs attention', 'aifq-site-review'); } if ((string) ($current['health_claim'] ?? '') === 'healthy') { return __('Working', 'aifq-site-review'); } return __('Observed', 'aifq-site-review'); } return ''; } /** * @param callable $issue_title * @return array> */ private function changes(array $changes, callable $issue_title): array { if (empty($changes['is_comparable'])) { return []; } $events = []; foreach ((array) ($changes['new'] ?? []) as $item) { $finding = is_array($item['finding'] ?? null) ? $item['finding'] : []; if ($finding !== []) { $events[] = [ 'type' => 'new', 'title' => (string) $issue_title($finding), 'label' => __('New', 'aifq-site-review'), ]; } } foreach ((array) ($changes['resolved'] ?? []) as $item) { $finding = is_array($item['finding'] ?? null) ? $item['finding'] : []; if ($finding !== []) { $events[] = [ 'type' => 'changed', 'title' => (string) $issue_title($finding), 'label' => __('No longer flagged', 'aifq-site-review'), ]; } } foreach ((array) ($changes['now_assessable'] ?? []) as $item) { $id = sanitize_key((string) ($item['capability_id'] ?? '')); if ($id !== '') { $events[] = [ 'type' => 'context', 'title' => ucwords(str_replace('_', ' ', $id)), 'label' => __('Can now be checked', 'aifq-site-review'), ]; } } return array_slice($events, 0, 4); } /** * @return array{title:string,sub:string,tone:string} */ private function headline(int $attention, int $review, int $unknown): array { if ($attention > 0) { return [ 'title' => sprintf( /* translators: %d: number of things needing attention. */ _n('%d thing needs your attention', '%d things need your attention', $attention, 'aifq-site-review'), $attention ), 'sub' => '', 'tone' => 'attention', ]; } if ($review === 0 && $unknown === 0) { return [ 'title' => __('Everything we checked looks good', 'aifq-site-review'), 'sub' => '', 'tone' => 'good', ]; } return [ 'title' => __('Nothing needs immediate attention', 'aifq-site-review'), 'sub' => $review > 0 ? sprintf( /* translators: %d: number of non-urgent items worth reviewing. */ _n('%d item is worth reviewing', '%d items are worth reviewing', $review, 'aifq-site-review'), $review ) : ($unknown > 0 ? __('Some checks could not be verified', 'aifq-site-review') : ''), 'tone' => 'neutral', ]; } }