Home › Forums › Calendar Products › Events Calendar PRO › Change text from 'Events for' to 'Classes in' in month view
- This topic has 4 replies, 2 voices, and was last updated 9 years, 11 months ago by Casey D.
-
AuthorPosts
-
May 7, 2014 at 10:19 am #152963belisamaParticipant
I’ve seen several forum questions regarding this, but cannot find a solution for my site. I used the function below (from https://tri.be/support/forums/topic/how-to-change-all-occurance-of-events-to-programs/); however, if I deactivate the plugin for updates it breaks the site (because is_tribe_month() doesn’t exist if the plugin isn’t activated). Is there a way to use this function only when the plugin is active, in case our client deactivates the plugin? Or is there a better method for making this change?
add_filter( ‘gettext’, ‘events_to_classes’ );
function events_to_classes( $txt ) {
//Only override the text on month view
if( tribe_is_month() | tribe_is_week() | tribe_is_day() ) {
$txt = str_replace( ‘Events for’, ‘Classes in’, $txt );
}return $txt;
}May 7, 2014 at 1:29 pm #153099Casey DMemberHello belisama,
Thanks for contacting us!
It seems like you are having two issue in one. I’m not sure you have to deactivate the plugin to update it. Have you run into other problems with that before?
If you don’t deactivate the plugin, I believe you should be fine. If you do deactivate if for short periods, you can comment out the ‘add_filter’ line and the function will never run.
//add_filter( 'gettext', 'events_to_classes' );
To answer your question though, I would use the ‘is_callable()‘ function to see if the tribe functions exist. I unfortunately don’t have time to test this at the moment, but this or something like this should work for your situation.
add_filter( 'gettext', 'events_to_classes' ); function events_to_classes( $txt ) { //Only override the text on month view if( is_callable( 'tribe_is_month' ) && is_callable( 'tribe_is_week' ) && is_callable( 'tribe_is_day' ) ) { if( tribe_is_month() || tribe_is_week() || tribe_is_day() ) { return str_replace( 'Events for', 'Classes in', $txt ); } } return $txt; }
I’m not 100% certain this will work, but I would try this first.
Does this make sense? Let me know if this doesn’t work for you and we can tweak the code.
Cheers!
– Casey Driscoll
May 12, 2014 at 11:25 am #158238belisamaParticipantThanks so much! I am getting some kind of error. Not sure why. It was missing some brackets, so I added them in. This is what I tried:
add_filter( ‘gettext’, ‘events_to_classes’ );
function events_to_classes( $txt ) {
//Only override the text on month view
if( is_callable( ‘tribe_is_month()’ ) && is_callable( ‘tribe_is_week()’ ) && is_callable( ‘tribe_is_day()’ ) ) {
if( tribe_is_month() || tribe_is_week() || tribe_is_day() ) {
return str_replace( ‘Events for’, ‘Classes in’, $txt );
}
return $txt;
}
}May 13, 2014 at 10:03 am #159509Casey DMemberHello belisama,
I believe your last brace is a little out of place. I updated my code to include the proper brace placement.
Cheers!
– Casey Driscoll
May 28, 2014 at 9:15 am #184150Casey DMemberHello belisama,
We typically close threads if there is no activity after two weeks. Feel free to create a new thread and reference this one to save you time.
Cheers!
– Casey Driscoll
-
AuthorPosts
- The topic ‘Change text from 'Events for' to 'Classes in' in month view’ is closed to new replies.