Last active
December 13, 2024 06:25
-
-
Save ipokkel/f87c8599e50d25b2efe56725a86c8ef4 to your computer and use it in GitHub Desktop.
Change text or translate Add Name to Checkout Add On #pmpro-add-name-to-checkout
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 changes localized text strings for | |
* Add Name to Checkout Add On using the gettext filter. | |
* | |
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext | |
* | |
* 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/ | |
*/ | |
// Example if translating to French | |
/* | |
case 'First Name': | |
$translated_text = __( 'Prénom', 'pmpro-add-name-to-checkout' ); | |
break; | |
*/ | |
function change_text_for_add_first_last_name_to_checkout( $translated_text, $text, $domain ) { | |
if ( ! function_exists( 'pmproan2c_pmpro_checkout_after_password' ) ) { | |
return $translated_text; | |
} | |
if ( 'paid-memberships-pro' === $domain || 'pmpro' === $domain || 'pmpro-add-name-to-checkout' === $domain ) { | |
switch ( $translated_text ) { | |
case 'First Name': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'Last Name': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'Account Information': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'The first and last name fields are required.': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'The first name field is required.': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'The last name field is required.': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
case 'Your Name': | |
$translated_text = __( 'Your translation here', 'pmpro-add-name-to-checkout' ); | |
break; | |
} | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'change_text_for_add_first_last_name_to_checkout', 20, 3 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment