Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/2bcfaa2924697da3ac2183b58307be6a to your computer and use it in GitHub Desktop.
Save JarrydLong/2bcfaa2924697da3ac2183b58307be6a to your computer and use it in GitHub Desktop.
Change text or translate Add Name to Checkout Add On #pmpro-add-name-to-checkout
<?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