Created
February 14, 2017 11:46
-
-
Save jonathanbossenger/6dc433e8f0dff41e2a9985f7591f286c to your computer and use it in GitHub Desktop.
WooCommerce gettext string replacement example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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