Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Created October 6, 2020 20:30
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 MaryOJob/0009770e8b94f394d5c90fa50290ecb5 to your computer and use it in GitHub Desktop.
Save MaryOJob/0009770e8b94f394d5c90fa50290ecb5 to your computer and use it in GitHub Desktop.
Change some of the text strings in PMPro Sponsored Members Add On via the WP gettext filter.
<?php // Do not copy this line
/**
* This filter will search your codebase for translatable strings and replace when an exact match is found.
*
* Here we're changing 'Number of Seats' to 'Number of Dependents/Spouse/Children' for Sponsored Members.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*
* @param string $output_text this represents the end result
* @param string $input_text what is written in the code that we want to change
* @param string $domain text-domain of the plugin/theme that contains the code
*
* @return string the result of the text transformation
*/
function my_gettext_membership( $output_text, $input_text, $domain ) {
if ( ! is_admin() && 'pmpro-sponsored-members' === $domain ) {
$output_text = str_replace( 'Number of Seats', 'Number of Dependents/Spouse/Children', $output_text );
}
return $output_text;
}
add_filter( 'gettext', 'my_gettext_membership', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment