Skip to content

Instantly share code, notes, and snippets.

@rynaldos
Created April 18, 2023 10:57
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 rynaldos/bce4e58a611e1e5394a1a95b108e9cdf to your computer and use it in GitHub Desktop.
Save rynaldos/bce4e58a611e1e5394a1a95b108e9cdf to your computer and use it in GitHub Desktop.
Gettext filter example
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'students' :
$translated_text = __( 'clients', 'woocommerce' );
break;
case 'courses' :
$translated_text = __( 'programs', 'woocommerce' );
break;
case 'teachers' :
$translated_text = __( 'counsellors', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment