Unable to modify notice when no event is found
-
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
- The topic ‘Unable to modify notice when no event is found’ is closed to new replies.