PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.0.2
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.0.2
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / includes / seo / email-report-sections / interface-email-report-section.php

interface-email-report-section.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.0.2, at includes/seo/email-report-sections/interface-email-report-section.php

93 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Email Report Section Interface
4 *
5 * Contract every section in the email report must implement. The renderer
6 * walks the registry, calls collect() then render() on each registered
7 * section, and falls back to fallback_html() if either throws.
8 *
9 * Extension model: the Pro plugin (or any other plugin) registers new
10 * sections via the `thinkrank_email_report_register_sections` action,
11 * implementing this interface. Free code never needs to know about them.
12 *
13 * @package ThinkRank
14 * @subpackage SEO\Email_Report_Sections
15 * @since 1.9.0
16 */
17
18 declare(strict_types=1);
19
20 namespace ThinkRank\SEO\Email_Report_Sections;
21
22 if (!defined('ABSPATH')) {
23 exit;
24 }
25
26 /**
27 * Email_Report_Section_Interface
28 *
29 * @since 1.9.0
30 */
31 interface Email_Report_Section_Interface {
32
33 /**
34 * Section identifier — also the key used in sections_enabled array.
35 */
36 public function key(): string;
37
38 /**
39 * Localized label shown in the "Sections to Include" UI.
40 */
41 public function label(): string;
42
43 /**
44 * Whether this section is on by default for a fresh install.
45 */
46 public function default_enabled(): bool;
47
48 /**
49 * The Plan_Config capability required to render this section.
50 *
51 * Return null for free sections. AI Highlights returns 'ai_highlights'.
52 * The renderer skips sections whose capability is not satisfied without
53 * raising an error — no surprises if a downgrade hides a Pro section.
54 */
55 public function requires_capability(): ?string;
56
57 /**
58 * Pull the data needed to render this section.
59 *
60 * Receives a context with the site URL, period, and any pre-fetched
61 * data the orchestrator chooses to share. Throwing an exception is fine
62 * — the renderer catches and falls back. Returning an empty payload
63 * also triggers fallback HTML.
64 *
65 * @param array $context {
66 * @type string $site_url Site URL (home_url()).
67 * @type string $period_start ISO datetime.
68 * @type string $period_end ISO datetime.
69 * @type int $frequency_days Frequency the report is being sent at.
70 * @type array $shared Cross-section cached data, e.g. shared GSC pulls.
71 * }
72 * @return array Payload chunk consumed by render().
73 */
74 public function collect(array $context): array;
75
76 /**
77 * Render the section's HTML given the payload from collect().
78 *
79 * Must return safe HTML — the renderer wraps the result in a section
80 * shell but does not re-sanitize. Use wp_kses_post() / esc_html() for
81 * any data interpolated from collect().
82 */
83 public function render(array $payload): string;
84
85 /**
86 * HTML rendered when collect() returns empty or throws.
87 *
88 * Per PRD: "If any data source is unavailable, render with a fallback
89 * message rather than failing the entire report."
90 */
91 public function fallback_html(): string;
92 }
93