Created
January 23, 2018 22:15
-
-
Save ideadude/830c50eb8e3d76483cae066796f7074b to your computer and use it in GitHub Desktop.
Example showing how to replace strings in the PMPro Sponsored Members Add On
This file contains hidden or 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
/* | |
Replace strings in the PMPro Sponsored Members Add On | |
Add this code to a custom plugin. | |
Note we check for 2 different but similar text domains. We SHOULD | |
set our text domains to match the slug of the plugin, but in this | |
case we used underscores instead of dashes and need to support both | |
for backwards compatability. | |
The original text must match exactly how it shows up in the code. | |
Search the code on GitHub to see how the strings are built. | |
https://github.com/strangerstudios/pmpro-sponsored-members | |
*/ | |
function my_pmprosm_string_replacement($translated_text, $original_text, $domain) { | |
if(($domain == 'pmpro_sponsored_members' || $domain == 'pmpro-sponsored-members') | |
&& $original_text == 'Would you like to purchase extra seats?') { | |
$translated_text = 'How many students do you need to add?'; | |
} | |
return $translated_text; | |
} | |
add_filter('gettext', 'my_pmprosm_string_replacement', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment