Skip to content

Instantly share code, notes, and snippets.

@tradesouthwest
Created October 28, 2018 01:45
Show Gist options
  • Save tradesouthwest/3271b680db9fe000bf0d90d780e0c550 to your computer and use it in GitHub Desktop.
Save tradesouthwest/3271b680db9fe000bf0d90d780e0c550 to your computer and use it in GitHub Desktop.
gettext example for wordpress to replace translated text
add_filter( 'gettext', 'misha_change_text_with_gettext', 20, 3 );
function misha_change_text_with_gettext( $translated_text, $text, $domain ) {
if ( is_admin()
&& isset($_GET['post'])
&& get_post_type( $_GET['post'] ) == 'shop_order'
&& $domain == 'woocommerce' ) {
if( $translated_text == 'Shipping' ) {
$translated_text = 'Delievery';
}
}
return $translated_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment