• Resolved tangobel

    (@tangobel)


    Hi everyone !

    I’m trying to modify the notice that appears when no event is found, which is the following by default :

    “No matching events listed under xxx. Please try viewing the full calendar for a complete list of events.”

    I think I found the sentence here : /wp-content/plugins/the-events-calendar/src/Tribe/Template_Factory.php on line 300 & 305.

    /**
    	 * Sets an appropriate no results found message. This may be overridden in child classes.
    	 */
    	protected function nothing_found_notice() {
    		$events_label_plural = strtolower( tribe_get_event_label_plural() );
    
    		list( $search_term, $tax_term, $geographic_term ) = $this->get_search_terms();
    
    		$tribe = Tribe__Events__Main::instance();
    
    		if ( ! empty( $search_term ) ) {
    			Tribe__Notices::set_notice( 'event-search-no-results', sprintf( esc_html__( 'There were no results found for %s.', 'the-events-calendar' ), '<strong>"' . esc_html( $search_term ) . '"</strong>' ) );
    		} elseif ( ! empty( $geographic_term ) ) {
    			Tribe__Notices::set_notice( 'event-search-no-results', sprintf( esc_html__( 'No results were found for %1$s in or near %2$s.', 'the-events-calendar' ), $events_label_plural, '<strong>"' . esc_html( $geographic_term ) . '"</strong>' ) );
    		} elseif ( ! empty( $tax_term ) && tribe_is_upcoming() && ( date( 'Y-m-d' ) === date( 'Y-m-d', strtotime( $tribe->date ) ) ) ) {
    			Tribe__Notices::set_notice( 'events-not-found', sprintf( esc_html__( 'No upcoming %1$s listed under %2$s. Check out upcoming %3$s for this category or view the full calendar.', 'the-events-calendar' ), $events_label_plural, $tax_term, $events_label_plural ) );
    		} elseif ( ! empty( $tax_term ) && tribe_is_upcoming() ) {
    			Tribe__Notices::set_notice( 'events-not-found', sprintf( esc_html__( 'No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar' ), $events_label_plural, $tax_term, $events_label_plural ) );
    		} elseif ( ! empty( $tax_term ) && tribe_is_past() ) {
    			Tribe__Notices::set_notice( 'events-past-not-found', sprintf( esc_html__( 'No previous %s ', 'the-events-calendar' ), $events_label_plural ) );
    		} // if on any other view and attempting to view a category archive.
    		elseif ( ! empty( $tax_term ) ) {
    			Tribe__Notices::set_notice( 'events-not-found', sprintf( esc_html__( 'No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar' ), $events_label_plural, $tax_term, $events_label_plural ) );
    		} else {
    			Tribe__Notices::set_notice( 'event-search-no-results', esc_html__( 'There were no results found.', 'the-events-calendar' ) );
    		}
    	}

    As the file could easily be overwrited as soon as I’ll update the plugin, could you please advise me anyway to override that notice without modifying that file ?
    The comment says to use a child class, but I don’t really know where and how I should create that one…

    Please notice that I’m using WPML to translate the website in english and french.

    Thanks in advance for you ideas/solutions !

    Cheers,

    Stéphane

    https://wordpress.org/plugins/the-events-calendar/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Brook

    (@brook-tribe)

    Great questions Stephane,

    If I were you I would use a plugin like this to alter that string: https://wordpress.org/plugins/say-what/ That allows you to change most any string in a WordPress plugin, including that one. And it will keep your changes when you update the plugins. Would that work?

    Cheers!
    – Brook

    Thread Starter tangobel

    (@tangobel)

    Hi Brook,

    Thank you so much for your solution !
    I’ve just tried it. It doesn’t fully solve the problemn but let’s say that it’s a first step to get to a solution 🙂

    The plugin allows me to modify the enlgish term without changing anything in the code. That works fine. The problem is that the website is also translated in french (using WPML), and I didn’t find anyway to alternate the french translation with the plugin.

    Do you know if the plugin provides a way to alternate the WPML translation as well ?
    Or, as I first said, is there anyway to override the php Class within the child theme ?

    Thanks again for your support !

    Cheers,

    Stéphane

    PS : happy easter btw 🙂

    nicosantos

    (@nicosantos)

    Hi tangobel,

    Glad Brook could help you out with your issue!

    unfortunately there’s no way to override the PHP classes like you can do with templates. Maybe the WPML folks are able to help you out, reaching out to them sounds like the next step here.

    Hope you can get around this,
    Best,
    Nico

    Thread Starter tangobel

    (@tangobel)

    Hi Nico, I’ve just realize that I never replied to your message. Didn’t want to be rude, sorry.

    Thanks for your reply ! The final customer is happy with the solution brought by Brook, so I don’t need any further help with this 🙂

    No worries at all, @tangobel! Thanks a ton for following up — we’re so stoked to hear that everything is working. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Unable to modify notice when no event is found’ is closed to new replies.