Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /****************************************************
- * eventlist
- ****************************************************/
- if (!function_exists('euged_shortcode_eventlist'))
- {
- function euged_shortcode_eventlist($atts, $content = null)
- {
- extract(
- shortcode_atts(
- array(
- 'load' => '2',
- 'post_type' => 'event',
- 'link' => '',
- 'orderby' => 'date',
- 'display' => 'upcoming',
- 'service' => '',
- 'order' => 'asc',
- 'relation' => 'AND',
- 'industry' => '',
- 'category' => '',
- 'post_format' => '',
- 'id' => '',
- 'showimage' => 'yes',
- ),
- $atts
- )
- );
- // Validation
- if (!is_numeric($load)) {
- $load = '2';
- }
- if (!in_array($link, array('yes','no'))) {
- $link = 'yes';
- }
- if (!in_array($orderby, array('title','date','rand','random','menu_order','ID','author','none','modified','comment_count'))) {
- $orderby = 'date';
- }
- if ($orderby == 'random') {
- $orderby = 'rand';
- }
- if (!in_array($order, array('asc','desc'))) {
- $order = 'asc';
- }
- if (!in_array($relation, array('AND','OR'))) {
- $relation = 'AND';
- }
- if (!empty($industry))
- {
- $industries = explode(',',$industry);
- foreach($industries as $key => $value)
- {
- $industries[$key] = trim($value);
- }
- }
- if (!empty($category))
- {
- $categories = explode(',',$category);
- foreach($categories as $key => $value)
- {
- $categories[$key] = trim($value);
- }
- }
- if (!empty($service))
- {
- $services = explode(',',$service);
- foreach($services as $key => $value)
- {
- $services[$key] = trim($value);
- }
- }
- if ($industry !== '' && $category !== '' && $service !== '')
- {
- $tax_query = array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'event_industry',
- 'field' => 'slug',
- 'terms' => $industries
- ),
- array(
- 'taxonomy' => 'tribe_events_cat',
- 'field' => 'slug',
- 'terms' => $categories
- ),
- array(
- 'taxonomy' => 'event_service',
- 'field' => 'slug',
- 'terms' => $services
- )
- );
- }
- elseif ($industry !== '' && $category !=='' && $service =='')
- {
- $tax_query = array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'event_industry',
- 'field' => 'slug',
- 'terms' => $industries
- ),
- array(
- 'taxonomy' => 'tribe_events_cat',
- 'field' => 'slug',
- 'terms' => $categories
- )
- );
- }
- elseif ($industry !== '' && $category =='' && $service !=='')
- {
- $tax_query = array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'event_industry',
- 'field' => 'slug',
- 'terms' => $industries
- ),
- array(
- 'taxonomy' => 'event_service',
- 'field' => 'slug',
- 'terms' => $services
- )
- );
- }
- elseif ($industry == '' && $category !=='' && $service !=='')
- {
- $tax_query = array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'tribe_events_cat',
- 'field' => 'slug',
- 'terms' => $categories
- ),
- array(
- 'taxonomy' => 'event_service',
- 'field' => 'slug',
- 'terms' => $services
- )
- );
- }
- elseif ($industry !== '' && $category =='' && $service =='')
- {
- $tax_query = array(
- array(
- 'taxonomy' => 'event_industry',
- 'field' => 'slug',
- 'terms' => $industries
- )
- );
- }
- elseif ($industry == '' && $category !=='' && $service =='')
- {
- $tax_query = array(
- array(
- 'taxonomy' => 'tribe_events_cat',
- 'field' => 'slug',
- 'terms' => $categories
- )
- );
- }
- elseif ($industry == '' && $category =='' && $service !=='')
- {
- $tax_query = array(
- array(
- 'taxonomy' => 'event_service',
- 'field' => 'slug',
- 'terms' => $services
- )
- );
- }
- else
- {
- $tax_query = array();
- }
- // Post Format
- if (!empty($post_format))
- {
- $post_formats = explode(',',$post_format);
- foreach($post_formats as $key => $value) {
- $post_formats[$key] = 'post-format-'.trim($value);
- }
- $tax_query[] = array(
- 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => $post_formats
- );
- }
- // ID's
- if (!empty($id)) {
- $ids = explode(',',$id);
- foreach($ids as $key => $value) {
- $ids[$key] = trim($value);
- }
- $post__in = $ids;
- } else {
- $post__in = array();
- }
- if (!in_array($showimage, array('yes','no'))) {
- $showimage = 'no';
- }
- if (!in_array($showtitle, array('yes','no'))) {
- $showtitle = 'yes';
- }
- global $post;
- $r = $t = 0;
- $args = array(
- 'post_type' => 'tribe_events',
- 'order' => $order,
- 'posts_per_page' => $load,
- 'orderby' => $orderby,
- 'exclude' => $post->ID,
- 'eventDisplay' => $display,
- 'tax_query' => $tax_query,
- 'post__in' => $post__in
- );
- $eventposts = tribe_get_events($args);
- if ($eventposts)
- {
- // Output
- foreach($eventposts as $eventpost) {
- $day = tribe_get_start_date( $eventpost->ID, false, 'j' );
- $month = tribe_get_start_date( $eventpost->ID, false, 'M' );
- $schedule_details = tribe_events_event_schedule_details($eventpost->ID);
- $event_address = tribe_get_address($eventpost->ID);
- $event_city = tribe_get_city($eventpost->ID);
- $event_state = tribe_get_state($eventpost->ID);
- $event_excerpt = tribe_events_get_the_excerpt($eventpost->ID);
- //$event_excerpt = apply_filters('get_the_excerpt', $eventpost->post_excerpt);
- $output .= '<div class="eventlist">';
- $output .= '<div style="padding-left:0;" class="eventlist-content">';
- // $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">';
- // if (has_term( 'webinars', 'tribe_events_cat', $eventpost->ID )) {
- // $output .= '<i style="font-size: 18px; line-height: 30px;" class="fa fa-laptop "></i>';
- // } else {
- // $output .= '<i style="font-size: 18px; line-height: 30px;" class="fa fa-map-marker"></i>';
- // }
- // $output .= '</div></div>';
- $output .= '<a class="title" href="'.get_permalink($eventpost->ID).'">'.$eventpost->post_title.'</a>';
- $output .= '<div class="updated published time-details">'.$schedule_details.'</div>';
- if ($event_address !== '' && $event_city !== '' && $event_state !== '' && has_term( 'conferences', 'tribe_events_cat', $eventpost->ID )) {
- $output .= '<div class="tribe-events-venue-details">'.$event_address.' '.$event_city.', '.$event_state.'</div>';
- }
- //$output .= '<p>'.$event_excerpt.'</p>';
- $output .= '</div>';
- $output .= '</div>';
- }
- }
- else
- {
- if ($category == 'webinars') {
- $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>';
- } else {
- $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>';
- }
- }
- if ($link == 'yes') {
- if (has_term( 'webinars', 'tribe_events_cat', $eventpost->ID )) {
- $output .= '<div class="eventlist-more-link"><a href="/guidance/latest-webinars/">More Webinars <i class="fa fa-arrow-circle-right"></i> </a> </div>'; } elseif (has_term( 'conferences', 'tribe_events_cat', $eventpost->ID )) {
- $output .= '<div class="eventlist-more-link" ><a href="/events/upcoming/?tribe_eventcategory=70">More Conferences <i class="fa fa-arrow-circle-right"></i> </a> </div>';}
- else {
- }
- }
- return $output;
- }
- add_shortcode('eventlist','euged_shortcode_eventlist');
- }
Advertisement
Add Comment
Please, Sign In to add comment