Created
June 21, 2021 13:32
-
-
Save ipokkel/87d916f6be359497b4a94dfca590d90d to your computer and use it in GitHub Desktop.
Example of how to change a text string using the gettext hook.
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
<?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