Posted: April 28, 2015 at 9:57 am
|
I’d like to change the word ‘Expired’ which appears on this page: http://www.robinhoodgymnastics.co.uk/events/wednesday-adults-gymnastics-weeks-march-23rd-may-3rd/ I’ve tried using the following code added to the child theme functions.php file: function ee_expired_messaging_changes( $translated, $original, $domain ) { $strings = array( if ( isset( $strings[$original] ) ) { return $translated; add_filter( ‘gettext’, ‘ee_expired_messaging_changes’, 10, 3 ); I’ve also tried using the event-espresso-4-en.mo and editing the wp-config.php using define(‘WPLANG’, ‘en’); unfortunately this is still having no effect (I’m running WordPress Version 4.2.1. Any ideas on how best to make this simple edit? Thanks |
Hi Richard, gettext filters work by looking for an exact match and then changing them. Your example was looking for this messaging: This event has expired or is no longer available. Try this instead: function mycustom_filter_gettext( $translated, $original, $domain ) { // This is an array of original strings // and what they should be replaced with $strings = array( 'Expired' => 'New Messaging 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 ); — |
|
|
Hi Lorenzo, many thanks for getting back to me so quickly. I’ve added this code to my child theme and unfortunately this hasn’t worked (i.e. ‘Expired’ hasn’t changed to ‘Expired NEW’, as a test): function mycustom_filter_gettext( $translated, $original, $domain ) { // This is an array of original strings // See if the current string is in the $strings array return $translated; add_filter( ‘gettext’, ‘mycustom_filter_gettext’, 10, 3 ); Do I need to add this code anywhere else? do you think adding it to the child theme is causing the problem? |
|
Hi Lorenzo, tried everything I can think of this including trawling through all the php core files and can’t get this one word to change. There must be a simple solution to this? thanks |
Hi Richard, Change ‘Expired’ to ‘expired’ and that function will work. However, just to note that will translate the ‘expired’ status that is used throughout the plugin. So anywhere that would display a status of expired will show this new translation not just on the front end. For example looking within the ticket editor – http://take.ms/ijGf4 |
|
|
Thanks Tony, that worked perfectly. I was just hoping I could replace just the single word ‘Expired’ in that specific place with a different phrase. It looks like that’s not possible, but this should do the job for the time being. |
Its currently not possible to edit that status in a specific location without creating your own custom template and function to check the status. I have created a ticket for our developers to discuss possible options for a future version of Event Espresso. |
|
|
Thanks Tony, it would be useful to be able to change the wording. On this particular project anyway. |
The support post ‘Edit QTY 'Expired' word’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.