Advertisement
Apina

EE3 ev list display with early bird

Aug 10th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.37 KB | None | 0 0
  1. <?php
  2. //This is the event list template page.
  3. //This is a template file for displaying an event lsit on a page.
  4. //There should be a copy of this file in your wp-content/uploads/espresso/ folder.
  5. /*
  6. * use the following shortcodes in a page or post:
  7. * [EVENT_LIST]
  8. * [EVENT_LIST limit=1]
  9. * [EVENT_LIST css_class=my-custom-class]
  10. * [EVENT_LIST show_expired=true]
  11. * [EVENT_LIST show_deleted=true]
  12. * [EVENT_LIST show_secondary=false]
  13. * [EVENT_LIST show_recurrence=true]
  14. * [EVENT_LIST category_identifier=your_category_identifier]
  15. *
  16. * Example:
  17. * [EVENT_LIST limit=5 show_recurrence=true category_identifier=your_category_identifier]
  18. *
  19. */
  20.  
  21. //Print out the array of event status options
  22. //print_r (event_espresso_get_is_active($event_id));
  23. //Here we can create messages based on the event status. These variables can be echoed anywhere on the page to display your status message.
  24. $status = event_espresso_get_is_active(0,$event_meta);
  25. $status_display = ' - ' . $status['display_custom'];
  26. $status_display_ongoing = $status['status'] == 'ONGOING' ? ' - ' . $status['display_custom'] : '';
  27. $status_display_deleted = $status['status'] == 'DELETED' ? ' - ' . $status['display_custom'] : '';
  28. $status_display_secondary = $status['status'] == 'SECONDARY' ? ' - ' . $status['display_custom'] : ''; //Waitlist event
  29. $status_display_draft = $status['status'] == 'DRAFT' ? ' - ' . $status['display_custom'] : '';
  30. $status_display_pending = $status['status'] == 'PENDING' ? ' - ' . $status['display_custom'] : '';
  31. $status_display_denied = $status['status'] == 'DENIED' ? ' - ' . $status['display_custom'] : '';
  32. $status_display_expired = $status['status'] == 'EXPIRED' ? ' - ' . $status['display_custom'] : '';
  33. $status_display_reg_closed = $status['status'] == 'REGISTRATION_CLOSED' ? ' - ' . $status['display_custom'] : '';
  34. $status_display_not_open = $status['status'] == 'REGISTRATION_NOT_OPEN' ? ' - ' . $status['display_custom'] : '';
  35. $status_display_open = $status['status'] == 'REGISTRATION_OPEN' ? ' - ' . $status['display_custom'] : '';
  36.  
  37. //You can also display a custom message. For example, this is a custom registration not open message:
  38. $status_display_custom_closed = $status['status'] == 'REGISTRATION_CLOSED' ? ' - <span class="'.espresso_template_css_class('espresso_closed','espresso_closed', false).'">' . __('Registration is closed', 'event_espresso') . '</span>' : '';
  39. global $this_event_id;
  40. $this_event_id = $event_id;
  41. ?>
  42. <div id="event_data-<?php echo $event_id ?>" class="<?php espresso_template_css_class('event_data_display','event_data '.$css_class.' '.$category_identifier.' event-data-display event-list-display event-display-boxes ui-widget'); ?>">
  43. <h3 id="event_title-<?php echo $event_id ?>" class="<?php espresso_template_css_class('event_title','event_title ui-widget-header ui-corner-top'); ?>"><a title="<?php echo stripslashes_deep($event_name) ?>" class="<?php espresso_template_css_class('a_event_title','a_event_title'); ?>" id="a_event_title-<?php echo $event_id ?>" href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event_name) ?></a>
  44. <?php /* These are custom messages that can be displayed based on the event status. Just un-comment the one you want to use. */ ?>
  45. <?php //echo $status_display; //Turn this on to display the overall status of the event. ?>
  46. <?php //echo $status_display_ongoing; //Turn this on to display the ongoing message. ?>
  47. <?php //echo $status_display_deleted; //Turn this on to display the deleted message. ?>
  48. <?php //echo $status_display_secondary; //Turn this on to display the waitlist message. ?>
  49. <?php //echo $status_display_reg_closed; //Turn this on to display the registration closed message. ?>
  50. <?php //echo $status_display_not_open; //Turn this on to display the secondary message. ?>
  51. <?php //echo $status_display_open; //Turn this on to display the not open message. ?>
  52. <?php //echo $status_display_custom_closed; //Turn this on to display the closed message. ?>
  53. </h3>
  54. <div class="<?php espresso_template_css_class('event_data_display','event-data-display ui-widget-content ui-corner-bottom'); ?>">
  55. <?php /* Venue details. Un-comment to display. */ ?>
  56. <?php //echo $venue_title != ''?'<p id="event_venue_name-'.$event_id.'" class="event_venue_name">'.stripslashes_deep($venue_title).'</p>':'' ?>
  57. <?php //echo $venue_address != ''?'<p id="event_venue_address-'.$event_id.'" class="event_venue_address">'.stripslashes_deep($venue_address).'</p>':''?>
  58. <?php //echo $venue_address2 != ''?'<p id="event_venue_address2-'.$event_id.'" class="event_venue_address2">'.stripslashes_deep($venue_address2).'</p>':''?>
  59. <?php //echo $venue_city != ''?'<p id="event_venue_city-'.$event_id.'" class="event_venue_city">'.stripslashes_deep($venue_city).'</p>':''?>
  60. <?php //echo $venue_state != ''?'<p id="event_venue_state-'.$event_id.'" class="event_venue_state">'.stripslashes_deep($venue_state).'</p>':''?>
  61. <?php //echo $venue_zip != ''?'<p id="event_venue_zip-'.$event_id.'" class="event_venue_zip">'.stripslashes_deep($venue_zip).'</p>':''?>
  62. <?php //echo $venue_country != ''?'<p id="event_venue_country-'.$event_id.'" class="event_venue_country">'.stripslashes_deep($venue_country).'</p>':''?>
  63. <?php
  64. //Show short descriptions
  65. if (!empty($event_desc) && isset($org_options['display_short_description_in_event_list']) && $org_options['display_short_description_in_event_list'] == 'Y') {
  66. ?>
  67. <div class="event-desc">
  68.  
  69. <?php echo espresso_format_content($event_desc); ?>
  70. </div>
  71. <?php
  72. }
  73. ?>
  74. <div class="<?php espresso_template_css_class('event_meta','event-meta clearfix'); ?>">
  75. <?php
  76. if ( function_exists('espresso_above_member_threshold') && espresso_above_member_threshold() == true ) {
  77. $event->member_price = empty($event->member_price) ? '' : $event->member_price;
  78. $event_cost = $event->member_price;
  79. } else {
  80. $event->event_cost = empty($event->event_cost) ? '' : $event->event_cost;
  81. $event_cost = $event->event_cost;
  82. }
  83.  
  84.  
  85.  
  86. $early_disc = $event->early_disc;
  87. $early_disc_date = strtotime( $event->early_disc_date );
  88. $early_disc_perc = $event->early_disc_percentage;
  89. $today = strtotime( date('Y-m-d') );
  90.  
  91.  
  92. if( $early_disc != '' && $today <= $early_disc_date ) {
  93. if ( $early_disc_perc == 'Y' ) {
  94. $pr = 100 - $early_disc;
  95. $p = ( $event->event_cost / 100 ) * $pr;
  96.  
  97. echo '<p id="p_event_price-'.$event_id.'" class="'.espresso_template_css_class('event_price','event_price', false).'"><span class="'.espresso_template_css_class('section_title','section-title', false).'">'. __('Price: ', 'event_espresso').'</span> '.$org_options['currency_symbol'].$p.' (including early discount)</p>';
  98.  
  99. }
  100. else {
  101. $p = $event_cost - $early_disc;
  102. echo '<p id="p_event_price-'.$event_id.'" class="'.espresso_template_css_class('event_price','event_price', false).'"><span class="'.espresso_template_css_class('section_title','section-title', false).'">'. __('Price: ', 'event_espresso').'</span> '.$org_options['currency_symbol'].$p.' (including early discount)</p>';
  103. }
  104. }
  105. else {
  106. echo do_action('action_hook_espresso_price_display', $event_id, $event_cost, isset($org_options['price_display_in_event_list']) ? $org_options['price_display_in_event_list'] : 'default' );
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113. //Featured image
  114. echo apply_filters('filter_hook_espresso_display_featured_image', $event_id, !empty($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : '');
  115. //echo do_action('action_hook_espresso_price_display', $event_id, $event_cost, isset($org_options['price_display_in_event_list']) ? $org_options['price_display_in_event_list'] : 'default' );
  116. ?>
  117. <p id="event_date-<?php echo $event_id ?>"><span class="<?php espresso_template_css_class('section_title','section-title'); ?>"><?php _e('Date:', 'event_espresso'); ?></span> <?php echo event_date_display($start_date, get_option('date_format')) ?>
  118. <?php //Add to calendar button
  119. echo apply_filters('filter_hook_espresso_display_ical', $all_meta);?>
  120. </p>
  121. </div>
  122.  
  123. <?php if ( (isset($location) && $location != '' ) && (isset($org_options['display_address_in_event_list']) && $org_options['display_address_in_event_list'] == 'Y') ) { ?>
  124. <p class="<?php espresso_template_css_class('event_address','event_address'); ?>" id="event_address-<?php echo $event_id ?>"><span class="<?php espresso_template_css_class('section_title','section-title'); ?>"><?php echo __('Address:', 'event_espresso'); ?></span> <br />
  125.  
  126. <span class="<?php espresso_template_css_class('address_block','address-block'); ?>">
  127. <?php echo stripslashes_deep($venue_title); ?><br />
  128. <?php echo stripslashes_deep($location); ?>
  129. <span class="<?php espresso_template_css_class('google_map_link','google-map-link'); ?>"><?php echo $google_map_link; ?></span></span>
  130. </p>
  131. <?php
  132. }
  133.  
  134. $num_attendees = apply_filters('filter_hook_espresso_get_num_attendees', $event_id);
  135. if ($num_attendees >= $reg_limit) {
  136. ?>
  137. <p id="available_spaces-<?php echo $event_id ?>" class="<?php espresso_template_css_class('available_spaces','available-spaces'); ?>"><span class="<?php espresso_template_css_class('section_title','section-title'); ?>"><?php _e('Available Spaces:', 'event_espresso') ?> </span><?php echo apply_filters('filter_hook_espresso_available_spaces_text', $event_id) ?></p>
  138. <?php if ($overflow_event_id != '0' && $allow_overflow == 'Y') { ?>
  139. <p id="register_link-<?php echo $overflow_event_id ?>" class="<?php espresso_template_css_class('register_link-footer','register-link-footer'); ?>"><a class="<?php espresso_template_css_class('a_register_link','a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all'); ?>" id="a_register_link-<?php echo $overflow_event_id ?>" href="<?php echo espresso_reg_url($overflow_event_id); ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Join Waiting List', 'event_espresso'); ?></a></p>
  140. <?php
  141. }
  142. } else {
  143. if ($display_reg_form == 'Y' && $externalURL == '') {
  144. ?> <p id="available_spaces-<?php echo $event_id ?>" class="<?php espresso_template_css_class('spaces_available','spaces-available'); ?>"><span class="<?php espresso_template_css_class('section_title','section-title'); ?>"><?php _e('Available Spaces:', 'event_espresso') ?></span> <?php echo apply_filters('filter_hook_espresso_available_spaces_text', $event_id) ?></p>
  145. <?php
  146. }
  147.  
  148. /**
  149. * Load the multi event link.
  150. * */
  151. //Un-comment these next lines to check if the event is active
  152. //echo event_espresso_get_status($event_id);
  153. //print_r( event_espresso_get_is_active($event_id));
  154.  
  155. if ($multi_reg && event_espresso_get_status($event_id) == 'ACTIVE'/* && $display_reg_form == 'Y'*/) {
  156. // Uncomment && $display_reg_form == 'Y' in the line above to hide the add to cart link/button form the event list when the registration form is turned off.
  157.  
  158. $params = array(
  159. //REQUIRED, the id of the event that needs to be added to the cart
  160. 'event_id' => $event_id,
  161. //REQUIRED, Anchor of the link, can use text or image
  162. 'anchor' => __("Add to Cart", 'event_espresso'), //'anchor' => '<img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/cart_add.png" />',
  163. //REQUIRED, if not available at this point, use the next line before this array declaration
  164. // $event_name = get_event_field('event_name', EVENTS_DETAIL_TABLE, ' WHERE id = ' . $event_id);
  165. 'event_name' => $event_name,
  166. //OPTIONAL, will place this term before the link
  167. 'separator' => __(" or ", 'event_espresso')
  168. );
  169.  
  170. $cart_link = event_espresso_cart_link($params);
  171. }else{
  172. $cart_link = false;
  173. }
  174. if ($display_reg_form == 'Y') {
  175. //Check to see if the Members plugin is installed.
  176. $member_options = get_option('events_member_settings');
  177. if ( function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in() && ($member_only == 'Y' || $member_options['member_only_all'] == 'Y') ) {
  178. echo '<p class="'.espresso_template_css_class('ee_member_only','ee_member_only').'">'.__('Member Only Event', 'event_espresso').'</p>';
  179. }else{
  180. ?>
  181. <p id="register_link-<?php echo $event_id ?>" class="<?php espresso_template_css_class('register_link_footer','register-link-footer'); ?>">
  182. <a class="<?php espresso_template_css_class('a_register_link','a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all'); ?>" id="a_register_link-<?php echo $event_id ?>" href="<?php echo $registration_url; ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Register', 'event_espresso'); ?></a>
  183. <?php echo isset($cart_link) && $externalURL == '' ? $cart_link : ''; ?>
  184. </p>
  185. <?php
  186. }
  187. } else {
  188. ?>
  189. <p id="register_link-<?php echo $event_id ?>" class="<?php espresso_template_css_class('register_link_footer','register-link-footer'); ?>">
  190. <a class="<?php espresso_template_css_class('a_register_link','a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all'); ?>" id="a_register_link-<?php echo $event_id ?>" href="<?php echo $registration_url; ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('View Details', 'event_espresso'); ?></a> <?php echo isset($cart_link) && $externalURL == '' ? $cart_link : ''; ?>
  191. </p>
  192.  
  193. <?php
  194. }
  195. }
  196. ?>
  197.  
  198. </div><!-- / .event-data-display -->
  199. </div><!-- / .event-display-boxes -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement