sseme

SSEME3 - 201014

Oct 20th, 2014
187
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Plugin Name: Event Espresso Template - Calendar Table
  4. Plugin URI: http://www.eventespresso.com
  5. Description: This template creates a list of events, displayed in a table. It can display events by category and/or maximum number of days. [EVENT_CUSTOM_VIEW template_name="calendar-table" max_days="30" category_identifier="concerts"]
  6. Version: 1.1
  7. Author: Event Espresso
  8. Author URI: http://www.eventespresso.com
  9. Copyright 2013 Event Espresso (email : support@eventespresso.com)
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License, version 2, as
  13. published by the Free Software Foundation.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
  23.  
  24. */
  25.  
  26. //Requirements: CSS skills to customize styles, some renaming of the table columns, Espresso WP User Add-on (optional)
  27. // Parameter: show_featured=true/false. If set to true, the dates will be replaced with the featured images.
  28. // Parameter: change_title="something". If set the Band/Artist default title will be change to the string provided.
  29.  
  30. //The end of the action name (example: "action_hook_espresso_custom_template_") should match the name of the template. In this example, the last part the action name is "calendar-table",
  31. add_action('action_hook_espresso_custom_template_calendar-table','espresso_custom_template_calendar_table');
  32.  
  33. function espresso_custom_template_calendar_table(){
  34.  
  35. global $org_options, $this_event_id, $events, $ee_attributes;
  36.  
  37. //Extract shortcode attributes, if any.
  38. extract($ee_attributes);
  39.  
  40. if(isset($ee_attributes['show_featured'])) { $show_featured = $ee_attributes['show_featured']; }
  41.  
  42. if(isset($ee_attributes['change_title'])) { $change_title = $ee_attributes['change_title']; }
  43.  
  44. //Load the css file
  45. wp_register_style( 'espresso_cal_table_css', WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/style.css' );
  46. wp_enqueue_style( 'espresso_cal_table_css');
  47.  
  48. //Clears the month name
  49. $temp_month = '';
  50.  
  51. //Uncomment to view the data being passed to this file
  52. //echo '<h4>$events : <pre>' . print_r($events,true) . '</pre> <span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
  53.  
  54. ?>
  55.  
  56. <table class="cal-table-list">
  57. <?php
  58. foreach ($events as $event){
  59. //Debug
  60. $this_event_id = $event->id;
  61. $this_event_desc = explode('<!--more-->', $event->event_desc);
  62. $this_event_desc = array_shift($this_event_desc);
  63. $member_only = !empty($event->member_only) ? $event->member_only : '';
  64. $event_meta = unserialize($event->event_meta);
  65. $externalURL = $event->externalURL;
  66. $registration_url = !empty($externalURL) ? $externalURL : espresso_reg_url($event->id);
  67. $live_button = '<a id="a_register_link-'.$event->id.'" href="'.$registration_url.'"><img class="buytix_button" src="'.WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/register-now.png" alt="Buy Tickets"></a>';
  68. if ( ! has_filter( 'filter_hook_espresso_get_num_available_spaces' ) ){
  69. $open_spots = apply_filters('filter_hook_espresso_get_num_available_spaces', $event->id); //Available in 3.1.37
  70. }else{
  71. $open_spots = get_number_of_attendees_reg_limit($event->id, 'number_available_spaces');
  72. }
  73. $featured_image = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : FALSE;
  74. $event_status = event_espresso_get_status($event->id);
  75.  
  76. if($open_spots < 1 && $event->allow_overflow == 'N') {
  77. $live_button = '<img class="buytix_button" src="'.WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/closed.png" alt="Closed">';
  78. } else if ($open_spots < 1 && $event->allow_overflow == 'Y'){
  79. $live_button = !empty($event->overflow_event_id) ? '<a href="'.espresso_reg_url($event->overflow_event_id).'"><img class="buytix_button" src="'.WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/waiting.png" alt="Join Waiting List"></a>' : '<img class="buytix_button" src="'.WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/closed.png" alt="Closed">';
  80. }
  81.  
  82. if ( isset($event_status) && $event_status == 'NOT_ACTIVE' ) {
  83. $live_button = '<img class="buytix_button" src="'.WP_PLUGIN_URL. "/".plugin_basename(dirname(__FILE__)) .'/closed.png" alt="Closed">';
  84. }
  85.  
  86. //Build the table headers
  87. $full_month = event_date_display($event->start_date, "F");
  88. if ($temp_month != $full_month){
  89. ?>
  90. <tr class="cal-header-month">
  91. <th class="cal-header-month-name" id="calendar-header-<?php echo $full_month; ?>" colspan="3"><?php echo $full_month; ?></th>
  92. </tr>
  93. <tr class="cal-header">
  94. <th><?php echo !isset($show_featured) || $show_featured === 'false' ? __('Date','event_espresso') : '' ?></th>
  95. <th class="th-event-info"><?php if(isset($change_title)) { echo $change_title; } else { _e('Band / Artist','event_espresso'); } ?></th>
  96. <th class="th-tickets"><?php _e('Enter Event','event_espresso'); ?></th>
  97. </tr>
  98. <?php
  99. $temp_month = $full_month;
  100. }
  101.  
  102. //Gets the member options, if the Members add-on is installed.
  103. $member_options = get_option('events_member_settings');
  104.  
  105. //If enough spaces exist then show the form
  106. //Check to see if the Members plugin is installed.
  107. if ( function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in() && ($member_only == 'Y' || $member_options['member_only_all'] == 'Y') ) {
  108. event_espresso_user_login();
  109. }else{
  110. ?>
  111. <tr class="event-row" id="event-row-<?php echo $this_event_id; ?>">
  112.  
  113.  
  114. <?php
  115.  
  116. if(isset($show_featured ) && $show_featured === 'true') { ?>
  117. <td class="td-fet-image"><div class="">
  118. <img src="<?php echo $featured_image; ?>" />
  119. </div></td>
  120. <?php } else { ?>
  121. <td class="td-date-holder"><div class="dater">
  122. <div class="cal-day-title"><?php echo event_date_display($event->start_date, "l"); ?></div>
  123. <div class="cal-day-num"><?php echo event_date_display($event->start_date, "j"); ?></div>
  124. <div><span><?php echo event_date_display($event->start_date, "M"); ?></span></div>
  125. <?php } ?>
  126. </div>
  127. </td>
  128.  
  129. <td class="td-event-info"><span class="event-title"><a href="<?php echo $registration_url ?>"><?php echo stripslashes_deep($event->event_name); ?></a></span>
  130. <p>
  131. <?php _e('When:', 'event_espresso'); ?>
  132. <?php echo event_date_display($event->start_date); ?><br />
  133. <?php _e('Where:', 'event_espresso'); ?>
  134. <?php echo stripslashes_deep($event->venue_name); ?><br />
  135. <?php _e('Price: ', 'event_espresso'); ?>
  136. <?php echo $org_options['currency_symbol'].$event->event_cost; ?> </p>
  137. </td>
  138. <td class="td-event-register"><?php echo $live_button ?><?php echo apply_filters('filter_hook_espresso_display_ical', (array)$event ); ?></td>
  139. </tr>
  140. <?php
  141. }// close is_user_logged_in
  142. } //close foreach ?>
  143. </table>
  144. <?php
  145. }
  146.  
  147. /**
  148. * hook into PUE updates
  149. */
  150. //Update notifications
  151. add_action('action_hook_espresso_template_calendar_table_update_api', 'espresso_template_calendar_table_load_pue_update');
  152. function espresso_template_calendar_table_load_pue_update() {
  153. global $org_options, $espresso_check_for_updates;
  154. if ( $espresso_check_for_updates == false )
  155. return;
  156.  
  157. if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'class/pue/pue-client.php')) { //include the file
  158. require(EVENT_ESPRESSO_PLUGINFULLPATH . 'class/pue/pue-client.php' );
  159. $api_key = $org_options['site_license_key'];
  160. $host_server_url = 'http://eventespresso.com';
  161. $plugin_slug = array(
  162. 'premium' => array('p'=> 'espresso-template-calendar-table'),
  163. 'prerelease' => array('b'=> 'espresso-template-calendar-table-pr')
  164. );
  165. $options = array(
  166. 'apikey' => $api_key,
  167. 'lang_domain' => 'event_espresso',
  168. 'checkPeriod' => '24',
  169. 'option_key' => 'site_license_key',
  170. 'options_page_slug' => 'event_espresso',
  171. 'plugin_basename' => plugin_basename(__FILE__),
  172. 'use_wp_update' => FALSE
  173. );
  174. $check_for_updates = new PluginUpdateEngineChecker($host_server_url, $plugin_slug, $options); //initiate the class and start the plugin update engine!
  175. }
  176. }
RAW Paste Data