Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active August 29, 2015 14:16
Show Gist options
  • Save Pebblo/348c67446db6b2b453d3 to your computer and use it in GitHub Desktop.
Save Pebblo/348c67446db6b2b453d3 to your computer and use it in GitHub Desktop.
Place this function within your themes functions.php file or within a site specific plugin.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function mycustom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Please choose a payment option' => 'Please select the Paypal icon below to be taken to the Paypay site for payment',
// 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