Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active May 26, 2023 00:57
Show Gist options
  • Save ipokkel/26a19aac8b9da822106711c64f0eb9c2 to your computer and use it in GitHub Desktop.
Save ipokkel/26a19aac8b9da822106711c64f0eb9c2 to your computer and use it in GitHub Desktop.
<?php
/**
* This recipe changes text strings with the gettext filter.
* Can be used to change text or translate specific text strings.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function change_text_or_translate_with_gettext_1611665660189( $translated, $text, $domain ) {
switch ( $domain ) {
case 'paid-memberships-pro':
switch ( $text ) {
case 'Site administrators must use the WordPress dashboard to update their email address.':
$translated = 'Your translation here.';
break;
case 'Please enter your username or email address. You will receive a link to create a new password via email.':
$translated = 'Your translation here.';
break;
case 'Username or Email Address':
$translated = 'Your translation here.';
break;
case 'Get New Password':
$translated = 'Your translation here.';
break;
case 'Lost Password?':
$translated = 'Your translation here.';
break;
case 'Lost Password':
$translated = 'Your translation here.';
break;
case 'Log In':
$translated = 'Your translation here.';
break;
case 'Log Out':
$translated = 'Your translation here.';
break;
case 'Paid':
$translated = 'Your translation here.';
break;
case '<strong>%1$s every %2$d %3$s</strong>':
$translated = '<strong>%1$s your-translation-here %2$d %3$s</strong>';
break;
case 'The price for membership is <strong>%1$s every %2$d %3$s</strong>.':
$translated = 'The price for membership is <strong>%1$s your-translation-here %2$d %3$s</strong>.';
break;
}
break;
}
return $translated;
}
add_filter( 'gettext', 'change_text_or_translate_with_gettext_1611665660189', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment