(int) ($traffic['sessions'] ?? 0), 'users' => (int) ($traffic['users'] ?? 0), 'impressions' => (int) ($totals['impressions'] ?? 0), 'clicks' => (int) ($totals['clicks'] ?? 0), 'avg_position' => (float) ($totals['position'] ?? 0.0), 'total_keywords' => (int) (count($search['rows'] ?? [])), ]; } public function render(array $payload): string { $cells = [ __('Sessions', 'thinkrank') => number_format_i18n((int) $payload['sessions']), __('Users', 'thinkrank') => number_format_i18n((int) $payload['users']), __('Impressions', 'thinkrank') => number_format_i18n((int) $payload['impressions']), __('Clicks', 'thinkrank') => number_format_i18n((int) $payload['clicks']), __('Avg. Position', 'thinkrank') => number_format_i18n((float) $payload['avg_position'], 1), __('Tracked Keywords', 'thinkrank') => number_format_i18n((int) $payload['total_keywords']), ]; $html = ''; $i = 0; foreach ($cells as $label => $value) { if ($i % 3 === 0) { $html .= ($i === 0 ? '' : ''); } $html .= ''; $i++; } $html .= '
' . '
' . esc_html($label) . '
' . '
' . esc_html($value) . '
' . '
'; return $html; } public function fallback_html(): string { return '

' . esc_html__('Data temporarily unavailable. Please check your connected integrations.', 'thinkrank') . '

'; } }