Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaelbeil/a3dd42ab1b3498c1f7e3b9ffa971313e to your computer and use it in GitHub Desktop.
Save michaelbeil/a3dd42ab1b3498c1f7e3b9ffa971313e to your computer and use it in GitHub Desktop.
<?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