Пример #1
0
 /**
  * Accepts an array of query arguments, retrieves them, and returns the html for those events in list view
  *
  * Optional inline example:
  * < code >
  * <?php
  * echo myfunction();
  * ?>
  * </ code >
  *
  * @param array $args       Args to be passed to TribeEventsQuery::getEvents()
  * @param bool  $initialize Whether the list view template class needs to be included and initialized
  *
  * @return string
  **/
 function tribe_include_view_list($args = null, $initialize = true)
 {
     global $wp_query;
     // hijack the main query to load the events via provided $args
     if (!is_null($args) || !($wp_query->tribe_is_event || $wp_query->tribe_is_event_category)) {
         $reset_q = $wp_query;
         $wp_query = TribeEventsQuery::getEvents($args, true);
     }
     // single-event notices are jumping in on this init when loading as a module
     TribeEvents::removeNotice('event-past');
     // get the list view template
     ob_start();
     if ($initialize) {
         tribe_initialize_view('Tribe_Events_List_Template');
     }
     tribe_get_view('list/content');
     $list_view_html = ob_get_clean();
     // fix the error of our ways
     if (!empty($reset_q)) {
         $wp_query = $reset_q;
     }
     // return the parsed template
     return $list_view_html;
 }