Advertisement
mrkameren

espresso-events-table-template.template.php

Mar 10th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 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. $category_filter_text = !isset($category_filter_text) ? __('Category Filter', 'event_espresso') : $category_filter_text;
  12.  
  13. if ( have_posts() ) :
  14. // allow other stuff
  15. do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
  16. ?>
  17.  
  18. <?php if ($category_filter != 'false'){ ?>
  19. <p class="category-filter">
  20. <label><?php echo $category_filter_text; ?></label>
  21. <select class="" id="ee_filter_cat">
  22. <option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
  23. <?php
  24. $taxonomy = array('espresso_event_categories');
  25. $args = array('orderby'=>'name','hide_empty'=>true);
  26. $ee_terms = get_terms($taxonomy, $args);
  27.  
  28. foreach($ee_terms as $term){
  29. echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
  30. }
  31. ?>
  32. </select>
  33. </p>
  34. <?php } ?>
  35.  
  36. <?php if ($footable != 'false' && $table_search != 'false'){ ?>
  37. <p>
  38. <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
  39. </p>
  40. <?php } ?>
  41.  
  42. <table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
  43. <thead class="espresso-table-header-row">
  44. <tr>
  45. <th class="th-group"><?php _e('Course','event_espresso'); ?></th>
  46. <?php if( $show_venues ) { ?>
  47. <th class="th-group"><?php _e('Location','event_espresso'); ?></th>
  48. <?php } ?>
  49. <th class="th-group"><?php _e('Date','event_espresso'); ?></th>
  50. <th class="th-group" data-sort-ignore="true"></th>
  51. </tr>
  52. </thead>
  53. <?php if ($footable != 'false' && $table_paging != 'false'){ ?>
  54. <tfoot>
  55. <tr>
  56. <?php echo '<td colspan="' . ($show_venues ? '4' : '3') . '">'; ?>
  57. <div class="pagination pagination-centered"></div>
  58. </td>
  59. </tr>
  60. </tfoot>
  61. <?php } ?>
  62. <tbody>
  63.  
  64. <?php
  65. // Start the Loop.
  66. while ( have_posts() ) : the_post();
  67. // Include the post TYPE-specific template for the content.
  68. global $post;
  69.  
  70. //Debug
  71. //d( $post );
  72.  
  73. //Get the category for this event
  74. $event = EEH_Event_View::get_event();
  75. if ( $event instanceof EE_Event ) {
  76. if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
  77. // loop thru terms and create links
  78. $category_slugs = array();
  79. foreach ( $event_categories as $term ) {
  80. $category_slugs[] = $term->slug;
  81. }
  82. $category_slugs = implode(' ', $category_slugs);
  83. } else {
  84. // event has no terms
  85. $category_slugs = '';
  86. }
  87.  
  88. }
  89. //Create the event link
  90. $external_url = $post->EE_Event->external_url();
  91. $button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
  92. $registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
  93.  
  94. //Create the register now button
  95. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link" href="'.$registration_url.'">'.$button_text.'</a>';
  96.  
  97. if ( $event->is_sold_out() ) {
  98. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out a_register_link" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
  99. }
  100.  
  101. // If the show_all_datetimes parameter is set set the limit to NULL to pull them all,
  102. // if not default to only display a single datetime.
  103. $datetime_limit = $show_all_datetimes ? NULL : 1;
  104.  
  105. // Pull the datetimes for this event order by start_date/time
  106. $datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, $datetime_limit );
  107.  
  108. // Reset the datetimes pointer to the earliest datetime and use that one.
  109. $datetime = reset( $datetimes );
  110. if ($datetime instanceof EE_Datetime) {
  111. ?>
  112. <tr class="espresso-table-row <?php echo $category_slugs; ?>">
  113. <td class="event_title event-<?php echo $post->ID; ?>"><?php echo '<a href='.$registration_url.' style=text-decoration:underline>'; ?><?php echo $post->post_title; ?></a></td>
  114. <?php if( $show_venues ) { ?>
  115. <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
  116. <?php } ?>
  117. <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>">
  118. <ul class="ee-table-view-datetime-list">
  119. <?php
  120. // Loop over each datetime we have pulled from the database and output
  121. foreach ($datetimes as $datetime) {
  122. ?>
  123. <li class="datetime-id-<?php echo $datetime->ID(); ?>">
  124. <?php echo date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) ); ?>
  125. </li>
  126. <?php
  127. //end foreach $datetimes
  128. }
  129. ?>
  130. </ul>
  131. </td>
  132. <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
  133. </tr>
  134. <?php
  135. }
  136. endwhile;
  137. echo '</table>';
  138. // allow moar other stuff
  139. do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
  140.  
  141. else :
  142. // If no content, include the "No posts found" template.
  143. espresso_get_template_part( 'content', 'none' );
  144.  
  145. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement