Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created January 14, 2021 16:53
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/1803f5ff011c8232daba6f89c8be90a6 to your computer and use it in GitHub Desktop.
Save ipokkel/1803f5ff011c8232daba6f89c8be90a6 to your computer and use it in GitHub Desktop.
Change the Discount Code text strings if a specific level is in the querystring parameter of the URL #gettext
<?php
/**
* This recipe will change the Discount Code text strings if a specific
* level is specified as a querystring parameter in the URL.
*
* 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 my_pmpro_discount_code_text_strings_1610643091698( $translated_text, $text, $domain ) {
// Dont change text if we're not on the level checkout for the AppSumo deal.
if ( isset( $_REQUEST['level'] ) && 4 != $_REQUEST['level'] ) {
return $translated_text;
}
// Do you have a discount code?
// Click here to enter your discount code
switch ( $translated_text ) {
case 'Discount Code':
$translated_text = __( 'AppSumo Code', 'paid-memberships-pro' );
break;
case 'Do you have a discount code?':
$translated_text = __( 'Do you have an AppSumo redemption code', 'paid-memberships-pro' );
break;
case 'Click here to enter your discount code':
$translated_text = __( 'Click here to redeem your AppSumo code', 'paid-memberships-pro' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_pmpro_discount_code_text_strings_1610643091698', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment