Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created June 21, 2021 13:32
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 ipokkel/87d916f6be359497b4a94dfca590d90d to your computer and use it in GitHub Desktop.
Save ipokkel/87d916f6be359497b4a94dfca590d90d to your computer and use it in GitHub Desktop.
Example of how to change a text string using the gettext hook.
<?php
/**
* This recipe is an example of how to change and translate localized text strings
* for PMPro.
*
* 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 gettext_translate_per_text_domain( $translated, $text, $domain ) {
switch ( $domain ) {
case 'paid-memberships-pro':
switch ( $text ) {
case 'If your account is not activated within a few minutes, please contact the site owner.':
// Your custom text string or translation here.
$translated = 'Your text string here.';
break;
}
break;
}
return $translated;
}
add_filter( 'gettext', 'gettext_translate_per_text_domain', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment