Advertisement
Guest User

espresso-events-table-template

a guest
Apr 18th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 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.  
  18.  
  19. <?php if ($footable != 'false' && $table_search != 'false'){ ?>
  20. <p>
  21. <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
  22. </p>
  23. <?php } ?>
  24.  
  25. <table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
  26. <thead class="espresso-table-header-row">
  27. <tr>
  28. <th class="th-group"><?php _e('Date','event_espresso'); ?></th>
  29. <th class="th-group"><?php _e('Goes on Sale','event_espresso'); ?></th>
  30. <th class="th-group"><?php _e('Event','event_espresso'); ?></th>
  31. <th class="th-group"><?php _e('Venue','event_espresso'); ?></th>
  32.  
  33. <th class="th-group" data-sort-ignore="true"><?php _e('Anmelden','event_espresso'); ?></th>
  34. </tr>
  35. </thead>
  36. <?php if ($footable != 'false' && $table_paging != 'false'){ ?>
  37. <tfoot>
  38. <tr>
  39. <td colspan="5">
  40. <div class="pagination pagination-centered"></div>
  41. </td>
  42. </tr>
  43. </tfoot>
  44. <?php } ?>
  45. <tbody>
  46.  
  47. <?php
  48. // Start the Loop.
  49. while ( have_posts() ) : the_post();
  50. // Include the post TYPE-specific template for the content.
  51. global $post;
  52.  
  53. //Debug
  54. //d( $post );
  55.  
  56. //Get the category for this event
  57. $event = EEH_Event_View::get_event();
  58. if ( $event instanceof EE_Event ) {
  59. if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
  60. // loop thru terms and create links
  61. $category_slugs = '';
  62. foreach ( $event_categories as $term ) {
  63. $category_slugs[] = $term->slug;
  64. }
  65. $category_slugs = implode(' ', $category_slugs);
  66. } else {
  67. // event has no terms
  68. $category_slugs = '';
  69. }
  70.  
  71. }
  72. //Create the event link
  73. $external_url = $post->EE_Event->external_url();
  74. $button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
  75. $registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
  76.  
  77. //Create the register now button
  78. $live_button = '<a id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';
  79.  
  80. if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
  81. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
  82. }
  83.  
  84.  
  85. $datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
  86.  
  87. $datetime = end( $datetimes );
  88.  
  89. if ( ! ($event->is_sold_out() || $event->is_sold_out( TRUE ) ) )
  90. {
  91.  
  92. // grab array of EE_Ticket objects for event
  93. $tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
  94.  
  95. // grab first ticket from array
  96. $ticket = reset( $tickets );
  97. //check if the ticket is free, if set the ticket price to 'Free'
  98. if ( $ticket instanceof EE_Ticket )
  99. {
  100. $ticket_price = $ticket->pretty_price();
  101. $ticket_price_data_value = $ticket->price();
  102. $ticket_price = $ticket_price_data_value == 0 ? __( 'Free', 'event_espresso' ) : $ticket_price;
  103. }
  104.  
  105. //Get the remaining ticket values for the next datetime.
  106. $tickets_remaining = $datetime->tickets_remaining() === EE_INF ? __('Unlimited','event_espresso') : $datetime->tickets_remaining();
  107. } else {
  108.  
  109. //The event is sold out, set the ticket price to 'N/A'
  110. $ticket_price = __( 'N/A', 'event_espresso');
  111. }
  112.  
  113. //let's use date_i18n on the correct offset for the timestamp. Note it seems like we're doing a lot of
  114. //unnecessary conversion but this is so it works with two different pardigmas in the EE core datetime
  115. //system, without users having to worry about updating.
  116. $startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
  117.  
  118. ?>
  119.  
  120. <tr class="espresso-table-row <?php echo $category_slugs; ?>">
  121. <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
  122. <td class="goes_on_sale_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $date_format); ?></td>
  123. <td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
  124. <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
  125. <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
  126. </tr>
  127. <?php
  128.  
  129.  
  130. endwhile;
  131. echo '</table>';
  132. // allow moar other stuff
  133. do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
  134.  
  135. else :
  136. // If no content, include the "No posts found" template.
  137. espresso_get_template_part( 'content', 'none' );
  138.  
  139. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement