Forked from kimwhite/my-pmpro-change-text-for-one-level.php
Last active
November 17, 2022 19:50
-
-
Save michaelbeil/a3dd42ab1b3498c1f7e3b9ffa971313e to your computer and use it in GitHub Desktop.
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 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 = __( 'Access Code', 'pmpro' ); | |
break; | |
case 'Click here to change your discount code': | |
$translated_text = __( 'Click here to change your access code', 'pmpro' ); | |
break; | |
case 'Do you have a discount code?': | |
$translated_text = __( 'Do you have an access code?', 'pmpro' ); | |
break; | |
case 'Click here to enter your discount code': | |
$translated_text = __( 'Click here to enter your access 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