Last active
November 15, 2016 22:03
-
-
Save Pebblo/09ae328c3a3d5ee4e190 to your computer and use it in GitHub Desktop.
This function can be used to translate all of the text strings within the default ticket template. Add the function to your themes functions.php file or add it within a site specific plugin. Each line is currently commented out, remove the // from the begging and add your custom text within the right side within ''
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 | |
| //* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
| function ticketstrings_filter_gettext( $translated, $original, $domain ) { | |
| // This is an array of original strings | |
| // and what they should be replaced with | |
| $strings = array( | |
| 'Ticket for' => 'Custom Text', | |
| //'Print Ticket' => '', | |
| //'Download PDF' => '', | |
| //'Print and bring this ticket with you to the event' => '', | |
| //'ID:' => '', | |
| //'Qty.' => '', | |
| //'Location: => '', | |
| //'More Information:' => '', | |
| //'Ticket Instructions:' => '', | |
| //'Powered by the <a href="%s" target="_blank">Event Espresso Ticketing System</a> for WordPress' => '', | |
| // 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', 'ticketstrings_filter_gettext', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment