-
-
Save Pebblo/3f2b7ce0c935ab68836fdd1b73f53245 to your computer and use it in GitHub Desktop.
EE4 WP User integration add-on string translations
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 | |
/* | |
Plugin Name: Site plugin for myexamplesite.com | |
Description: Site specific code for myexamplesite.com | |
*/ | |
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
//This function can be used for custom translations. | |
//The original string on the left, then the translation like this: | |
// 'original => 'translated', | |
function mycustom_filter_gettext( $translated, $original, $domain ) { | |
// This is an array of original strings | |
// and what they should be replaced with | |
$strings = array( | |
'You are only able to edit your information once you have %slogged in%s. If you recently registered, please check your email for your account information which will allow you to log in.' => 'Your custom string 1', | |
'If you did not receive any emails, please %sclick here%s to notify us and we will followup with you to get you setup.' => 'Your custom string 2', | |
// Add some more strings here | |
); | |
// See if the current string is in the $strings array | |
// If so, replace its translation | |
if ( isset( $strings[$original] ) ) { | |
// This accomplishes the same thing as __() | |
// but without running it through the filter again | |
$translations = get_translations_for_domain( $domain ); | |
$translated = $translations->translate( $strings[$original] ); | |
} | |
return $translated; | |
} | |
add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment