From 35e699e0af317298a7847b4b2e4190608918a27e Mon Sep 17 00:00:00 2001 From: Ben Bowler Date: Wed, 1 Apr 2026 15:27:15 +0100 Subject: [PATCH 1/3] Review and correct error email title copy to match spreadsheet. --- includes/Core/Email_Reporting/Content_Map.php | 14 +++++++------- .../Email_Reporting/Batch_Error_NotifierTest.php | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/includes/Core/Email_Reporting/Content_Map.php b/includes/Core/Email_Reporting/Content_Map.php index 3302eac5d2f..ea4f642adca 100644 --- a/includes/Core/Email_Reporting/Content_Map.php +++ b/includes/Core/Email_Reporting/Content_Map.php @@ -155,10 +155,13 @@ public static function get_graphic_config( $template_name ) { protected static function get_all_titles() { return array( /* translators: 1: opening anchor tag with mailto link, 2: inviter email address, 3: closing anchor tag */ - 'invitation-email' => __( '%1$s%2$s%3$s invited you to receive periodic performance reports', 'google-site-kit' ), - 'subscription-confirmation' => __( 'Success! You’re subscribed to Site Kit reports', 'google-site-kit' ), - 'error-email' => __( 'Email reports are failing to send', 'google-site-kit' ), - 'error-email-cron-scheduler' => __( 'Email reports are failing to send', 'google-site-kit' ), + 'invitation-email' => __( '%1$s%2$s%3$s invited you to receive periodic performance reports', 'google-site-kit' ), + 'subscription-confirmation' => __( 'Success! You’re subscribed to Site Kit reports', 'google-site-kit' ), + 'error-email' => __( 'Email reports are failing to send', 'google-site-kit' ), + 'error-email-permissions-search-console' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), + 'error-email-permissions-analytics-4' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), + 'error-email-report-search-console' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), + 'error-email-report-analytics-4' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), ); } @@ -184,9 +187,6 @@ protected static function get_all_bodies() { 'error-email' => array( __( 'We were unable to generate your report due to a server error. To fix this, contact your host. Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ), ), - 'error-email-cron-scheduler' => array( - __( 'We were unable to deliver your report, likely due to a WP-Cron configuration error in your WordPress site’s system settings. To fix this, contact your administrator or get help. Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ), - ), // Opening/closing tag placeholders keep inline styles and HTML // out of translation strings. Inline color styles are required // because many email clients strip or ignore CSS classes. diff --git a/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php b/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php index 22ac6b2ded8..4653afd260e 100644 --- a/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php +++ b/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php @@ -305,8 +305,7 @@ public function test_uses_module_specific_content_when_available( $category_id, self::factory()->user->create( array( 'role' => 'administrator' ) ); $this->set_up_batch_with_category_and_module( $category_id, $module_slug ); - // Module-specific titles were removed; all error emails use the generic error-email title. - $expected_subject = Content_Map::get_title( 'error-email' ); + $expected_subject = Content_Map::get_title( $expected_content_key ); $this->batch_query->expects( $this->once() ) ->method( 'mark_batch_admin_notified' ) From 16c5ddab628d0ab78f9a37565b8ff83de46b6509 Mon Sep 17 00:00:00 2001 From: Ben Bowler Date: Wed, 1 Apr 2026 15:56:47 +0100 Subject: [PATCH 2/3] Update error email title copy and move get_body_args to Content_Map for the tester plugin to access. --- .../Email_Reporting/Batch_Error_Notifier.php | 51 +--------------- includes/Core/Email_Reporting/Content_Map.php | 58 +++++++++++++++++-- 2 files changed, 55 insertions(+), 54 deletions(-) diff --git a/includes/Core/Email_Reporting/Batch_Error_Notifier.php b/includes/Core/Email_Reporting/Batch_Error_Notifier.php index 3b67a3d5de6..77ef7038ce3 100644 --- a/includes/Core/Email_Reporting/Batch_Error_Notifier.php +++ b/includes/Core/Email_Reporting/Batch_Error_Notifier.php @@ -271,7 +271,7 @@ private function build_template_data( $content_key ) { $title = Content_Map::get_title( 'error-email' ); } - $body_args = $this->get_body_args( $content_key ); + $body_args = Content_Map::get_body_args( $content_key, $this->golinks ); $body = Content_Map::get_body_with_args( $content_key, $body_args ); $domain = $this->get_site_domain(); @@ -299,55 +299,6 @@ private function build_template_data( $content_key ) { ); } - /** - * Gets sprintf arguments for Content_Map body placeholders. - * - * Maps each content key to the URLs that fill its `%s` / `%1$s` / `%2$s` - * placeholders. Keys without placeholders return an empty array. - * - * @since 1.175.0 - * - * @param string $content_key Content_Map key. - * @return array Ordered sprintf arguments for the body paragraphs. - */ - private function get_body_args( $content_key ) { - $link_style = 'color:#108080;'; - $help_url = add_query_arg( 'doc', 'email-reporting', 'https://sitekit.withgoogle.com/support/' ); - - // URLs are internally generated (golinks, add_query_arg) and safe. - // Escaping is handled by wp_kses() in the HTML template and - // wp_strip_all_tags() in the plain text renderer. - switch ( $content_key ) { - case 'error-email-report-search-console': - $settings_url = add_query_arg( 'module', 'search-console', $this->golinks->get_url( 'settings' ) ); - return array( - '', - '', - '', - '', - ); - - case 'error-email-report-analytics-4': - $settings_url = add_query_arg( 'module', 'analytics-4', $this->golinks->get_url( 'settings' ) ); - return array( - '', - '', - '', - '', - ); - - case 'error-email-permissions-search-console': - case 'error-email-permissions-analytics-4': - return array( - '', - '', - ); - - default: - return array(); - } - } - /** * Gets the site domain including subdirectory context. * diff --git a/includes/Core/Email_Reporting/Content_Map.php b/includes/Core/Email_Reporting/Content_Map.php index ea4f642adca..f2f5181390e 100644 --- a/includes/Core/Email_Reporting/Content_Map.php +++ b/includes/Core/Email_Reporting/Content_Map.php @@ -10,6 +10,8 @@ namespace Google\Site_Kit\Core\Email_Reporting; +use Google\Site_Kit\Core\Golinks\Golinks; + /** * Class for mapping email template content (titles and body). * @@ -158,10 +160,10 @@ protected static function get_all_titles() { 'invitation-email' => __( '%1$s%2$s%3$s invited you to receive periodic performance reports', 'google-site-kit' ), 'subscription-confirmation' => __( 'Success! You’re subscribed to Site Kit reports', 'google-site-kit' ), 'error-email' => __( 'Email reports are failing to send', 'google-site-kit' ), - 'error-email-permissions-search-console' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), - 'error-email-permissions-analytics-4' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), - 'error-email-report-search-console' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), - 'error-email-report-analytics-4' => __( 'Action needed: your Site Kit report couldn\'t be generated', 'google-site-kit' ), + 'error-email-permissions-search-console' => __( 'Action needed: your Site Kit report couldn’t be generated', 'google-site-kit' ), + 'error-email-permissions-analytics-4' => __( 'Action needed: your Site Kit report couldn’t be generated', 'google-site-kit' ), + 'error-email-report-search-console' => __( 'Action needed: your Site Kit report couldn’t be generated', 'google-site-kit' ), + 'error-email-report-analytics-4' => __( 'Action needed: your Site Kit report couldn’t be generated', 'google-site-kit' ), ); } @@ -212,4 +214,52 @@ protected static function get_all_bodies() { ), ); } + + /** + * Gets sprintf arguments for body placeholders. + * + * Maps each content key to the styled anchor tags that fill its + * `%s` / `%1$s` / `%2$s` placeholders. Keys without placeholders + * return an empty array. + * + * @since n.e.x.t + * + * @param string $content_key Content key (e.g. 'error-email-report-analytics-4'). + * @param Golinks $golinks Golinks instance for building URLs. + * @return array Ordered sprintf arguments for the body paragraphs. + */ + public static function get_body_args( $content_key, Golinks $golinks ) { + $link_style = 'color:#108080;'; + $help_url = add_query_arg( 'doc', 'email-reporting', 'https://sitekit.withgoogle.com/support/' ); + + switch ( $content_key ) { + case 'error-email-report-search-console': + $settings_url = add_query_arg( 'module', 'search-console', $golinks->get_url( 'settings' ) ); + return array( + '', + '', + '', + '', + ); + + case 'error-email-report-analytics-4': + $settings_url = add_query_arg( 'module', 'analytics-4', $golinks->get_url( 'settings' ) ); + return array( + '', + '', + '', + '', + ); + + case 'error-email-permissions-search-console': + case 'error-email-permissions-analytics-4': + return array( + '', + '', + ); + + default: + return array(); + } + } } From 423974c8863cc3a983fff2cca766da5b4eeb4fa4 Mon Sep 17 00:00:00 2001 From: Ben Bowler Date: Wed, 1 Apr 2026 16:01:51 +0100 Subject: [PATCH 3/3] Remove unused error types. --- includes/Core/Email_Reporting/Batch_Error_Notifier.php | 2 -- .../Core/Email_Reporting/Batch_Error_NotifierTest.php | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/Core/Email_Reporting/Batch_Error_Notifier.php b/includes/Core/Email_Reporting/Batch_Error_Notifier.php index 77ef7038ce3..9b40c5b123a 100644 --- a/includes/Core/Email_Reporting/Batch_Error_Notifier.php +++ b/includes/Core/Email_Reporting/Batch_Error_Notifier.php @@ -35,7 +35,6 @@ class Batch_Error_Notifier { const NON_SENDABLE_CATEGORIES = array( 'sending_error', 'cron_scheduler_error', - 'other_error', ); /** @@ -47,7 +46,6 @@ class Batch_Error_Notifier { const CATEGORY_CONTENT_MAP = array( 'permissions_error' => 'permissions', 'report_error' => 'report', - 'network_error' => 'network', 'server_error' => 'server', ); diff --git a/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php b/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php index 4653afd260e..1213919e1d4 100644 --- a/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php +++ b/tests/phpunit/integration/Core/Email_Reporting/Batch_Error_NotifierTest.php @@ -98,7 +98,6 @@ public function data_non_sendable_categories() { return array( 'sending_error' => array( 'sending_error' ), 'cron_scheduler_error' => array( 'cron_scheduler_error' ), - 'other_error' => array( 'other_error' ), ); } @@ -133,7 +132,6 @@ public function data_sendable_categories() { return array( 'permissions_error' => array( 'permissions_error', 'error-email' ), 'report_error' => array( 'report_error', 'error-email' ), - 'network_error' => array( 'network_error', 'error-email' ), 'server_error' => array( 'server_error', 'error-email' ), ); } @@ -357,9 +355,9 @@ public function test_falls_back_to_generic_error_when_no_module_match() { public function test_falls_back_to_generic_error_for_unknown_module() { self::factory()->user->create( array( 'role' => 'administrator' ) ); - $this->set_up_batch_with_category_and_module( 'network_error', 'some-unknown-module' ); + $this->set_up_batch_with_category_and_module( 'server_error', 'some-unknown-module' ); - // No module-specific body for network_error + some-unknown-module, falls back to generic error-email. + // No module-specific body for server_error + some-unknown-module, falls back to generic error-email. $expected_subject = Content_Map::get_title( 'error-email' ); $this->email_sender->method( 'build_headers' )->willReturn( array() );