| @@ -1,14 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Email Report Settings Configuration |
| 4 | 4 | * |
| 5 | - * Default per-site configuration + field schema for the Email Reporting feature. | |
| 6 | - * Used by Email_Report_Config (load/save), the renderer (templating), and the | |
| 7 | - * REST endpoint (validation args). | |
| 5 | + * Default stored state and section catalog for the Email Reporting feature. | |
| 8 | 6 | * |
| 9 | - * Free vs. Pro field availability is NOT decided here — it lives in | |
| 10 | - * `Plan_Config::email_report()`. This file only describes shape and defaults. | |
| 7 | + * The free report is fixed: every 30 days, to the site admin email, with every | |
| 8 | + * section. Only the on/off switch and the schedule timestamps are stored. | |
| 9 | + * Schedule, recipients and branding settings belong to ThinkRank Pro, which | |
| 10 | + * supplies them through the `thinkrank_email_report_config`, | |
| 11 | + * `thinkrank_email_report_subject_template` and `thinkrank_email_report_payload` | |
| 12 | + * filters (#673). | |
| 11 | 13 | * |
| 12 | 14 | * @package ThinkRank |
| 13 | 15 | * @subpackage Config |
| 14 | 16 | * @since 1.9.0 |
| @@ -20,105 +22,54 @@ | ||
| 20 | 22 | exit; |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | /** |
| 24 | - * Default Email Reporting per-site config. | |
| 26 | + * Default stored Email Reporting state. | |
| 25 | 27 | * |
| 26 | - * Pre-fills sensible values for a fresh install. Free plan never overrides | |
| 27 | - * paid-only fields once saved; they sit dormant in the DB so they re-light | |
| 28 | - * if the user upgrades. | |
| 29 | - * | |
| 30 | - * @return array | |
| 28 | + * @return array{enabled: bool, next_scheduled_at: ?string, last_sent_at: ?string} | |
| 31 | 29 | */ |
| 32 | 30 | function thinkrank_get_default_email_report_config(): array { |
| 33 | 31 | return [ |
| 34 | - 'enabled' => false, | |
| 35 | - 'frequency_days' => 30, | |
| 36 | - 'recipients' => [(string) get_option('admin_email')], | |
| 37 | - 'subject_template' => '%site_title% SEO performance report', | |
| 38 | - 'logo_url' => null, | |
| 39 | - 'logo_link' => null, | |
| 40 | - 'header_background' => null, | |
| 41 | - 'link_to_full_report' => true, | |
| 42 | - 'intro_text' => null, | |
| 43 | - 'sections_enabled' => array_keys(thinkrank_get_email_report_default_sections()), | |
| 44 | - 'footer_text' => null, | |
| 45 | - 'additional_css' => null, | |
| 46 | - 'next_scheduled_at' => null, | |
| 47 | - 'last_sent_at' => null, | |
| 32 | + 'enabled' => false, | |
| 33 | + 'next_scheduled_at' => null, | |
| 34 | + 'last_sent_at' => null, | |
| 48 | 35 | ]; |
| 49 | 36 | } |
| 50 | 37 | |
| 51 | 38 | /** |
| 52 | - * Default section ordering + free/pro flag. | |
| 39 | + * Built-in sections, in render order. | |
| 53 | 40 | * |
| 54 | - * Keys here are the section identifiers used everywhere — in the sections_enabled | |
| 55 | - * array of the per-site config, in the Section_Registry, and in template paths. | |
| 41 | + * Keys here are the section identifiers used everywhere — in the | |
| 42 | + * sections_enabled list of the resolved config, in the Section_Registry, and | |
| 43 | + * in template paths. `site_traffic` and `ai_search` render only when their | |
| 44 | + * source (a GA4 property, the AI traffic tracker) has something to show. | |
| 56 | 45 | * |
| 57 | - * The order in this array is the order sections render. Pro can re-order via | |
| 58 | - * `thinkrank_email_report_sections` filter; AI Highlights inserts at the top. | |
| 59 | - * | |
| 60 | - * @return array<string,array{label:string,requires_capability:?string}> | |
| 46 | + * @return array<string,array{label:string}> | |
| 61 | 47 | */ |
| 62 | 48 | function thinkrank_get_email_report_default_sections(): array { |
| 63 | 49 | return [ |
| 64 | 50 | 'key_metrics' => [ |
| 65 | - 'label' => __('Key Metrics', 'thinkrank'), | |
| 66 | - 'requires_capability' => null, | |
| 51 | + 'label' => __('Search performance', 'thinkrank'), | |
| 67 | 52 | ], |
| 68 | - 'position_summary' => [ | |
| 69 | - 'label' => __('Position Summary', 'thinkrank'), | |
| 70 | - 'requires_capability' => null, | |
| 53 | + 'top_winning_posts' => [ | |
| 54 | + 'label' => __('Top growing pages', 'thinkrank'), | |
| 71 | 55 | ], |
| 72 | - 'top_winning_posts' => [ | |
| 73 | - 'label' => __('Top Winning Posts', 'thinkrank'), | |
| 74 | - 'requires_capability' => null, | |
| 56 | + 'top_winning_keywords' => [ | |
| 57 | + 'label' => __('Top growing queries', 'thinkrank'), | |
| 75 | 58 | ], |
| 76 | 59 | 'top_losing_posts' => [ |
| 77 | - 'label' => __('Top Losing Posts', 'thinkrank'), | |
| 78 | - 'requires_capability' => null, | |
| 60 | + 'label' => __('Pages losing ground', 'thinkrank'), | |
| 79 | 61 | ], |
| 80 | - 'top_winning_keywords' => [ | |
| 81 | - 'label' => __('Top Winning Keywords', 'thinkrank'), | |
| 82 | - 'requires_capability' => null, | |
| 62 | + 'top_losing_keywords' => [ | |
| 63 | + 'label' => __('Queries losing ground', 'thinkrank'), | |
| 83 | 64 | ], |
| 84 | - 'top_losing_keywords' => [ | |
| 85 | - 'label' => __('Top Losing Keywords', 'thinkrank'), | |
| 86 | - 'requires_capability' => null, | |
| 65 | + 'position_summary' => [ | |
| 66 | + 'label' => __('Where your keywords rank', 'thinkrank'), | |
| 87 | 67 | ], |
| 88 | - ]; | |
| 89 | -} | |
| 90 | - | |
| 91 | -/** | |
| 92 | - * Tokens supported in subject/intro/footer text. | |
| 93 | - * | |
| 94 | - * Each token resolves at render time against the report context. Pro can add | |
| 95 | - * tokens via the `thinkrank_email_report_tokens` filter (e.g. %client_name%). | |
| 96 | - * | |
| 97 | - * @return array<string,string> token => human description | |
| 98 | - */ | |
| 99 | -function thinkrank_get_email_report_tokens(): array { | |
| 100 | - return [ | |
| 101 | - '%site_title%' => __('Site title from WordPress general settings', 'thinkrank'), | |
| 102 | - '%site_url%' => __('Home URL of the site', 'thinkrank'), | |
| 103 | - '%date%' => __('Date the report is sent (localized)', 'thinkrank'), | |
| 104 | - '%period%' => __('Reporting period label, e.g. "May 1 – May 30"', 'thinkrank'), | |
| 105 | - ]; | |
| 106 | -} | |
| 107 | - | |
| 108 | -/** | |
| 109 | - * Maximum lengths for free-text fields. Defense-in-depth limits to keep | |
| 110 | - * a misconfigured Pro plugin or pasted bulk content from blowing up the email. | |
| 111 | - * | |
| 112 | - * @return array<string,int> | |
| 113 | - */ | |
| 114 | -function thinkrank_get_email_report_field_limits(): array { | |
| 115 | - return [ | |
| 116 | - 'subject_template' => 200, | |
| 117 | - 'intro_text' => 5000, | |
| 118 | - 'footer_text' => 5000, | |
| 119 | - 'additional_css' => 20000, | |
| 120 | - 'logo_url' => 2048, | |
| 121 | - 'logo_link' => 2048, | |
| 122 | - 'header_background' => 500, | |
| 68 | + 'site_traffic' => [ | |
| 69 | + 'label' => __('Site traffic (Google Analytics 4)', 'thinkrank'), | |
| 70 | + ], | |
| 71 | + 'ai_search' => [ | |
| 72 | + 'label' => __('Traffic from AI assistants', 'thinkrank'), | |
| 73 | + ], | |
| 123 | 74 | ]; |
| 124 | 75 | } |