← All changes
|
includes/seo/email-report-sections/class-top-winning-posts-section.php
+21
-6
2.5.0
→
2.11.0
View file →
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Top Winning Posts Section | |
| 3 | + * Top Winning Posts Section — "Top growing pages". | |
| 4 | 4 | * |
| 5 | 5 | * Pages with the largest click gain vs the previous period, computed from |
| 6 | 6 | * the shared current-vs-previous comparison the Data Provider builds from |
| 7 | 7 | * Search Console (page dimension). |
| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | return 'top_winning_posts'; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function label(): string { |
| 31 | - return __('Top Winning Posts', 'thinkrank'); | |
| 31 | + return __('Top growing pages', 'thinkrank'); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function default_enabled(): bool { |
| 35 | 35 | return true; |
| @@ -38,8 +38,12 @@ | ||
| 38 | 38 | public function requires_capability(): ?string { |
| 39 | 39 | return null; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + public function renders_own_heading(): bool { | |
| 43 | + return true; | |
| 44 | + } | |
| 45 | + | |
| 42 | 46 | public function collect(array $context): array { |
| 43 | 47 | $shared = $context['shared'] ?? []; |
| 44 | 48 | $comparison = $shared['comparison'] ?? []; |
| 45 | 49 | if (empty($comparison['available']) || empty($comparison['pages'])) { |
| @@ -66,14 +70,25 @@ | ||
| 66 | 70 | 'rows' => array_slice($rows, 0, self::MAX_ROWS), |
| 67 | 71 | ]; |
| 68 | 72 | } |
| 69 | 73 | |
| 74 | + public function has_data(array $payload): bool { | |
| 75 | + return !empty($payload['rows']); | |
| 76 | + } | |
| 77 | + | |
| 70 | 78 | public function render(array $payload): string { |
| 71 | - return Top_Posts_Renderer::render($payload['rows'] ?? [], 'gain'); | |
| 79 | + $rows = Top_Posts_Renderer::page_rows($payload['rows'] ?? []); | |
| 80 | + if ($rows === []) { | |
| 81 | + return ''; | |
| 82 | + } | |
| 83 | + return Email_Report_Html::heading( | |
| 84 | + $this->label(), | |
| 85 | + __('Pages that gained the most clicks vs the previous period', 'thinkrank') | |
| 86 | + ) | |
| 87 | + . Email_Report_Html::list_rows($rows, 'up') | |
| 88 | + . Email_Report_Html::link(__('See all pages', 'thinkrank'), Email_Report_Html::admin_link('analytics', 'dashboard')); | |
| 72 | 89 | } |
| 73 | 90 | |
| 74 | 91 | public function fallback_html(): string { |
| 75 | - return '<p style="color:#6b7280;font-style:italic;">' | |
| 76 | - . esc_html__('Search Console data unavailable. Connect Search Console to see your winning posts.', 'thinkrank') | |
| 77 | - . '</p>'; | |
| 92 | + return ''; | |
| 78 | 93 | } |
| 79 | 94 | } |