Skip to content

Instantly share code, notes, and snippets.

@MWDelaney
Created September 18, 2017 20:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MWDelaney/bc159335bee5f1b38061e2dfeeac044b to your computer and use it in GitHub Desktop.
Save MWDelaney/bc159335bee5f1b38061e2dfeeac044b to your computer and use it in GitHub Desktop.
{{--
Template Name: Events
--}}
@extends('layouts.app')
@section('content')
<div id="tribe-events-pg-template">
<?php tribe_events_before_html(); ?>
<?php tribe_get_view(); ?>
<?php tribe_events_after_html(); ?>
</div> <!-- #tribe-events-pg-template -->
@endsection
<?php
Namespace App;
/**
* The Events Calendar drop-in functionality for Sage 9
* Version: 1.0
* Author: Michael W. Delaney
*/
/**
* Set Sage-friendly The Events Calendar template
*/
if(class_exists('Tribe__Settings_Manager')) {
// Set the The Events Calendar default template to our Sage-friendly template.
\Tribe__Settings_Manager::set_option( 'tribeEventsTemplate', 'views/template-events.blade.php' );
}
/**
* Menu highlighting for The Events Calendar pages
*/
add_filter( 'nav_menu_css_class', function ($classes = array(), $menu_item = false){
// Check if the current queried page is an event, or the events archive, and whether the current item in the filter is '/events/'
if((is_singular('tribe_events') || is_post_type_archive('tribe_events')) && $menu_item->url == '/events/') {
$classes[] ='current-page-ancestor';
}
// The filter also wants to highlight the "Posts" archive. Stop it from doing that.
if((is_singular('tribe_events') || is_post_type_archive('tribe_events')) && $menu_item->url == get_post_type_archive_link( 'post' )) {
if(($key = array_search('current_page_parent', $classes)) !== false) {
unset($classes[$key]);
}
}
// Return the correct classes for this menu item.
return $classes;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment