-
-
Save cliffordp/82836c507db01515745db6e5172f4f76 to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* The Events Calendar (V2 Views): Remove the "This event has passed." notice from single events. | |
* | |
* FYI: There are other places this same notice displays, such as embed view. To remove the notice from everywhere, | |
* remove the code snippet's "if..." logic. | |
* | |
* @link https://gist.github.com/cliffordp/82836c507db01515745db6e5172f4f76 This snippet. | |
* @link https://share.getcloudapp.com/YEud5m7d Screenshot of the notice that gets removed. | |
*/ | |
function tec_remove_is_a_past_event_notice_on_event_single() { | |
/** @var \Tribe\Events\Views\V2\Template_Bootstrap $template */ | |
$template = tribe( \Tribe\Events\Views\V2\Template_Bootstrap::class ); | |
if ( $template->is_single_event() ) { | |
Tribe__Notices::remove_notice( 'event-past' ); | |
} | |
} | |
add_action( 'tribe_pre_get_view', 'tec_remove_is_a_past_event_notice_on_event_single' ); |
@benklocek, if you have Events Calendar Pro, you could just use a shortcode: https://theeventscalendar.com/knowledgebase/k/events-calendar-pro-widget-shortcodes-overview/
But since you're trying to integrate to a third-party thing, these might help accomplish whatever you're doing:
- https://gist.github.com/cliffordp/9994cf05f6475922f451eaeacef2cd3c (specific to your request but only for v2)
- https://gist.github.com/cliffordp/98d438e52a1a95a9fea3e862c426b399 (specific to your request but only for v1)
- https://gist.github.com/cliffordp/39e68939132bd0f483e0111972165455 (overriding template loading location)
Oh, so close! That first gist almost does it. It pulls in the V1 templates, instead of the V2.
I haven't figured out a way to use a widget, as I'm creating a customized version of "Featured Events" based on a query variable for an organizer. The organizers are embedding a community calendar on their site, and we are "Featuring" their next two events just for them.
I hit enter too soon, then GitHub went down for a short bit... I just now updated my previous reply.
Beyond what I've shared here, you'll have to continue on your own, especially with the custom scenario you're working within.
Good luck!
One of your colleges sent this and I'm set:
$engine = new \Tribe__Template(); $engine->set_template_origin( tribe( 'tec.main' ) ) ->set_template_folder( 'src/views/v2' ) ->set_template_folder_lookup( true ) ->set_template_context_extract( true );
Then I'm using it like this with the results of a query:
$engine->template( 'list/event', [ 'event' => tribe_get_event( $event->ID ) ] );
👍
Yeah! That does the trick. Thank you, Clifford!
Thanks also for pointing me to the /tribe-ext-events-happening-now plugin. There is lots there for me to work with.
I love you guys!
🥳
Hi Clifford,
I've been trying to figure out a way to pull in one of the V2 templates into my plugin for TEC, and this gist is the only bit that gives me hope.
Is there a way to use the Template_Bootstrap class to load the V2/list/event.php template within a WP_Query foreach loop? The templates all rely on being in an object context, since they use $this, but I can't figure out how to load them within the template context so the $this->template object is set.
Thanks!