Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created July 19, 2016 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/fbd72127bf1c518f3682dba92a590dd9 to your computer and use it in GitHub Desktop.
Save Pebblo/fbd72127bf1c518f3682dba92a590dd9 to your computer and use it in GitHub Desktop.
An example of how to translate the 'accepted' message shown when using the the Stripe payment method and your payment is acepted.
<?php //Please don't add the opening PHP if you already have one.
function mycustom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Payment Accepted. Please click "Proceed to Finalize Registration" if not forwarded automatically.' => 'You\'re payment has been accepted.',
// Add some more strings here
);
// See if the current string is in the $strings array
// If so, replace its translation
if ( isset( $strings[$original] ) ) {
// This accomplishes the same thing as __()
// but without running it through the filter again
$translations = get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment