Last active
November 17, 2022 19:47
-
-
Save kimwhite/18182c6050d16488a5cd149fdd7bf514 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* This recipe will change the name of "Discount Code" to something else for one level | |
* | |
* 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 change_discount_code_text( $translated_text, $text, $domain ) { | |
global $pmpro_pages; | |
$pmpro_level = isset( $_REQUEST['level'] ) ? absint( $_REQUEST['level'] ) : 0; | |
if ( is_page( $pmpro_pages['checkout'] ) && $pmpro_level == 5 ) { | |
/* original translated text code */ | |
switch ( $text ) { | |
case 'Discount Code': | |
$translated_text = __( 'Student Code', 'pmpro' ); | |
break; | |
case 'Click here to change your discount code': | |
$translated_text = __( 'Click here to change your student code', 'pmpro' ); | |
break; | |
case 'Do you have a discount code?': | |
$translated_text = __( 'Do you have a student code?', 'pmpro' ); | |
break; | |
case 'Click here to enter your discount code': | |
$translated_text = __( 'Click here to enter your student code', 'pmpro' ); | |
break; | |
} | |
} | |
return $translated_text; | |
/* end original translated text code */ | |
} | |
add_action( 'wp', function() { | |
add_filter( 'gettext', 'change_discount_code_text', 20, 3 ); | |
} ); | |
function change_discount_code_text2( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Click here to change your discount code' : | |
$translated_text = __( 'Click here to change your code', 'paid-memberships-pro' ); | |
break; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'change_discount_code_text2', 20, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment