Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. <?php
  2. // Options
  3. $date_format = get_option( 'date_format' );
  4. $time_format = get_option( 'time_format' );
  5. // Load Venue View Helper
  6. EE_Registry::instance()->load_helper('Venue_View');
  7. //Defaults
  8. $reg_button_text = !isset($reg_button_text) ? __('Register', 'event_espresso') : $reg_button_text;
  9. $alt_button_text = !isset($alt_button_text) ? __('View Details', 'event_espresso') : $alt_button_text;//For alternate registration pages
  10. $sold_out_button_text = !isset($sold_out_button_text) ? __('Sold Out', 'event_espresso') : $sold_out_button_text;//For sold out events
  11.  
  12. if ( have_posts() ) :
  13. // allow other stuff
  14. do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
  15. ?>
  16.  
  17. <?php if ($category_filter != 'false'){ ?>
  18. <p class="category-filter">
  19. <label><?php echo __('Category Filter', 'event_espresso'); ?></label>
  20. <select class="" id="ee_filter_cat">
  21. <option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
  22. <?php
  23. $taxonomy = array('espresso_event_categories');
  24. $args = array('orderby'=>'name','hide_empty'=>true);
  25. $ee_terms = get_terms($taxonomy, $args);
  26.  
  27. foreach($ee_terms as $term){
  28. echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
  29. }
  30. ?>
  31. </select>
  32. </p>
  33. <?php } ?>
  34.  
  35. <?php if ($footable != 'false' && $table_search != 'false'){ ?>
  36. <p>
  37. <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
  38. </p>
  39. <?php } ?>
  40.  
  41. <table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
  42. <thead class="espresso-table-header-row">
  43. <tr>
  44. <th class="th-group"><?php _e('Event','event_espresso'); ?></th>
  45. <th class="th-group"><?php _e('Venue','event_espresso'); ?></th>
  46. <th class="th-group"><?php _e('Date','event_espresso'); ?></th>
  47. <th class="th-group"><?php _e('Starting From','event_espresso'); ?></th>
  48. <th class="th-group" data-sort-ignore="true"></th>
  49. </tr>
  50. </thead>
  51. <?php if ($footable != 'false' && $table_paging != 'false'){ ?>
  52. <tfoot>
  53. <tr>
  54. <td colspan="4">
  55. <div class="pagination pagination-centered"></div>
  56. </td>
  57. </tr>
  58. </tfoot>
  59. <?php } ?>
  60. <tbody>
  61.  
  62. <?php
  63. // Start the Loop.
  64. while ( have_posts() ) : the_post();
  65. // Include the post TYPE-specific template for the content.
  66. global $post;
  67.  
  68. //Debug
  69. //d( $post );
  70.  
  71. //Get the category for this event
  72. $event = EEH_Event_View::get_event();
  73. if ( $event instanceof EE_Event ) {
  74. if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
  75. // loop thru terms and create links
  76. $category_slugs = '';
  77. foreach ( $event_categories as $term ) {
  78. $category_slugs[] = $term->slug;
  79. }
  80. $category_slugs = implode(' ', $category_slugs);
  81. } else {
  82. // event has no terms
  83. $category_slugs = '';
  84. }
  85.  
  86. }
  87. //Create the event link
  88. $external_url = $post->EE_Event->external_url();
  89. $button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
  90. $registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
  91.  
  92. //Create the register now button
  93. $live_button = '<a id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';
  94.  
  95. if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
  96. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
  97. }
  98.  
  99.  
  100. $datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
  101.  
  102. $datetime = end( $datetimes );
  103. foreach ( $datetimes as $datetime ) {
  104. $startdat = $datetime->start_date_and_time();
  105. }
  106.  
  107. // grab array of EE_Ticket objects for event
  108. $tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
  109. // grab first ticket from array
  110. $ticket = is_array($tickets)? array_shift( $tickets ): '';
  111. $ticket_price = $ticket instanceof EE_Ticket ? $ticket->pretty_price() : '';
  112. $ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : '';
  113. $tickets_price_free_check = $ticket_price_data_value == 0 ? __('Free','event_espresso') : $ticket_price;
  114. // grab primary datetime for event
  115. $first_datetime = espresso_event_date_obj( $post->ID );
  116. $tickets_left = $first_datetime instanceof EE_Datetime ? $first_datetime->tickets_remaining() : 0;
  117. $tickets_left = $tickets_left === INF ? __('unlimited','event_espresso') : $tickets_left;
  118.  
  119. //let's use date_i18n on the correct offset for the timestamp. Note it seems like we're doing a lot of
  120. //unnecessary conversion but this is so it works with two different pardigmas in the EE core datetime
  121. //system, without users having to worry about updating.
  122. $startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
  123.  
  124. ?>
  125. <tr class="espresso-table-row <?php echo $category_slugs; ?>">
  126. <td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
  127. <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
  128. <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo date_i18n( $date_format . ' ' . $time_format, strtotime( $startdat ) ); ?></td>
  129. <td class="starting_from_pricing event-<?php echo $post->ID; ?>"><?php echo $tickets_price_free_check; ?></td>
  130. <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
  131. </tr>
  132. <?php
  133.  
  134.  
  135. endwhile;
  136. echo '</table>';
  137. // allow moar other stuff
  138. do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
  139.  
  140. else :
  141. // If no content, include the "No posts found" template.
  142. espresso_get_template_part( 'content', 'none' );
  143.  
  144. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement