Advertisement
BakerMan

Modified TEC Advanced Widget View/Template

Nov 1st, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.28 KB | None | 0 0
  1. <?php
  2. /**
  3.  * This is the template for the output of the events list widget.
  4.  * All the items are turned on and off through the widget admin.
  5.  * There is currently no default styling, which is highly needed.
  6.  *
  7.  * You can customize this view by putting a replacement file of the same name (events-list-load-widget-display.php) in the events/ directory of your theme.
  8.  *
  9.  * When the template is loaded, the following vars are set: $start, $end, $venue, $address, $city, $state, $province'], $zip, $country, $phone, $cost
  10.  * @return string
  11.  */
  12.  
  13. // Vars set:
  14. // '$event->AllDay',
  15. // '$event->StartDate',
  16. // '$event->EndDate',
  17. // '$event->ShowMapLink',
  18. // '$event->ShowMap',
  19. // '$event->Cost',
  20. // '$event->Phone',
  21.  
  22. // Don't load directly
  23. if ( !defined('ABSPATH') ) { die('-1'); }
  24.  
  25. $event = array();
  26. $tribe_ecp = TribeEvents::instance();
  27. reset($tribe_ecp->metaTags); // Move pointer to beginning of array.
  28. foreach($tribe_ecp->metaTags as $tag){
  29.     $var_name = str_replace('_Event','',$tag);
  30.     $event[$var_name] = tribe_get_event_meta( $post->ID, $tag, true );
  31. }
  32.  
  33. $event = (object) $event; //Easier to work with.
  34.  
  35. ob_start();
  36. if ( !isset($alt_text) ) { $alt_text = ''; }
  37. post_class($alt_text,$post->ID);
  38. $class = ob_get_contents();
  39. ob_end_clean();
  40. ?>
  41. <li <?php echo $class ?>>
  42.     <div class="when">
  43.         <?php
  44.         $space = false;
  45.         $output = '';
  46.         $startDate = tribe_get_start_date( $post->ID, $start );
  47.         $endDate = tribe_get_end_date( $post->ID );
  48.  
  49.         echo __('Starts', 'tribe-events-calendar-pro') . ': ';
  50.         echo $startDate;
  51.  
  52.         if($event->AllDay && $start) {
  53.             echo ' <small>('.__('All Day','tribe-events-calendar-pro').')</small>';
  54.             if ($startDate != $endDate)
  55.                 echo $endDate;
  56.         } else {
  57.             if ( $end && $event->EndDate != '') {
  58.                 echo '<br/>' . __('Ends', 'tribe-events-calendar-pro') . ': ';
  59.                 echo $endDate;
  60.             }
  61.         }
  62.         ?>
  63.     </div>
  64.     <div class="event">
  65.         <a href="<?php echo tribe_get_event_link($post) ?>"><?php echo $post->post_title ?></a>
  66.     </div>
  67.     <div class="loc"><?php
  68.         if ( $venue && tribe_get_venue() != '') {
  69.             $output .= ( $space ) ? '<br />' : '';
  70.             $output .= tribe_get_venue();
  71.             $space = true;
  72.         }
  73.  
  74.         if ( $address && tribe_get_address()) {
  75.             $output .= ( $space ) ? '<br />' : '';
  76.             $output .= tribe_get_address();
  77.             $space = true;
  78.         }
  79.  
  80.         if ( $city && tribe_get_city() != '' ) {
  81.             $output .= ( $space ) ? '<br />' : '';
  82.             $output .= tribe_get_city() . ', ';
  83.             $space = true;
  84.         }
  85.         if ( $region && tribe_get_region()) {
  86.             $output .= ( !$city ) ? '<br />' : '';
  87.             $space = true;
  88.             $output .= tribe_get_region();
  89.         } else {
  90.             $output = rtrim( $output, ', ' );
  91.         }
  92.  
  93.         if ( $zip && tribe_get_zip() != '') {
  94.             $output .= ( $space ) ? '<br />' : '';
  95.             $output .= tribe_get_zip();
  96.             $space = true;
  97.         }
  98.  
  99.         if ( $country && tribe_get_country() != '') {
  100.             $output .= ( $space ) ? '<br />' : ' ';
  101.             $output .= tribe_get_country();
  102.         }
  103.  
  104.         if ( $phone && tribe_get_phone() != '') {
  105.             if($output)
  106.                 $output .= '<br/>';
  107.  
  108.             $output .= tribe_get_phone();
  109.         }
  110.         if ( $cost && tribe_get_cost() != '') {
  111.             if($output)
  112.                 $output .= '<br/>';
  113.             $output .= __('Price:', 'tribe-events-calendar-pro') . ' ' . tribe_get_cost();
  114.         }
  115.  
  116.         echo $output;
  117.         ?>
  118.     </div>
  119. </li>
  120. <?php $alt_text = ( empty( $alt_text ) ) ? 'alt' : ''; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement