PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.0
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.7.0, at includes/seo/email-report-sections/interface-email-report-section.php

90 lines 2.7 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 * Retained for compatibility with sections written against 1.9. The
50 * registry no longer consults it; return null.
51 */
52 public function requires_capability(): ?string;
53
54 /**
55 * Pull the data needed to render this section.
56 *
57 * Receives a context with the site URL, period, and any pre-fetched
58 * data the orchestrator chooses to share. Throwing an exception is fine
59 * — the renderer catches and falls back. Returning an empty payload
60 * also triggers fallback HTML.
61 *
62 * @param array $context {
63 * @type string $site_url Site URL (home_url()).
64 * @type string $period_start ISO datetime.
65 * @type string $period_end ISO datetime.
66 * @type int $frequency_days Frequency the report is being sent at.
67 * @type array $shared Cross-section cached data, e.g. shared GSC pulls.
68 * }
69 * @return array Payload chunk consumed by render().
70 */
71 public function collect(array $context): array;
72
73 /**
74 * Render the section's HTML given the payload from collect().
75 *
76 * Must return safe HTML — the renderer wraps the result in a section
77 * shell but does not re-sanitize. Use wp_kses_post() / esc_html() for
78 * any data interpolated from collect().
79 */
80 public function render(array $payload): string;
81
82 /**
83 * HTML rendered when collect() returns empty or throws.
84 *
85 * Per PRD: "If any data source is unavailable, render with a fallback
86 * message rather than failing the entire report."
87 */
88 public function fallback_html(): string;
89 }
90