Change text from 'Events for' to 'Classes in' in month view

Home Forums Calendar Products Events Calendar PRO Change text from 'Events for' to 'Classes in' in month view

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #152963
    belisama
    Participant

    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;
    }

    #153099
    Casey D
    Member

    Hello 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

    #158238
    belisama
    Participant

    Thanks 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;
    }
    }

    #159509
    Casey D
    Member

    Hello 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

    #184150
    Casey D
    Member

    Hello 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Change text from 'Events for' to 'Classes in' in month view’ is closed to new replies.