Skip to content

Instantly share code, notes, and snippets.

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 jonathanbossenger/6dc433e8f0dff41e2a9985f7591f286c to your computer and use it in GitHub Desktop.
Save jonathanbossenger/6dc433e8f0dff41e2a9985f7591f286c to your computer and use it in GitHub Desktop.
WooCommerce gettext string replacement example.
function xx_woo_text_strings( $translated_text, $text, $domain ) {
if ('woocommerce' == $domain){
$strings = array('Coupons' => 'Vouchers', 'Coupon Code' => 'Voucher Code');
foreach ($strings as $original => $updated) {
$string_found = stristr($translated_text, $original);
if( $string_found !== FALSE ) {
$translated_text = str_ireplace($original, $updated, $translated_text);
break;
}
}
}
return $translated_text;
}
add_filter( 'gettext', 'xx_woo_text_strings', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment