/** * Pick the correct template to include * @param string $template Path to template * * @return string Path to template */ public static function templateChooser($template) { $events = TribeEvents::instance(); do_action('tribe_tec_template_chooser', $template); // hijack this method right up front if it's a 404 if (is_404() && $events->displaying == 'single-event') { return get_404_template(); } // add the theme slug to the body class add_filter('body_class', array(__CLASS__, 'theme_body_class')); // add the template name to the body class add_filter('body_class', array(__CLASS__, 'template_body_class')); // no non-events need apply // @todo check $wp_query->tribe_is_event_query instead? if (in_array(get_query_var('post_type'), array(TribeEvents::POSTTYPE, TribeEvents::VENUE_POST_TYPE, TribeEvents::ORGANIZER_POST_TYPE)) || is_tax(TribeEvents::TAXONOMY)) { // user has selected a page/custom page template if (tribe_get_option('tribeEventsTemplate', 'default') != '') { if (!is_single() || !post_password_required()) { add_action('loop_start', array(__CLASS__, 'setup_ecp_template')); } $template = locate_template(tribe_get_option('tribeEventsTemplate', 'default') == 'default' ? 'page.php' : tribe_get_option('tribeEventsTemplate', 'default')); if ($template == '') { $template = get_index_template(); } // remove singular body class if sidebar-page.php if ($template == get_stylesheet_directory() . '/sidebar-page.php') { add_filter('body_class', array(__CLASS__, 'remove_singular_body_class')); } else { add_filter('body_class', array(__CLASS__, 'add_singular_body_class')); } } else { $template = self::getTemplateHierarchy('default-template'); } } self::$template = $template; return $template; }