(int) ($dist['top_3'] ?? 0), '4_10' => (int) ($dist['4_10'] ?? 0), '11_50' => (int) ($dist['10_50'] ?? 0), // GSC's `10_50` bucket starts at 11 '51_100' => (int) ($dist['51_100'] ?? 0), ]; } public function has_data(array $payload): bool { return array_sum(array_map('intval', $payload)) > 0; } public function render(array $payload): string { $counts = [ 'top_3' => (int) ($payload['top_3'] ?? 0), '4_10' => (int) ($payload['4_10'] ?? 0), '11_50' => (int) ($payload['11_50'] ?? 0), '51_100' => (int) ($payload['51_100'] ?? 0), ]; $total = array_sum($counts); if ($total === 0) { return ''; } $page_one = $counts['top_3'] + $counts['4_10']; $html = Email_Report_Html::heading( $this->label(), sprintf( /* translators: %s: number of queries. */ _n('%s query got at least one impression this period', '%s queries got at least one impression this period', $total, 'thinkrank'), number_format_i18n($total) ) ); $html .= '' . Email_Report_Html::bar_row(__('Top 3', 'thinkrank'), $counts['top_3'], $total, Email_Report_Html::PRIMARY) . Email_Report_Html::bar_row(__('Positions 4–10', 'thinkrank'), $counts['4_10'], $total, '#6e79ff') . Email_Report_Html::bar_row(__('Positions 11–50', 'thinkrank'), $counts['11_50'], $total, '#b3b9ff') . Email_Report_Html::bar_row(__('Positions 51–100', 'thinkrank'), $counts['51_100'], $total, '#dcdfff') . '
'; $html .= Email_Report_Html::note(sprintf( /* translators: %s: number of queries ranking in positions 1–10. */ _n('%s query is on page one.', '%s queries are on page one.', $page_one, 'thinkrank'), number_format_i18n($page_one) )); $html .= Email_Report_Html::link(__('See all keywords', 'thinkrank'), Email_Report_Html::admin_link('analytics', 'keywords')); return $html; } public function fallback_html(): string { return ''; } }