Guest User

Untitled

a guest
Feb 5th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.08 KB | None | 0 0
  1. <?php
  2.  
  3. /****************************************************
  4. * eventlist
  5. ****************************************************/
  6.  
  7. if (!function_exists('euged_shortcode_eventlist'))
  8. {
  9.     function euged_shortcode_eventlist($atts, $content = null)
  10.     {
  11.         extract(
  12.             shortcode_atts(
  13.                 array(
  14.                     'load' => '2',
  15.                     'post_type' => 'event',
  16.                     'link' => '',
  17.                     'orderby' => 'date',
  18.                     'display' => 'upcoming',
  19.                     'service' => '',
  20.                     'order' => 'asc',
  21.                     'relation' => 'AND',
  22.                     'industry' => '',
  23.                     'category' => '',
  24.                     'post_format' => '',
  25.                     'id' => '',
  26.                     'showimage' => 'yes',
  27.                                    
  28.                 ),
  29.                 $atts
  30.             )
  31.         );
  32.  
  33.         // Validation
  34.  
  35.         if (!is_numeric($load)) {
  36.             $load = '2';
  37.         }
  38.        
  39.         if (!in_array($link, array('yes','no'))) {
  40.             $link = 'yes';
  41.         }
  42.                
  43.         if (!in_array($orderby, array('title','date','rand','random','menu_order','ID','author','none','modified','comment_count'))) {
  44.             $orderby = 'date';
  45.         }
  46.  
  47.         if ($orderby == 'random') {
  48.             $orderby = 'rand';
  49.         }
  50.  
  51.         if (!in_array($order, array('asc','desc'))) {
  52.             $order = 'asc';
  53.         }
  54.        
  55.         if (!in_array($relation, array('AND','OR'))) {
  56.             $relation = 'AND';
  57.         }
  58.  
  59.    
  60.    
  61.       if (!empty($industry))
  62.         {
  63.             $industries = explode(',',$industry);
  64.  
  65.             foreach($industries as $key => $value)
  66.             {
  67.                 $industries[$key] = trim($value);
  68.             }
  69.         }
  70.        
  71.                
  72.          if (!empty($category))
  73.         {
  74.             $categories = explode(',',$category);
  75.  
  76.             foreach($categories as $key => $value)
  77.             {
  78.                 $categories[$key] = trim($value);
  79.             }
  80.         }
  81.        
  82.         if (!empty($service))
  83.         {
  84.             $services = explode(',',$service);
  85.  
  86.             foreach($services as $key => $value)
  87.             {
  88.                 $services[$key] = trim($value);
  89.             }
  90.         }
  91.  
  92.  
  93.    
  94.  
  95.         if ($industry !== ''  && $category !== ''  && $service !== '')
  96.                 {
  97.                    
  98.                     $tax_query = array(
  99.                        'relation' => 'AND',
  100.                         array(
  101.                         'taxonomy' => 'event_industry',
  102.                         'field' => 'slug',
  103.                         'terms' => $industries
  104.                         ),
  105.                         array(
  106.                         'taxonomy' => 'tribe_events_cat',
  107.                         'field' => 'slug',
  108.                         'terms' => $categories
  109.                         ),
  110.                         array(
  111.                         'taxonomy' => 'event_service',
  112.                         'field' => 'slug',
  113.                         'terms' => $services
  114.                         )
  115.                        
  116.                     );
  117.                 }
  118.  
  119.         elseif ($industry !== ''  && $category !==''  && $service =='')
  120.         {
  121.            
  122.             $tax_query = array(
  123.                'relation' => 'AND',
  124.                 array(
  125.                 'taxonomy' => 'event_industry',
  126.                 'field' => 'slug',
  127.                 'terms' => $industries
  128.                 ),
  129.                 array(
  130.                 'taxonomy' => 'tribe_events_cat',
  131.                 'field' => 'slug',
  132.                 'terms' => $categories
  133.                 )
  134.                
  135.             );
  136.         }
  137.        
  138.         elseif ($industry !== ''  && $category ==''  && $service !=='')
  139.         {
  140.            
  141.             $tax_query = array(
  142.                'relation' => 'AND',
  143.                 array(
  144.                 'taxonomy' => 'event_industry',
  145.                 'field' => 'slug',
  146.                 'terms' => $industries
  147.                 ),
  148.                 array(
  149.                 'taxonomy' => 'event_service',
  150.                 'field' => 'slug',
  151.                 'terms' => $services
  152.                 )
  153.                
  154.             );
  155.         }
  156.        
  157.         elseif ($industry == ''  && $category !==''  && $service !=='')
  158.         {
  159.            
  160.             $tax_query = array(
  161.                'relation' => 'AND',
  162.                 array(
  163.                 'taxonomy' => 'tribe_events_cat',
  164.                 'field' => 'slug',
  165.                 'terms' => $categories
  166.                 ),
  167.                 array(
  168.                 'taxonomy' => 'event_service',
  169.                 'field' => 'slug',
  170.                 'terms' => $services
  171.                 )
  172.                
  173.             );
  174.         }
  175.        
  176.         elseif ($industry !== ''  && $category ==''  && $service =='')
  177.         {
  178.             $tax_query = array(
  179.                 array(
  180.                 'taxonomy' => 'event_industry',
  181.                 'field' => 'slug',
  182.                 'terms' => $industries
  183.                 )
  184.             );
  185.         }
  186.        
  187.         elseif ($industry == ''  && $category !==''  && $service =='')
  188.         {
  189.             $tax_query = array(
  190.                 array(
  191.                 'taxonomy' => 'tribe_events_cat',
  192.                 'field' => 'slug',
  193.                 'terms' => $categories
  194.                 )
  195.             );
  196.         }
  197.        
  198.         elseif ($industry == ''  && $category ==''  && $service !=='')
  199.         {
  200.             $tax_query = array(
  201.                 array(
  202.                 'taxonomy' => 'event_service',
  203.                 'field' => 'slug',
  204.                 'terms' => $services
  205.                 )
  206.             );
  207.         }
  208.        
  209.         else
  210.         {
  211.             $tax_query = array();
  212.         }
  213.    
  214.    
  215.  
  216.  
  217.         // Post Format
  218.         if (!empty($post_format))
  219.         {
  220.             $post_formats = explode(',',$post_format);
  221.  
  222.             foreach($post_formats as $key => $value) {
  223.                 $post_formats[$key] = 'post-format-'.trim($value);
  224.             }
  225.  
  226.             $tax_query[] = array(
  227.                 'taxonomy' => 'post_format',
  228.                 'field' => 'slug',
  229.                 'terms' => $post_formats
  230.             );
  231.         }
  232.  
  233.         // ID's
  234.         if (!empty($id)) {
  235.             $ids = explode(',',$id);
  236.  
  237.             foreach($ids as $key => $value) {
  238.                 $ids[$key] = trim($value);
  239.             }
  240.  
  241.             $post__in = $ids;
  242.         } else {
  243.             $post__in = array();
  244.         }
  245.  
  246.         if (!in_array($showimage, array('yes','no'))) {
  247.             $showimage = 'no';
  248.         }
  249.  
  250.         if (!in_array($showtitle, array('yes','no'))) {
  251.             $showtitle = 'yes';
  252.         }
  253.  
  254.        
  255.        
  256.  
  257.        
  258.    
  259.         global $post;
  260.         $r = $t = 0;
  261.  
  262.         $args = array(
  263.             'post_type' => 'tribe_events',
  264.             'order' => $order,
  265.             'posts_per_page' => $load,
  266.             'orderby' => $orderby,
  267.             'exclude' => $post->ID,
  268.             'eventDisplay' => $display,
  269.             'tax_query' => $tax_query,
  270.             'post__in' => $post__in
  271.            
  272.         );
  273.  
  274.         $eventposts = tribe_get_events($args);
  275.  
  276.         if ($eventposts)
  277.         {
  278.            
  279.                        
  280.             // Output
  281.             foreach($eventposts as $eventpost) {
  282.                                
  283.                 $day = tribe_get_start_date( $eventpost->ID, false, 'j' );
  284.                 $month = tribe_get_start_date( $eventpost->ID, false, 'M' );
  285.                 $schedule_details = tribe_events_event_schedule_details($eventpost->ID);
  286.                 $event_address = tribe_get_address($eventpost->ID);
  287.                 $event_city = tribe_get_city($eventpost->ID);
  288.                 $event_state = tribe_get_state($eventpost->ID);
  289.                 $event_excerpt = tribe_events_get_the_excerpt($eventpost->ID);
  290.                 //$event_excerpt = apply_filters('get_the_excerpt', $eventpost->post_excerpt);
  291.                
  292.                
  293.                 $output .= '<div class="eventlist">';
  294.                 $output .= '<div style="padding-left:0;" class="eventlist-content">';
  295.                 //  $output .= '<div class="mini-meta-holder"><div class="meta datetime"><p><time pubdate="" datetime=""><span class="month">'.$month.'</span><span class="day">'.$day.'</span></time></p></div><div class="meta postformat">';
  296.                    
  297.                 //   if (has_term( 'webinars', 'tribe_events_cat', $eventpost->ID )) {
  298.                      
  299.                 //   $output .= '<i style="font-size: 18px; line-height: 30px;" class="fa fa-laptop "></i>';
  300.                      
  301.                 //    } else {
  302.                      
  303.                 //    $output .= '<i style="font-size: 18px; line-height: 30px;" class="fa fa-map-marker"></i>';
  304.                      
  305.                 //     }
  306.                                    
  307.                    
  308.                 //  $output .= '</div></div>';
  309.                            
  310.                 $output .= '<a class="title" href="'.get_permalink($eventpost->ID).'">'.$eventpost->post_title.'</a>';   
  311.                
  312.                 $output .= '<div class="updated published time-details">'.$schedule_details.'</div>';
  313.                      if ($event_address !== ''  && $event_city !== ''  && $event_state !== '' && has_term( 'conferences', 'tribe_events_cat', $eventpost->ID )) {      
  314.                 $output .= '<div class="tribe-events-venue-details">'.$event_address.' '.$event_city.', '.$event_state.'</div>';
  315.                      }
  316.                 //$output .= '<p>'.$event_excerpt.'</p>';
  317.                  
  318.                 $output .= '</div>';
  319.                
  320.                
  321.                
  322.                
  323.                 $output .= '</div>';
  324.             }
  325.            
  326.            
  327.         }
  328.         else
  329.         {
  330.             if ($category == 'webinars') {
  331.             $output = '<p class="notice default ">'.__('Our webinars keep you in-the-know on business-critical trends and issues. Check back shortly to see upcoming topics.', 'euged').'</p>';
  332.             } else {  
  333.             $output = '<p class="notice default ">'.__('Check back soon to see the events at which we’ll be guests, sponsors and speakers. We’d love to connect with you there.', 'euged').'</p>';
  334.             }
  335.         }
  336.  
  337. if ($link == 'yes') {
  338.  if (has_term( 'webinars', 'tribe_events_cat', $eventpost->ID )) {
  339.  $output .= '<div class="eventlist-more-link"><a href="/guidance/latest-webinars/">More Webinars&nbsp; <i class="fa fa-arrow-circle-right"></i> </a> </div>'; } elseif (has_term( 'conferences', 'tribe_events_cat', $eventpost->ID )) {  
  340.  $output .= '<div class="eventlist-more-link" ><a href="/events/upcoming/?tribe_eventcategory=70">More Conferences&nbsp; <i class="fa fa-arrow-circle-right"></i> </a> </div>';}
  341.  
  342.  else {
  343.      }
  344.                        
  345. }
  346.  
  347.         return $output;
  348.     }
  349.     add_shortcode('eventlist','euged_shortcode_eventlist');
  350. }
Advertisement
Add Comment
Please, Sign In to add comment