BakerMan

Hide/show GCal links according to stock (WooTickets) (1)

Apr 2nd, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * Custom single event template re:
  4. * http://tri.be/support/forums/topic/disable-add-to-google-calendar-and-ical-import-when-tickets-are-unavailable/
  5. */
  6.  
  7. // Don't load directly
  8. if ( !defined('ABSPATH') ) { die('-1'); }
  9.  
  10. global $wooticket_stock;
  11. $wooticket_stock = false;
  12.  
  13. ?>
  14. <span class="back"><a href="<?php echo tribe_get_events_link(); ?>"><?php _e('&laquo; Back to Events', 'tribe-events-calendar'); ?></a></span>             
  15. <?php
  16.     $gmt_offset = (get_option('gmt_offset') >= '0' ) ? ' +' . get_option('gmt_offset') : " " . get_option('gmt_offset');
  17.     $gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
  18.     if (strtotime( tribe_get_end_date(get_the_ID(), false, 'Y-m-d G:i') . $gmt_offset ) <= time() ) { ?><div class="event-passed"><?php  _e('This event has passed.', 'tribe-events-calendar'); ?></div><?php } ?>
  19. <div id="tribe-events-event-meta" itemscope itemtype="http://schema.org/Event">
  20.     <dl class="column">
  21.         <dt class="event-label event-label-name"><?php _e('Event:', 'tribe-events-calendar'); ?></dt>
  22.         <dd itemprop="name" class="event-meta event-meta-name"><span class="summary"><?php the_title(); ?></span></dd>
  23.         <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?>
  24.             <dt class="event-label event-label-start"><?php _e('Start:', 'tribe-events-calendar'); ?> </dt>
  25.             <dd class="event-meta event-meta-start"><meta itemprop="startDate" content="<?php echo tribe_get_start_date( null, false, 'j M Y - h:i a' ); ?>"/><?php echo tribe_get_start_date(null, false, 'M j, Y - h:i a'); ?></dd>
  26.             <dt class="event-label event-label-end"><?php _e('End:', 'tribe-events-calendar'); ?></dt>
  27.             <dd class="event-meta event-meta-end"><meta itemprop="endDate" content="<?php echo tribe_get_end_date( null, false, 'Y-m-d-h:i:s' ); ?>"/><?php echo tribe_get_end_date(); ?></dd>                     
  28.         <?php } else { ?>
  29.             <dt class="event-label event-label-date"><?php _e('Date:', 'tribe-events-calendar'); ?></dt>
  30.             <dd class="event-meta event-meta-date"><meta itemprop="startDate" content="<?php echo tribe_get_start_date( null, false, 'Y-m-d-h:i:s' ); ?>"/><?php echo tribe_get_start_date(); ?></dd>
  31.         <?php } ?>
  32.         <?php if ( tribe_get_cost() ) : ?>
  33.             <dt class="event-label event-label-cost"><?php _e('Cost:', 'tribe-events-calendar'); ?></dt>
  34.             <dd itemprop="price" class="event-meta event-meta-cost"><?php echo tribe_get_cost(); ?></dd>
  35.         <?php endif; ?>
  36.         <?php tribe_meta_event_cats(); ?>
  37.         <?php if ( tribe_get_organizer_link( get_the_ID(), false, false ) ) : ?>
  38.             <dt class="event-label event-label-organizer"><?php _e('Organizer:', 'tribe-events-calendar'); ?></dt>
  39.             <dd class="vcard author event-meta event-meta-author"><span class="fn url"><?php echo tribe_get_organizer_link(); ?></span></dd>
  40.       <?php elseif (tribe_get_organizer()): ?>
  41.             <dt class="event-label event-label-organizer"><?php _e('Organizer:', 'tribe-events-calendar'); ?></dt>
  42.             <dd class="vcard author event-meta event-meta-author"><span class="fn url"><?php echo tribe_get_organizer(); ?></span></dd>
  43.         <?php endif; ?>
  44.         <?php if ( tribe_get_organizer_phone() ) : ?>
  45.             <dt class="event-label event-label-organizer-phone"><?php _e('Phone:', 'tribe-events-calendar'); ?></dt>
  46.             <dd itemprop="telephone" class="event-meta event-meta-phone"><?php echo tribe_get_organizer_phone(); ?></dd>
  47.         <?php endif; ?>
  48.         <?php if ( tribe_get_organizer_email() ) : ?>
  49.             <dt class="event-label event-label-email"><?php _e('Email:', 'tribe-events-calendar'); ?></dt>
  50.             <dd itemprop="email" class="event-meta event-meta-email"><a href="mailto:<?php echo tribe_get_organizer_email(); ?>"><?php echo tribe_get_organizer_email(); ?></a></dd>
  51.         <?php endif; ?>
  52.         <dt class="event-label event-label-updated"><?php _e('Updated:', 'tribe-events-calendar'); ?></dt>
  53.         <dd class="event-meta event-meta-updated"><span class="date updated"><?php the_date(); ?></span></dd>
  54.         <?php if ( class_exists('TribeEventsRecurrenceMeta') && function_exists('tribe_get_recurrence_text') && tribe_is_recurring_event() ) : ?>
  55.  
  56.             <dt>Date range</dt>
  57.             <dd><?php
  58.                 // Find the start and end dates
  59.                 $recurrence = TribeEventsRecurrenceMeta::getRecurrenceMeta(get_the_ID());
  60.                 $final = isset($recurrence['recEnd']) ? $recurrence['recEnd'] : false;
  61.                 $start = get_post_meta(get_the_ID(), '_EventStartDate', true);
  62.  
  63.                 // Do we have what we are looking for?
  64.                 if ($final !== false and !empty($start)) {
  65.                     // Format both dates
  66.                     $start = new DateTime($start);
  67.                     $start = $start->format(get_option('date_format'));
  68.  
  69.                     $final = new DateTime($final);
  70.                     $final = $final->format(get_option('date_format'));
  71.  
  72.                     // Display!
  73.                     echo "$start until $final";
  74.                 }
  75.             ?></dd>
  76.  
  77.             <dt class="event-label event-label-schedule"><?php _e('Schedule:', 'tribe-events-calendar'); ?></dt>
  78.          <dd class="event-meta event-meta-schedule"><?php echo tribe_get_recurrence_text(); ?>
  79.             <?php if( class_exists('TribeEventsRecurrenceMeta') && function_exists('tribe_all_occurences_link')): ?>(<a href='<?php tribe_all_occurences_link(); ?>'>See all</a>)<?php endif; ?>
  80.          </dd>
  81.         <?php endif; ?>
  82.     </dl>
  83.     <dl class="column" itemprop="location" itemscope itemtype="http://schema.org/Place">
  84.         <?php if(tribe_get_venue()) : ?>
  85.         <dt class="event-label event-label-venue"><?php _e('Venue:', 'tribe-events-calendar'); ?></dt>
  86.         <dd itemprop="name" class="event-meta event-meta-venue">
  87.             <?php if( class_exists( 'TribeEventsPro' ) ): ?>
  88.                 <?php tribe_get_venue_link( get_the_ID(), class_exists( 'TribeEventsPro' ) ); ?>
  89.             <?php else: ?>
  90.                 <?php echo tribe_get_venue( get_the_ID() ); ?>
  91.             <?php endif; ?>
  92.         </dd>
  93.         <?php endif; ?>
  94.         <?php if(tribe_get_phone()) : ?>
  95.         <dt class="event-label event-label-venue-phone"><?php _e('Phone:', 'tribe-events-calendar'); ?></dt>
  96.             <dd itemprop="telephone" class="event-meta event-meta-venue-phone"><?php echo tribe_get_phone(); ?></dd>
  97.         <?php endif; ?>
  98.         <?php if( tribe_address_exists( get_the_ID() ) ) : ?>
  99.         <dt class="event-label event-label-address">
  100.             <?php _e('Address:', 'tribe-events-calendar') ?><br />
  101.             <?php if( tribe_show_google_map_link( get_the_ID() ) ) : ?>
  102.                 <a class="gmap" itemprop="maps" href="<?php echo tribe_get_map_link(); ?>" title="<?php _e('Click to view a Google Map', 'tribe-events-calendar'); ?>" target="_blank"><?php _e('Google Map', 'tribe-events-calendar' ); ?></a>
  103.             <?php endif; ?>
  104.         </dt>
  105.             <dd class="event-meta event-meta-address">
  106.             <?php echo tribe_get_full_address( get_the_ID() ); ?>
  107.             </dd>
  108.         <?php endif; ?>
  109.     </dl>
  110.  
  111.     <?php if( function_exists('tribe_the_custom_fields') && tribe_get_custom_fields( get_the_ID() ) ): ?>
  112.         <?php tribe_the_custom_fields( get_the_ID() );?>
  113.     <?php endif; ?>
  114.  
  115.     <?php if( function_exists('tribe_the_custom_fields') && tribe_get_custom_fields( get_the_ID() ) ): ?>
  116.         <?php $fields = tribe_get_custom_fields( $postId ); ?>
  117.         <dl class="column">
  118.         <?php foreach ($fields as $label => $value) :
  119.             $ignore = 'Field Label'; // Label of the field you wish to ignore
  120.             if ($label === $ignore) continue;
  121.             echo  apply_filters('tribe_the_custom_field',"<dt class=\"tribe-custom-label\">".stripslashes($label).":</dt><dd class=\"tribe-custom-meta\">".stripslashes($value)."</dd>\n",$label,$value);
  122.         endforeach ?>
  123.         </dl>
  124.     <?php endif ?>
  125.  
  126. </div>
  127. <?php if( tribe_embed_google_map( get_the_ID() ) ) : ?>
  128. <?php if( tribe_address_exists( get_the_ID() ) ) { echo tribe_get_embedded_map(); } ?>
  129. <?php endif; ?>
  130. <div class="entry-content">
  131.     <?php
  132.     if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {?>
  133.         <?php the_post_thumbnail(); ?>
  134.     <?php } ?>
  135.     <div class="summary"><?php the_content(); ?></div>
  136.     <?php if (function_exists('tribe_get_ticket_form') && tribe_get_ticket_form()) { tribe_get_ticket_form(); } ?>
  137. </div>
  138. <?php if ($wooticket_stock === false or ($wooticket_stock !== false and $wooticket_stock > 0)): ?>
  139.     <?php if( function_exists('tribe_get_single_ical_link') ): ?>
  140.        <a class="ical single" href="<?php echo tribe_get_single_ical_link(); ?>"><?php _e('iCal Import', 'tribe-events-calendar'); ?></a>
  141.     <?php endif; ?>
  142.     <?php if( function_exists('tribe_get_gcal_link') ): ?>
  143.        <a href="<?php echo tribe_get_gcal_link(); ?>" class="gcal-add" title="<?php _e('Add to Google Calendar', 'tribe-events-calendar'); ?>"><?php _e('+ Google Calendar', 'tribe-events-calendar'); ?></a>
  144.     <?php endif; ?>
  145. <?php endif ?>
  146.  
  147. <span class="navlink tribe-previous"><?php tribe_previous_event_link(); ?></span>
  148.  
  149. <span class="navlink tribe-next"><?php tribe_next_event_link(); ?></span>
  150. <div style="clear:both"></div>
Advertisement
Add Comment
Please, Sign In to add comment