Change the terms link text in emails

📅 Published on

📝 Last updated

Documentation

»

Code Samples

»

Change the terms link text in emails

Changes the text of the terms link in the legacy email footer. Does not apply when using the footer block.

<?php
/**
 * Modifies the "Terms" text to "Terms & Conditions" in the footer context.
 *
 * @param string $translated_text The translated text.
 * @param string $text                    The original text before translation.
 * @param string $domain              The text domain.
 * @return string                              The modified text.
 */
function gh_change_footer_terms( string $translated_text, string $text, string $domain ): string {
    // Only apply the replacement in the footer context and for a specific text domain (if applicable).
    if ( 'footer' === $domain || in_array( $domain, [ 'your-theme-text-domain', 'default' ], true ) ) {
        if ( 'Terms' === $text ) {
            return 'Terms & Conditions';
        }
    }

    return $translated_text;
}
add_filter( 'gettext', 'gh_change_footer_terms', 20, 3 );

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.