Skip to content

Update "get help" email translations within Email Report templates #12479

@benbowler

Description

@benbowler

Feature Description

The anchor html should be included within the translation string with classes inserted later as discussed here

__( 'We were unable to generate your reports due to insufficient permissions in Search Console. To fix this, contact your administrator or %1$sget help%2$s.', 'google-site-kit' ),
__( 'Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ),
),
'error-email-permissions-analytics-4' => array(
/* translators: 1: opening anchor tag for help link, 2: closing anchor tag */
__( 'We were unable to generate your reports due to insufficient permissions in Analytics. To fix this, contact your administrator or %1$sget help%2$s.', 'google-site-kit' ),
__( 'Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ),
),
'error-email-report-search-console' => array(
/* translators: 1: opening anchor tag for settings link, 2: closing anchor tag, 3: opening anchor tag for help link, 4: closing anchor tag */
__( 'We were unable to generate your report because data loading failed for Search Console. To fix this, go to %1$sSearch Console settings%2$s in Site Kit or %3$sget help%4$s.', 'google-site-kit' ),
__( 'Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ),
),
'error-email-report-analytics-4' => array(
/* translators: 1: opening anchor tag for settings link, 2: closing anchor tag, 3: opening anchor tag for help link, 4: closing anchor tag */
__( 'We were unable to generate your report because data loading failed for Analytics. To fix this, go to %1$sAnalytics settings%2$s in Site Kit or %3$sget help%4$s.', 'google-site-kit' ),
__( 'Report delivery will automatically resume once the issue is resolved.', 'google-site-kit' ),


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Error email translation strings contain complete anchor tags with href placeholder(s) instead of separate opening/closing tag placeholders
  • Inline styles (e.g. link color) are injected after translation, not within the translatable string
  • HTML and plain text email output remains visually identical to current behavior
  • Existing wp_kses allowlist in the HTML template continues to sanitize anchor tags correctly

Implementation Brief

Backend

  • Update file includes/Core/Email_Reporting/Content_Map.php

    • Refactor the four error email body strings to use inline <a href="%s"> within the translation string instead of separate opening/closing tag placeholders:
      • error-email-permissions-search-console: change to single %s href placeholder
      • error-email-permissions-analytics-4: change to single %s href placeholder
      • error-email-report-search-console: change to two %s href placeholders (settings link + help link)
      • error-email-report-analytics-4: change to two %s href placeholders (settings link + help link)
    • Update translator comments to reflect the new placeholder format (e.g. /* translators: %s: "get help" link URL */)
    • Add a new static method add_inline_link_styles( string $html ) that post-processes translated body paragraphs to inject inline styles onto anchor tags:
      • Match <a tags and add class="link" and style="color:#108080;" attributes
      • This replaces the current pattern of baking styles into the get_body_args return values
    • Refactor get_body_args() to return only the URL strings (not full <a> opening/closing tags):
      • error-email-permissions-*: return array( $help_url )
      • error-email-report-*: return array( $settings_url, $help_url )
    • Apply add_inline_link_styles() in get_body_with_args() to each paragraph after vsprintf substitution
  • Update file includes/Core/Email_Reporting/Batch_Error_Notifier.php

    • Verify no changes needed — this file calls Content_Map::get_body_args() and Content_Map::get_body_with_args() which will handle the new format transparently
  • Update file includes/Core/Email_Reporting/templates/simple-email/parts/content.php

    • Verify the existing wp_kses allowlist for anchor tags already permits href, style, and class attributes — add class to the allowlist if missing

Test Coverage

  • Update file tests/phpunit/integration/Core/Email_Reporting/Content_MapTest.php
    • Update test_get_body_with_args_substitutes_placeholders and error-email-related assertions to match new string format (inline anchors instead of separate open/close tags)
    • Add test for add_inline_link_styles method: verify styles are injected on anchor tags
    • Add test that error email body paragraphs after get_body_with_args contain complete <a href="..."> tags with inline styles
    • Add test that Plain_Text_Formatter::convert_links_to_text correctly extracts URLs from the new format

QA Brief

Changelog entry

Metadata

Metadata

Assignees

Labels

P2Low priorityTeam SIssues for Squad 1Type: EnhancementImprovement of an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions