Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Last active December 20, 2018 17:53
Show Gist options
  • Save kimcoleman/73d615bea36339ea2fe7d06f1c435e7d to your computer and use it in GitHub Desktop.
Save kimcoleman/73d615bea36339ea2fe7d06f1c435e7d to your computer and use it in GitHub Desktop.
Example of using str_replace for AtlasFoundation ticket
<?php
/**
* This filter will search your codebase for translatable strings and replace when an exact match is found.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* @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 ( 'pmprodon' === $domain ) {
$output_text = str_replace( 'Make a Gift', 'Make a Donation', $output_text );
}
if ( 'paid-memberships-pro' === $domain ) {
$output_text = str_replace( 'I agree to the %s', 'I agree to the <a href="/link-to-page/">%s</a>', $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