Forked from ipokkel/change-add-first-last-name-to-checkout.php
Created
December 13, 2024 06:25
-
-
Save JarrydLong/273f95c5b3593f3025406e6fea842664 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 ( 'paid-memberships-pro' === $domain || 'pmpro' === $domain || 'pmpro-add-name-to-checkout' === $domain ) { | |
switch ( $translated_text ) { | |
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