Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active August 8, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/a2aa913c7fa894ff9723c7084d8d1530 to your computer and use it in GitHub Desktop.
Save joshfeck/a2aa913c7fa894ff9723c7084d8d1530 to your computer and use it in GitHub Desktop.
Examples of changing wait list add-on strings. Event Espresso 4 + wait list add-on.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function my_waitlist_filter_gettext( $translated, $original, $domain ) {
if( $domain == 'event_espresso' ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Sign Up For The Wait List' => 'Join the Wait list', // button text
'Join Now' => 'Wait List Form', // main heading
'If you would like to be added to the wait list for this event, then please enter your name and email address, and we will contact you when spaces become available.'
=> 'Please enter your information and we\'ll be in touch.',
'Preferred Option' => 'Preference', // field label
'Join The Wait List' => 'Sign me up', // submit button text
// 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', 'my_waitlist_filter_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment