network_id, $scope->site_id ) : new \WP_Error( 'overview_events', 'Activity evidence is currently unavailable.' ); $groups = is_array( $snapshot['groups'] ) ? Overview::groups( $snapshot['groups'], $scope->network_id, $scope->site_id ) : new \WP_Error( 'overview_groups', 'Request-group evidence is currently unavailable.' ); $activity_url = add_query_arg( array( 'page' => 'logged-ai', 'from' => $window['from_date'], 'to' => $window['to_date'] ), admin_url( 'admin.php' ) ); echo ( '

' . esc_html__( 'YOUR WORDPRESS, UNDERSTOOD', 'logged-ai' ) . '

' ); if ( null !== $provider ) { echo esc_html__( 'Your review.', 'logged-ai' ) . ' ' . esc_html__( 'In context.', 'logged-ai' ) . ''; } else { echo esc_html__( 'Your site.', 'logged-ai' ) . ' ' . esc_html__( 'In focus.', 'logged-ai' ) . ''; } echo ( '

' . esc_html__( 'View activity', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '
'; if ( current_user_can( 'logged_ai_manage_settings' ) ) { echo '
' . wp_kses( Design::icon( 'setup' ), Design::allowed_markup() ) . ( '
' . esc_html__( 'Make this workspace feel like yours.', 'logged-ai' ) . '' . esc_html__( 'Choose your goal, your experience and the tools that fit.', 'logged-ai' ) . '
' . esc_html__( 'Personalise my workspace', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '
'; } Design::experience(); echo '
' . wp_kses( Design::icon( 'activity' ), Design::allowed_markup() ) . ( '

' . esc_html__( 'Start with what needs your attention.', 'logged-ai' ) . '

' . esc_html__( 'Review a change, open its evidence, then decide what to do. A finding is something to inspect—not a verdict.', 'logged-ai' ) . '

' . esc_html__( 'Take a look', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '
'; echo '
'; self::stat( __( 'Changes to review', 'logged-ai' ), is_wp_error( $events ) ? '—' : (string) $events['significant_count'], __( 'In the latest examined activity', 'logged-ai' ), 'incidents', true ); self::stat( __( 'Activity examined', 'logged-ai' ), is_wp_error( $events ) ? '—' : (string) $events['examined'], __( 'Up to 50 recent retained records', 'logged-ai' ), 'activity' ); self::stat( __( 'Request observations', 'logged-ai' ), is_wp_error( $groups ) ? '—' : $groups['admitted'], __( 'Within the displayed minute groups', 'logged-ai' ), 'requests' ); self::stat( __( 'Local responses', 'logged-ai' ), is_wp_error( $groups ) ? '—' : $groups['own_responses'], __( 'Recorded in those request groups', 'logged-ai' ), 'response' ); echo '
'; self::map( is_wp_error( $events ) ? null : $events['bound_events'], $scope, $now ); if ( ! is_wp_error( $events ) ) { DesignActivity::chart( $events['bound_events'], 'overview', true ); } echo ( '

' . esc_html__( 'Your review queue', 'logged-ai' ) . '

' . esc_html__( 'Significant changes, with the evidence one click away.', 'logged-ai' ) . '

' . esc_html__( 'View all', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '
'; if ( is_wp_error( $events ) ) { echo ( '

' . esc_html__( 'Activity is unavailable. Check monitoring details below.', 'logged-ai' ) . '

' ); } elseif ( ! $events['significant'] ) { echo ( '
' . esc_html__( 'No significant changes in this sample.', 'logged-ai' ) . '
' . esc_html__( 'Missing or older observations are not represented.', 'logged-ai' ) . '
' ); } else { echo '
    '; foreach ( $events['significant'] as $event ) { $url = add_query_arg( 'event', $event['id'], $activity_url ); echo '
  1. ' . wp_kses( Design::icon( 'identity' === $event['category'] ? 'lock' : 'activity' ), Design::allowed_markup() ) . '
    ' . esc_html( Design::label( $event['code'] ) ) . '' . esc_html( Design::time_label( $time, $event['occurred_at'] ) . ' · #' . $event['id'] ) . '' . esc_html( $event['code'] . ' · ' . $event['outcome'] ) . '
    ' . esc_html( array( 'info' => __( 'info', 'logged-ai' ), 'notice' => __( 'notice', 'logged-ai' ), 'warning' => __( 'warning', 'logged-ai' ), 'high' => __( 'high', 'logged-ai' ), 'critical' => __( 'critical', 'logged-ai' ) )[ $event['severity'] ] ?? $event['severity'] ) . '
  2. '; } echo '
'; } echo ( '

' . esc_html__( 'Warning, high and critical source severity. Counts cover the latest examined records, not all site activity.', 'logged-ai' ) . '

' ); if ( null !== $provider && null !== $extension ) { $provider->render( $extension, array( 'time' => $time, 'window' => $window ) ); } echo '
'; self::requests( $groups, $time ); self::health( $snapshot['health'] ); if ( null === $provider && ! defined( 'LOGGED_AI_PRO_FILE' ) ) { Design::upgrade_card(); } echo ( '
' . esc_html__( 'About this snapshot & coverage', 'logged-ai' ) . '

' ) . esc_html( sprintf( /* translators: 1: site ID, 2: network ID, 3: display timezone, 4: snapshot timestamp. */ __( 'Site #%1$s · Network #%2$s · Display timezone: %3$s · Snapshot: %4$s', 'logged-ai' ), $scope->site_id, $scope->network_id, $zone['fallback'] ? sprintf( /* translators: %s: display timezone. */ __( '%s (UTC fallback)', 'logged-ai' ), $time->zone() ) : $time->zone(), $time->text( $now ) ) ) . '

' . esc_html( sprintf( /* translators: 1: inclusive start date, 2: exclusive end date. */ __( 'UTC interval: %1$s inclusive to %2$s exclusive. Current retention may shorten the available evidence.', 'logged-ai' ), $window['from_date'], $window['to_date'] ) ) . ( '

' . esc_html__( 'Overview counts are bounded samples. Static files, cache hits, upstream traffic, erased records and activity while collection is disabled may be absent. No common actor or successful exploit is inferred.', 'logged-ai' ) . '

' ); if ( ! is_wp_error( $events ) ) { echo '

' . esc_html( $events['has_more'] ? __( 'Older events exist beyond the 50 examined records. The significant-change count is a lower bound.', 'logged-ai' ) : __( 'The event scan reached the end of retained records in this interval.', 'logged-ai' ) ) . '

'; } if ( ! is_wp_error( $groups ) ) { echo '

' . esc_html( sprintf( /* translators: 1: partial analyses count, 2: unknown final status count. */ __( 'Partial request analyses: %1$s · Unknown final status: %2$s', 'logged-ai' ), $groups['partial'], $groups['unknown'] ) . ( $groups['has_more'] ? __( ' · More request groups exist.', 'logged-ai' ) : '' ) ) . '

'; } echo '
'; $health_details( $snapshot['health'], $time ); echo '
'; } private static function stat( string $label, string $value, string $note, string $icon, bool $featured = false ): void { echo '
' . esc_html( $label ) . wp_kses( Design::icon( $icon ), Design::allowed_markup() ) . '' . esc_html( $value ) . '' . esc_html( $note ) . '
'; } private static function map( ?array $events, Scope $scope, int $now ): void { $rows = array(); foreach ( $events ?? array() as $event ) { $rows[] = array_intersect_key( $event, array_fill_keys( array( 'id', 'category', 'code', 'occurred_at', 'severity' ), true ) ); } $config = array( 'events' => $rows, 'available' => null !== $events, 'api' => rest_url( 'logged-ai/v1/events' ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'site' => (string) $scope->site_id, 'network' => (string) $scope->network_id, 'eventUrl' => admin_url( 'admin.php?page=logged-ai' ), 'at' => $now ); echo '

' . esc_html__( 'The activity map', 'logged-ai' ) . '

' . esc_html__( 'See where your WordPress activity happens.', 'logged-ai' ) . '

' . ' ' . esc_html__( 'SNAPSHOT', 'logged-ai' ) . '
' ) . wp_kses( Design::mark(), Design::allowed_markup() ) . 'WordPress
'; $map_counts=array_fill_keys(array('identity','content','configuration','commerce','other'),0); foreach($rows as $row){$key=isset($map_counts[$row['category']])?$row['category']:'other';$map_counts[$key]++;} foreach ( array( 'identity' => array( __( 'Users', 'logged-ai' ), 'lock' ), 'content' => array( __( 'Content', 'logged-ai' ), 'reports' ), 'configuration' => array( __( 'Site & plugins', 'logged-ai' ), 'settings' ), 'commerce' => array( __( 'Commerce', 'logged-ai' ), 'requests' ), 'other' => array( __( 'Other activity', 'logged-ai' ), 'activity' ) ) as $category => $item ) { echo ''; } echo '

' . esc_html__( 'Activity categories, not network topology. Live mode checks the latest 50 retained events every 10 seconds while this tab is visible. Overview cards remain a separate snapshot.', 'logged-ai' ) . '

' ); } private static function requests( array|\WP_Error $groups, TimeDisplay $time ): void { echo ( '

' . esc_html__( 'Request signals', 'logged-ai' ) . '

' . esc_html__( 'Latest retained minute groups', 'logged-ai' ) . '

' ) . wp_kses( Design::icon( 'requests' ), Design::allowed_markup() ) . '
'; if ( is_wp_error( $groups ) ) { echo ( '

' . esc_html__( 'Request evidence unavailable.', 'logged-ai' ) . '

' ); } elseif ( ! $groups['groups'] ) { echo ( '

' . esc_html__( 'No retained groups in this interval.', 'logged-ai' ) . '
' . esc_html__( 'Coverage gaps can also produce an empty view.', 'logged-ai' ) . '

' ); } else { echo ''; } echo '

' . esc_html__( 'Explore request findings', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '

'; } private static function health( array $health ): void { $capture = $health['activity_capture']; $control = $health['collection_controls']; $requests = $health['requests']; $warning = 'degraded' === $capture['state'] || 'degraded' === $requests['state'] || 'unavailable' === $requests['state']; echo '
' . wp_kses( Design::icon( 'activity' ), Design::allowed_markup() ) . ( '

' . esc_html__( 'Monitoring status', 'logged-ai' ) . '

' ) . esc_html( $warning ? __( 'Some monitoring needs attention. Open System status for details.', 'logged-ai' ) : __( 'Collection status at this snapshot. Quiet activity does not establish site safety.', 'logged-ai' ) ) . ( '

' . esc_html__( 'Open system status', 'logged-ai' ) . ' ' ) . wp_kses( Design::icon( 'arrow' ), Design::allowed_markup() ) . '
'; } }