0 ? $client->get_manifest_summary(true, $status, 60) : $client->get_manifest_summary(false, $status); $err = is_wp_error($summary) ? $summary->get_error_message() : null; // Normalize to an array immediately: on API failure get_manifest_summary // returns a WP_Error, and the array subscripts below (e.g. line ~118 // $summary['countsByStatus']) FATAL on "object of type WP_Error as array" // before any is_array() check on the subscript result can run. Mirror the // $agg guard. Empty array → page renders the empty/first-run state. if (!is_array($summary)) { $summary = array(); } $tier = (string) $client->get_subscription_tier(); if ($tier === '') $tier = 'free'; $isFree = ($tier === 'free'); $site_options_obj = $client->get_site_options(); $features_list = array(); if (is_object($site_options_obj) && isset($site_options_obj->features) && is_array($site_options_obj->features)) { $features_list = $site_options_obj->features; } $has_agentic = in_array('agentic_fixes_approve', $features_list, true); $is_legacy_v1 = ($tier === 'legacy') || (!$has_agentic && !$isFree); AllAccessible_Debug::console('AgenticFixesPage', array( 'status_tab' => $status, 'tier' => $tier, 'is_free' => $isFree, 'is_legacy_v1' => $is_legacy_v1, 'has_agentic_feature'=> $has_agentic, 'features_list' => $features_list, 'summary_is_error' => is_wp_error($summary), 'summary_error' => $err, 'summary_keys' => is_array($summary) ? array_keys($summary) : null, 'summary' => is_wp_error($summary) ? null : $summary, )); if ($is_legacy_v1) { self::render_legacy_upgrade_page(); return; } $agg = $client->get_audit_aggregation(); if (is_wp_error($agg) || !is_array($agg)) { $agg = null; } $hero_site_score = null; $hero_remediation_score = null; $hero_pages_scanned = null; $hero_is_live_estimate = false; if ($agg && !empty($agg['hasData'])) { $hero_site_score = isset($agg['overallScore']) ? (float) $agg['overallScore'] : null; $hero_remediation_score = isset($agg['remediationScore']) ? (float) $agg['remediationScore'] : null; $hero_pages_scanned = isset($agg['totalPagesScanned']) ? (int) $agg['totalPagesScanned'] : (isset($agg['coverage']['totalPagesScanned']) ? (int) $agg['coverage']['totalPagesScanned'] : null); $hero_is_live_estimate = !empty($agg['isLiveEstimate']); } $extras_hero = array( 'site_score' => $hero_site_score, 'remediation_score' => $hero_remediation_score, 'pages_scanned' => $hero_pages_scanned, 'is_live_estimate' => $hero_is_live_estimate, 'fixes_url' => admin_url('admin.php?page=aacb-agentic-fixes'), ); $counts = is_array($summary['countsByStatus'] ?? null) ? $summary['countsByStatus'] : array(); $groups = is_array($summary['groups'] ?? null) ? $summary['groups'] : array(); $pending = (int) ($counts['draft'] ?? 0); $approved = (int) ($counts['approved'] ?? 0); $reverted = (int) ($counts['reverted'] ?? 0); // Served signal from the summary endpoint (last time the widget received a manifest). null/absent = never delivered. $live_raw = is_array($summary['liveSignal'] ?? null) ? $summary['liveSignal'] : null; $live_at = ($live_raw && !empty($live_raw['at'])) ? (int) $live_raw['at'] : 0; if ($live_at > 100000000000) { $live_at = intdiv($live_at, 1000); } // ms -> s guard $live_age_s = $live_at > 0 ? max(0, time() - $live_at) : null; $live_state = $approved === 0 ? 'none' : ($live_age_s === null ? 'waiting' : ($live_age_s < DAY_IN_SECONDS ? 'live' : 'stale')); $live_labels = AllAccessible_AgenticFixes_Labels::live_state(); // Still waiting for the first delivery: don't pin that state in the 30-min cache. if ($live_state === 'waiting') { $client->shorten_manifest_summary_cache($status, 90); } $show_first_run_hint = ($status === 'draft' && $approved === 0 && $reverted === 0); ?>