Created
January 14, 2021 16:53
-
-
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
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 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