function block_tribe_event_output($params) { extract($params); $default_excerpt_length = 650; if (!isset($event_ID) || empty($event_ID)) { return; } $event = get_post($event_ID); // if block has event ID but the actual event does not exist then exit if (!isset($event)) { return; } // BLOCK CLASSES $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } ?> <!-- BLOCK: LATEST POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix"> <!-- start main-content --> <div class="main-content"> <!-- Start Post --> <div class="clearfix tribe-events-tcblock"> <!-- Event Cost --> <div class="tribe-events-event-cost"> <span><?php echo tribe_get_formatted_cost($event_ID); ?> </span> </div> <!-- Event Title --> <h2 class="tribe-events-list-event-title summary"> <?php printf('<a class="url" href="%s" title="%s" rel="bookmark">%s</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_attr(get_the_title($event_ID))); ?> </h2> <!-- Event Image --> <div class="tribe-events-event-image"> <?php if (has_post_thumbnail($event_ID) && get_post(get_post_thumbnail_id($event_ID))) { $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($event_ID), 'full'); printf('<a href="%s" title="%s"><img src="%s" title="%s"/></a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_url($post_thumbnail_src[0]), esc_attr(get_the_title($event_ID))); } ?> </div> <!-- Event Meta --> <div class="tribe-events-event-meta vcard location"> <!-- Schedule & Recurrence Details --> <div class="updated published time-details"> <?php printf('<span class="date-start dtstart">%s</span>', esc_attr(tribe_get_start_date($event_ID))); ?> </div> <!-- Venue Display Info --> <div class="tribe-events-venue-details"> <span class="author fn org"><?php echo tribe_get_venue($event_ID); ?> </span>, <address class="tribe-events-address"> <span class="adr"> <span class="street-address"><?php echo tribe_get_address($event_ID); ?> </span> <span class="delimiter">,</span> <span class="locality"><?php echo tribe_get_city($event_ID); ?> </span> <span class="delimiter">,</span> <span class="postal-code"><?php echo tribe_get_zip($event_ID); ?> </span> <span class="country-name"><?php echo tribe_get_country($event_ID); ?> </span> </span> </address> <?php printf('<a class="tribe-events-gmap" href="%s" title="Click to view a Google Map" target="_blank">- Google Map</a>', esc_url(tribe_get_map_link($event_ID))); ?> </div> <!-- .tribe-events-venue-details --> </div><!-- .tribe-events-event-meta --> <!-- Event Content --> <div class="tribe-events-list-event-description tribe-events-content description entry-summary"> <?php $event_excerpt = !empty($event->post_excerpt) ? do_shortcode($event->post_excerpt) : mb_make_excerpt($event->post_content, $default_excerpt_length, true); // excerpt echo "<p>"; echo $event_excerpt; echo "</p>"; // read more printf('<a href="%s" class="tribe-events-read-more" rel="bookmark">%s »</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(__('Find out more', "loc_sport_core_plugin"))); ?> </div><!-- .tribe-events-list-event-description --> </div> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
/** * Adds the View link for recurring events. * * @param array $actions The current action links. * @return array The modified action links. */ public static function add_recurring_event_view_link($actions) { global $post; if (function_exists('tribe_is_recurring_event') && is_array(self::$events_list) && tribe_is_recurring_event(self::$events_list[0]->ID) && isset(self::$events_list[0])) { $actions['view'] = '<a href="' . tribe_get_event_link(self::$events_list[0]) . '" title="' . esc_attr(sprintf(__('View “%s”', 'tribe-events-calendar'), $post->post_title)) . '" rel="permalink">' . __('View', 'tribe-events-calendar') . '</a>'; } return $actions; }
/** * Generate the hidden information to be passed to jQuery. */ public function generate_countdown_output($seconds, $complete, $hourformat, $event_ID, $event_date = null) { $event = get_post($event_ID); if (!is_null($event_date)) { $event->EventStartDate = $event_date; } $link = tribe_get_event_link($event); return ' <div class="tribe-countdown-text"><a href="' . esc_url($link) . '">' . esc_attr($event->post_title) . '</a></div> <div class="tribe-countdown-timer"> <span class="tribe-countdown-seconds">' . $seconds . '</span> <span class="tribe-countdown-format">' . $hourformat . '</span> ' . $complete . ' </div>'; }
function ckhp_get_tribe_list($atts) { if (!function_exists('tribe_get_events')) { return; } global $wp_query, $tribe_ecp, $post; $output = ''; $ckhp_event_tax = ''; extract(shortcode_atts(array('cat' => '', 'number' => 5, 'class' => '', 'error' => 'y'), $atts, 'ckhp-tribe-events'), EXTR_PREFIX_ALL, 'ckhp'); $class = $atts['class']; if ($ckhp_cat) { $ckhp_event_tax = array(array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => $ckhp_cat)); } $posts = tribe_get_events(apply_filters('tribe_events_list_widget_query_args', array('eventDisplay' => 'upcoming', 'posts_per_page' => $ckhp_number, 'tax_query' => $ckhp_event_tax))); if (!isset($no_upcoming_events)) { $no_upcoming_events = 0; } if ($posts && !$no_upcoming_events) { if ($posts && !$no_upcoming_events) { $output .= '<div class="event-calendar ' . $class . '">'; foreach ($posts as $post) { setup_postdata($post); $output .= '<a href="' . tribe_get_event_link() . '" rel="bookmark">'; $output .= '<div class="event-post">'; $output .= '<div class="event-date">'; $output .= '<time>' . sp_get_start_date($postId = null, $showtime = true, $dateFormat = 'M') . '<span>' . sp_get_start_date($postId = null, $showtime = true, $dateFormat = 'd') . '</span></time>'; $output .= '</div>'; $output .= '<div class="event-details">'; $output .= '<p>' . sp_get_start_date($postId = null, $showtime = true, $dateFormat = 'l') . ' ' . sp_get_start_date($postId = null, $showtime = true, $dateFormat = 'g:i a') . '</p>'; $output .= '<h4 class="media-heading">' . '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . get_the_title() . '</a>' . '</h4>'; $output .= '</div>'; $output .= '</div>'; $output .= '</a>'; } $output .= '</div><!-- .hfeed -->'; $output .= '<p class="tribe-events-widget-link"><a class="btn btn-primary btn-sm" href="' . tribe_get_events_link() . '" rel="bookmark">' . translate('View All Events', 'tribe-events-calendar') . '</a></p>'; } } else { //No Events were Found $output .= $ckhp_error == 'y' ? '<p>' . translate('There are no upcoming events at this time.', 'tribe-events-calendar') . '</p>' : ''; } // endif wp_reset_query(); return $output; }
function widget($args, $instance) { extract($args); extract($instance); // DEFAULTS if (empty($instance)) { $widget_title = __('Event', "loc_sport_widgets_plugin"); $excerpt_length = 650; // get events $events = tribe_get_events(array('eventDisplay' => 'all', 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => 1)); $event_ID = $events[0]->ID; } $cost = tribe_get_formatted_cost($event_ID); // WPML if (function_exists('icl_translate')) { $widget_title = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[widget_title]", $widget_title); } if (function_exists('icl_translate')) { $cost = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[cost]", $cost); } if (!isset($event_ID) || empty($event_ID)) { return; } $event = get_post($event_ID); ?> <?php echo $before_widget; ?> <?php if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } ?> <!-- Start Post --> <div class="clearfix tribe-events-tcblock"> <!-- Event Cost --> <div class="tribe-events-event-cost"> <span><?php echo $cost; ?> </span> </div> <!-- Event Title --> <h2 class="tribe-events-list-event-title summary"> <?php printf('<a class="url" href="%s" title="%s" rel="bookmark">%s</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_attr(get_the_title($event_ID))); ?> </h2> <!-- Event Image --> <div class="tribe-events-event-image"> <?php if (has_post_thumbnail($event_ID) && get_post(get_post_thumbnail_id($event_ID))) { $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($event_ID), 'full'); printf('<a href="%s" title="%s"><img src="%s" title="%s"/></a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(get_the_title($event_ID)), esc_url($post_thumbnail_src[0]), esc_attr(get_the_title($event_ID))); } ?> </div> <!-- Event Meta --> <div class="tribe-events-event-meta vcard location"> <!-- Schedule & Recurrence Details --> <div class="updated published time-details"> <?php printf('<span class="date-start dtstart">%s</span>', esc_attr(tribe_get_start_date($event_ID))); ?> </div> <!-- Venue Display Info --> <div class="tribe-events-venue-details"> <span class="author fn org"><?php echo tribe_get_venue($event_ID); ?> </span>, <address class="tribe-events-address"> <span class="adr"> <span class="street-address"><?php echo tribe_get_address($event_ID); ?> </span> <span class="delimiter">,</span> <span class="locality"><?php echo tribe_get_city($event_ID); ?> </span> <span class="delimiter">,</span> <span class="postal-code"><?php echo tribe_get_zip($event_ID); ?> </span> <span class="country-name"><?php echo tribe_get_country($event_ID); ?> </span> </span> </address> <?php printf('<a class="tribe-events-gmap" href="%s" title="Click to view a Google Map" target="_blank">- Google Map</a>', esc_url(tribe_get_map_link($event_ID))); ?> </div> <!-- .tribe-events-venue-details --> </div><!-- .tribe-events-event-meta --> <!-- Event Content --> <div class="tribe-events-list-event-description tribe-events-content description entry-summary"> <?php $event_excerpt = !empty($event->post_excerpt) ? do_shortcode($event->post_excerpt) : mb_make_excerpt($event->post_content, $excerpt_length, true); // excerpt echo "<p>"; echo $event_excerpt; echo "</p>"; // read more printf('<a href="%s" class="tribe-events-read-more" rel="bookmark">%s »</a>', esc_url(tribe_get_event_link($event_ID)), esc_attr(__('Find out more', "loc_sport_widgets_plugin"))); ?> </div><!-- .tribe-events-list-event-description --> </div> <?php echo $after_widget; ?> <?php }
<?php } ?> <div class="tribe-event-schedule-details"> <?php echo tribe_events_event_schedule_details(); ?> </div> <!-- Event Title --> <?php do_action('tribe_events_before_the_event_title'); ?> <h2 class="tribe-events-list-event-title"> <a class="tribe-event-url" href="<?php echo esc_url(tribe_get_event_link()); ?> " title="<?php the_title_attribute(); ?> " rel="bookmark"> <?php the_title(); ?> </a> </h2> <?php do_action('tribe_events_after_the_event_title'); ?> <!-- Event Meta -->
<?php } else { ?> <?php do_action('tribe_events_venue_widget_before_the_list'); ?> <ul class="tribe-venue-widget-list"> <?php while ($events->have_posts()) { ?> <?php $events->the_post(); ?> <li> <h4><a href="<?php echo tribe_get_event_link(); ?> "><?php echo get_the_title(get_the_ID()); ?> </a></h4> <?php echo tribe_events_event_schedule_details(); ?> <?php if (tribe_get_cost(get_the_ID()) != '') { ?> <span class="tribe-events-divider">|</span> <span class="tribe-events-event-cost"> <?php echo tribe_get_cost(get_the_ID(), true);
/** * Returns json for javascript templating functions throughout the plugin. * * @category Events * * @param $event * @param $additional * * @return string */ function tribe_events_template_data($event, array $additional = null) { $has_image = false; $image_src = ''; $image_tool_src = ''; $date_display = ''; //Disable recurring event info in tooltip if (class_exists('Tribe__Events__Pro__Main')) { $ecp = Tribe__Events__Pro__Main::instance(); $ecp->disable_recurring_info_tooltip(); $date_display = strip_tags(tribe_events_event_schedule_details($event)); // Re-enable recurring event info $ecp->enable_recurring_info_tooltip(); } else { $date_display = strip_tags(tribe_events_event_schedule_details($event)); } if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) { $has_image = true; $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium'); $image_src = $image_arr[0]; } if ($has_image) { $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75)); $image_tool_src = $image_tool_arr[0]; } if (has_excerpt($event->ID)) { $excerpt = $event->post_excerpt; } else { $excerpt = $event->post_content; } $excerpt = Tribe__Events__Main::instance()->truncate($excerpt, 30); $category_classes = tribe_events_event_classes($event->ID, false); $json = array('eventId' => $event->ID, 'title' => $event->post_title, 'permalink' => tribe_get_event_link($event->ID), 'imageSrc' => $image_src, 'dateDisplay' => $date_display, 'imageTooltipSrc' => $image_tool_src, 'excerpt' => $excerpt, 'categoryClasses' => $category_classes); /** * Template overrides (of month/tooltip.php) set up in 3.9.3 or earlier may still expect * these vars and will break without them, so they are being kept temporarily for * backwards compatibility purposes. * * @todo consider removing in 4.0 */ $json['startTime'] = tribe_get_start_date($event); $json['endTime'] = tribe_get_end_date($event); if ($additional) { $json = array_merge((array) $json, (array) $additional); } $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional); $json = tribe_prepare_for_json_deep($json); return json_encode($json); }
* @author Modern Tribe Inc. * */ if (!defined('ABSPATH')) { die('-1'); } //Maximum Number of related posts to display $num_posts = 3; $posts = tribe_get_related_posts($num_posts); ?> <?php if (is_array($posts) && !empty($posts)) { echo '<h3 class="tribe-events-related-events-title">' . __('Related Events', 'tribe-events-calendar-pro') . '</h3>'; echo '<ul class="tribe-related-events tribe-clearfix hfeed vcalendar">'; foreach ($posts as $post) { echo '<li>'; $thumb = has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'large') : '<img src="' . trailingslashit(TribeEventsPro::instance()->pluginUrl) . 'resources/images/tribe-related-events-placeholder.png" alt="' . get_the_title($post->ID) . '" />'; echo '<div class="tribe-related-events-thumbnail">'; echo '<a href="' . tribe_get_event_link($post) . '" class="url" rel="bookmark">' . $thumb . '</a>'; echo '</div>'; echo '<div class="tribe-related-event-info">'; echo '<h3 class="tribe-related-events-title summary"><a href="' . tribe_get_event_link($post) . '" class="url" rel="bookmark">' . get_the_title($post->ID) . '</a></h3>'; if ($post->post_type == TribeEvents::POSTTYPE) { echo tribe_events_event_schedule_details($post); } echo '</div>'; echo '</li>'; } echo '</ul>'; }
/** * Injects a buy/RSVP button into oembeds for events when necessary */ public function inject_buy_button_into_oembed() { $event_id = get_the_ID(); if (!tribe_events_has_tickets($event_id)) { return; } $tickets = Tribe__Tickets__Tickets::get_all_event_tickets($event_id); $has_non_rsvp = false; $available = false; $now = current_time('timestamp'); foreach ($tickets as $ticket) { if ('Tribe__Tickets__RSVP' !== $ticket->provider_class) { $has_non_rsvp = true; } if ($ticket->date_in_range($now) && $ticket->is_in_stock()) { $available = true; } } // if there aren't any tickets available, bail if (!$available) { return; } $button_text = $has_non_rsvp ? __('Buy', 'event-tickets') : __('RSVP', 'event-tickets'); /** * Filters the text that appears in the buy/rsvp button on event oembeds * * @var string The button text * @var int Event ID */ $button_text = apply_filters('event_tickets_embed_buy_button_text', $button_text, $event_id); ob_start(); ?> <a class="tribe-event-buy" href="<?php echo esc_url(tribe_get_event_link()); ?> " title="<?php the_title_attribute(); ?> " rel="bookmark"><?php echo esc_html($button_text); ?> </a> <?php $buy_button = ob_get_clean(); /** * Filters the buy button that appears on event oembeds * * @var string The button markup * @var int Event ID */ echo apply_filters('event_tickets_embed_buy_button', $buy_button, $event_id); }
/** ** Get a "previous/next post" link for events. Ordered by start date instead of ID. **/ public function get_event_link($post, $mode = 'next', $anchor = false) { global $wpdb; if ($mode == 'previous') { $order = 'DESC'; $sign = '<'; } else { $order = 'ASC'; $sign = '>'; } $date = $post->EventStartDate; $id = $post->ID; $eventsQuery = "\n\t\t\t\tSELECT {$wpdb->posts}.*, d1.meta_value as EventStartDate\n\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\tLEFT JOIN {$wpdb->postmeta} as d1 ON({$wpdb->posts}.ID = d1.post_id)\n\t\t\t\tWHERE {$wpdb->posts}.post_type = '" . self::POSTTYPE . "'\n\t\t\t\tAND d1.meta_key = '_EventStartDate'\n\t\t\t\tAND ((d1.meta_value = '" . $date . "' AND ID {$sign} " . $id . ") OR\n\t\t\t\t\td1.meta_value {$sign} '" . $date . "')\n\t\t\t\tAND {$wpdb->posts}.post_status = 'publish'\n\t\t\t\tAND ({$wpdb->posts}.ID != {$id} OR d1.meta_value != '{$date}')\n\t\t\t\tORDER BY TIMESTAMP(d1.meta_value) {$order}, ID {$order}\n\t\t\t\tLIMIT 1"; $results = $wpdb->get_row($eventsQuery, OBJECT); if (is_object($results)) { if (!$anchor) { $anchor = $results->post_title; } elseif (strpos($anchor, '%title%') !== false) { $anchor = preg_replace('|%title%|', $results->post_title, $anchor); } echo '<a href=' . tribe_get_event_link($results) . '>' . $anchor . '</a>'; } }
function tribe_mini_display_day($day, $monthView) { $return = "<div class='daynum tribe-events-event' id='daynum_{$day}'>"; $return .= count($monthView[$day]) ? "<a class='tribe-events-mini-has-event'>{$day}</a>" : $day; $return .= "<div id='tooltip_day_{$day}' class='tribe-events-tooltip' style='display:none;'>"; for ($i = 0; $i < count($monthView[$day]); $i++) { $post = $monthView[$day][$i]; setup_postdata($post); $return .= '<h5 class="tribe-events-event-title-mini"><a href="' . tribe_get_event_link($post) . '">' . $post->post_title . '</a></h5>'; } $return .= '<span class="tribe-events-arrow"></span>'; $return .= '</div>'; $return .= "</div>"; return $return; }
/** * Fetch and return required events. * @param array $atts shortcode attributes * @return string shortcode output */ public function ecs_fetch_events($atts) { /** * Check if events calendar plugin method exists */ if (!function_exists('tribe_get_events')) { return; } global $wp_query, $post; $output = ''; $atts = shortcode_atts(array('cat' => '', 'month' => '', 'limit' => 5, 'eventdetails' => 'true', 'time' => null, 'past' => null, 'venue' => 'false', 'author' => null, 'message' => sprintf(__('There are no upcoming %s at this time.', 'tribe-events-calendar'), tribe_get_event_label_plural()), 'key' => 'End Date', 'order' => 'ASC', 'viewall' => 'false', 'excerpt' => 'false', 'thumb' => 'false', 'thumbwidth' => '', 'thumbheight' => '', 'contentorder' => 'title, thumbnail, excerpt, date, venue', 'event_tax' => ''), $atts, 'ecs-list-events'); // Category if ($atts['cat']) { if (strpos($atts['cat'], ",") !== false) { $atts['cats'] = explode(",", $atts['cat']); $atts['cats'] = array_map('trim', $atts['cats']); } else { $atts['cats'] = $atts['cat']; } $atts['event_tax'] = array('relation' => 'OR', array('taxonomy' => 'tribe_events_cat', 'field' => 'name', 'terms' => $atts['cats']), array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => $atts['cats'])); } // Past Event $meta_date_compare = '>='; $meta_date_date = date('Y-m-d'); if ($atts['time'] == 'past' || !empty($atts['past'])) { $meta_date_compare = '<'; } // Key if (str_replace(' ', '', trim(strtolower($atts['key']))) == 'startdate') { $atts['key'] = '_EventStartDate'; } else { $atts['key'] = '_EventEndDate'; } // Date $atts['meta_date'] = array(array('key' => $atts['key'], 'value' => $meta_date_date, 'compare' => $meta_date_compare, 'type' => 'DATETIME')); // Specific Month if ($atts['month'] == 'current') { $atts['month'] = date('Y-m'); } if ($atts['month']) { $month_array = explode("-", $atts['month']); $month_yearstr = $month_array[0]; $month_monthstr = $month_array[1]; $month_startdate = date($month_yearstr . "-" . $month_monthstr . "-1"); $month_enddate = date($month_yearstr . "-" . $month_monthstr . "-t"); $atts['meta_date'] = array(array('key' => $atts['key'], 'value' => array($month_startdate, $month_enddate), 'compare' => 'BETWEEN', 'type' => 'DATETIME')); } $posts = get_posts(array('post_type' => 'tribe_events', 'posts_per_page' => $atts['limit'], 'tax_query' => $atts['event_tax'], 'meta_key' => $atts['key'], 'orderby' => 'meta_value', 'author' => $atts['author'], 'order' => $atts['order'], 'meta_query' => array($atts['meta_date']))); if ($posts) { $output .= '<ul class="ecs-event-list">'; $atts['contentorder'] = explode(',', $atts['contentorder']); foreach ($posts as $post) { setup_postdata($post); $li_classes = 'ecs-event'; $start_date = tribe_get_start_date($post, false, 'Y-m-d'); $today = date('Y-m-d', current_time('timestamp')); $tomorrow = date('Y-m-d', strtotime('tomorrow', current_time('timestamp'))); if ($start_date == $today) { $li_classes .= ' ecs-today'; } else { if ($start_date == $tomorrow) { $li_classes .= ' ecs-tomorrow'; } } $output .= '<li class="' . $li_classes . '">'; // Put Values into $output foreach ($atts['contentorder'] as $contentorder) { switch (trim($contentorder)) { case 'title': $output .= '<h4 class="entry-title summary">' . '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . apply_filters('ecs_event_list_title', get_the_title(), $atts) . '</a> </h4>'; break; case 'thumbnail': if (self::isValid($atts['thumb'])) { $thumbWidth = is_numeric($atts['thumbwidth']) ? $atts['thumbwidth'] : ''; $thumbHeight = is_numeric($atts['thumbheight']) ? $atts['thumbheight'] : ''; if (!empty($thumbWidth) && !empty($thumbHeight)) { $output .= get_the_post_thumbnail($post->ID, array($thumbWidth, $thumbHeight)); } else { $size = !empty($thumbWidth) && !empty($thumbHeight) ? array($thumbWidth, $thumbHeight) : 'medium'; if ($thumb = get_the_post_thumbnail($post->ID, $size)) { $output .= '<a href="' . tribe_get_event_link() . '">'; $output .= $thumb; $output .= '</a>'; } } } break; case 'excerpt': if (self::isValid($atts['excerpt'])) { $excerptLength = is_numeric($atts['excerpt']) ? $atts['excerpt'] : 100; $output .= '<p class="ecs-excerpt">' . self::get_excerpt($excerptLength) . '</p>'; } break; case 'date': if (self::isValid($atts['eventdetails'])) { $output .= '<span class="duration time">' . apply_filters('ecs_event_list_details', tribe_events_event_schedule_details(), $atts) . '</span>'; } break; case 'venue': if (self::isValid($atts['venue'])) { $output .= '<span class="duration venue">' . apply_filters('ecs_event_list_venue', ' <em>at</em> ' . tribe_get_venue(), $atts) . '</span>'; } break; } } $output .= '</li>'; } $output .= '</ul>'; if (self::isValid($atts['viewall'])) { $output .= '<span class="ecs-all-events"><a href="' . apply_filters('ecs_event_list_viewall_link', tribe_get_events_link(), $atts) . '" rel="bookmark">' . translate(apply_filters('ecs_event_list_viewall_text', 'View All Events', $atts), 'tribe-events-calendar') . '</a></span>'; } } else { //No Events were Found $output .= translate($atts['message'], 'tribe-events-calendar'); } // endif wp_reset_query(); return $output; }
?> <div class="tribe-related-events-thumbnail hover-type-<?php echo Avada()->settings->get('ec_hover_type'); ?> "> <a href="<?php echo esc_url(tribe_get_event_link($post)); ?> " class="url" rel="bookmark"><?php echo $thumb; ?> </a> </div> <div class="tribe-related-event-info"> <h3 class="tribe-related-events-title summary"><a href="<?php echo tribe_get_event_link($post); ?> " class="url" rel="bookmark"><?php echo get_the_title($post->ID); ?> </a></h3> <?php if ($post->post_type == Tribe__Events__Main::POSTTYPE) { echo tribe_events_event_schedule_details($post); } ?> </div> </li> <?php } ?>
function tribe_event_andre_image($post_id = null, $size = 'full', $link = true) { if (is_null($post_id)) { $post_id = get_the_ID(); } $image_html = get_the_post_thumbnail($post_id, $size, array('itemprop' => 'image')); $featured_image = ''; //if link is not specifically excluded, then include <a> if (!empty($image_html) && $link) { $featured_image .= '<div class="tribe-events-event-image"><a href="' . esc_url(tribe_get_event_link()) . '">' . $image_html . '</a></div>'; } elseif (!empty($image_html)) { $featured_image .= '<div class="tribe-events-event-image">' . $image_html . '</div>'; } return apply_filters('tribe_event_featured_image', $featured_image, $post_id, $size); }
/** * Fetch and return required events. * @param array $atts shortcode attributes * @return string shortcode output */ public function ecs_fetch_events($atts) { /** * Check if events calendar plugin method exists */ if (!function_exists('tribe_get_events')) { return; } global $wp_query, $post; $output = ''; $ecs_event_tax = ''; extract(shortcode_atts(array('cat' => '', 'month' => '', 'limit' => 5, 'eventdetails' => 'true', 'time' => null, 'past' => null, 'venue' => 'false', 'author' => null, 'message' => 'There are no upcoming events at this time.', 'key' => 'End Date', 'order' => 'ASC', 'viewall' => 'false', 'excerpt' => 'false', 'thumb' => 'false', 'thumbwidth' => '', 'thumbheight' => '', 'contentorder' => 'title, thumbnail, excerpt, date, venue'), $atts, 'ecs-list-events'), EXTR_PREFIX_ALL, 'ecs'); // Category if ($ecs_cat) { $ecs_cats = explode(",", $ecs_cat); $ecs_cats = array_map('trim', $ecs_cats); $ecs_event_tax = array(array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => $ecs_cat)); } // Past Event $meta_date_compare = '>='; $meta_date_date = date('Y-m-d'); if ($ecs_time == 'past' || !empty($ecs_past)) { $meta_date_compare = '<'; } // Key if (str_replace(' ', '', trim(strtolower($ecs_key))) == 'startdate') { $ecs_key = '_EventStartDate'; } else { $ecs_key = '_EventEndDate'; } // Date $ecs_meta_date = array(array('key' => $ecs_key, 'value' => $meta_date_date, 'compare' => $meta_date_compare, 'type' => 'DATETIME')); // Specific Month if ($ecs_month == 'current') { $ecs_month = date('Y-m'); } if ($ecs_month) { $month_array = explode("-", $ecs_month); $month_yearstr = $month_array[0]; $month_monthstr = $month_array[1]; $month_startdate = date($month_yearstr . "-" . $month_monthstr . "-1"); $month_enddate = date($month_yearstr . "-" . $month_monthstr . "-t"); $ecs_meta_date = array(array('key' => $ecs_key, 'value' => array($month_startdate, $month_enddate), 'compare' => 'BETWEEN', 'type' => 'DATETIME')); } $posts = get_posts(array('post_type' => 'tribe_events', 'posts_per_page' => $ecs_limit, 'tax_query' => $ecs_event_tax, 'meta_key' => $ecs_key, 'orderby' => 'meta_value', 'author' => $ecs_author, 'order' => $ecs_order, 'meta_query' => array($ecs_meta_date))); if ($posts) { $output .= '<ul class="ecs-event-list">'; $ecs_contentorder = explode(',', $ecs_contentorder); foreach ($posts as $post) { setup_postdata($post); $output .= '<li class="ecs-event">'; // Put Values into $output foreach ($ecs_contentorder as $contentorder) { switch (trim($contentorder)) { case 'title': $output .= '<h4 class="entry-title summary">' . '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . get_the_title() . '</a> </h4>'; break; case 'thumbnail': if (self::isValid($ecs_thumb)) { $thumbWidth = is_numeric($ecs_thumbwidth) ? $ecs_thumbwidth : ''; $thumbHeight = is_numeric($ecs_thumbheight) ? $ecs_thumbheight : ''; if (!empty($thumbWidth) && !empty($thumbHeight)) { $output .= get_the_post_thumbnail(get_the_ID(), array($thumbWidth, $thumbHeight)); } else { $output .= get_the_post_thumbnail(get_the_ID(), 'medium'); } } break; case 'excerpt': if (self::isValid($ecs_excerpt)) { $excerptLength = is_numeric($ecs_excerpt) ? $ecs_excerpt : 100; $output .= '<p class="ecs-excerpt">' . self::get_excerpt($excerptLength) . '</p>'; } break; case 'date': if (self::isValid($ecs_eventdetails)) { $output .= '<span class="duration time">' . tribe_events_event_schedule_details() . '</span>'; } break; case 'venue': if (self::isValid($ecs_venue)) { $output .= '<span class="duration venue"><em> at </em>' . tribe_get_venue() . '</span>'; } break; } } $output .= '</li>'; } $output .= '</ul>'; if (self::isValid($ecs_viewall)) { $output .= '<span class="ecs-all-events"><a href="' . tribe_get_events_link() . '" rel="bookmark">' . translate('View All Events', 'tribe-events-calendar') . '</a></span>'; } } else { //No Events were Found $output .= translate($ecs_message, 'tribe-events-calendar'); } // endif wp_reset_query(); return $output; }
/** * Get a "previous/next post" link for events. Ordered by start date instead of ID. * * @param WP_Post $post The post/event. * @param string $mode Either 'next' or 'previous'. * @param mixed $anchor * * @return string The link (with <a> tags). */ public function get_event_link($post, $mode = 'next', $anchor = false) { global $wpdb; if ($mode == 'previous') { $order = 'DESC'; $sign = '<'; } else { $order = 'ASC'; $sign = '>'; } $date = $post->EventStartDate; $id = $post->ID; $eventsQuery = $wpdb->prepare("\n\t\t\t\tSELECT {$wpdb->posts}.*, d1.meta_value as EventStartDate\n\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\tLEFT JOIN {$wpdb->postmeta} as d1 ON({$wpdb->posts}.ID = d1.post_id)\n\t\t\t\tWHERE {$wpdb->posts}.post_type = '%s'\n\t\t\t\tAND d1.meta_key = '_EventStartDate'\n\t\t\t\tAND ((d1.meta_value = '%s' AND ID {$sign} %d) OR\n\t\t\t\t\td1.meta_value {$sign} '%s')\n\t\t\t\tAND {$wpdb->posts}.post_status = 'publish'\n\t\t\t\tAND ({$wpdb->posts}.ID != %d OR d1.meta_value != '%s')\n\t\t\t\tORDER BY TIMESTAMP(d1.meta_value) {$order}, ID {$order}\n\t\t\t\tLIMIT 1", self::POSTTYPE, $date, $id, $date, $id, $date); $args = array('post_type' => self::POSTTYPE, 'post_status' => 'publish', 'post__not_in' => array($post->ID), 'order' => $order, 'orderby' => "TIMESTAMP({$wpdb->postmeta}.meta_value) ID", 'posts_per_page' => 1, 'meta_query' => array(array('key' => '_EventStartDate', 'value' => $post->EventStartDate, 'type' => 'DATE'))); // TODO: Finish rewriting this query to be WP_QUERY based // TribeEventsQuery::deregister(); // $event_link = new WP_Query($args); // print_r($event_link); $results = $wpdb->get_row($eventsQuery, OBJECT); if (is_object($results)) { if (!$anchor) { $anchor = $results->post_title; } elseif (strpos($anchor, '%title%') !== false) { $anchor = preg_replace('|%title%|', $results->post_title, $anchor); } return apply_filters('tribe_events_get_event_link', '<a href="' . tribe_get_event_link($results) . '">' . $anchor . '</a>'); } }
/** * Replaces the link to the product with a link to the Event in the * order confirmation page. * * @param $url * @param $product_id * * @return string */ public function hijack_ticket_link($url, $product_id) { $event = get_post_meta($product_id, $this->event_key, true); if (!empty($event)) { $url = tribe_get_event_link($event); } return $url; }
/** * Returns json for javascript templating functions throughout the plugin. * * @category Events * * @param $event * @param $additional * * @return string */ function tribe_events_template_data($event = null, array $additional = null) { // Base JSON variable $json = array('i18n' => array()); if (!is_null($event)) { $event = get_post($event); // Check if we are dealing with an Event if (is_object($event) && $event instanceof WP_Post && tribe_is_event($event->ID)) { $has_image = false; $image_src = ''; $image_tool_src = ''; $date_display = ''; //Disable recurring event info in tooltip if (class_exists('Tribe__Events__Pro__Main')) { $ecp = Tribe__Events__Pro__Main::instance(); $ecp->disable_recurring_info_tooltip(); $date_display = strip_tags(tribe_events_event_schedule_details($event)); // Re-enable recurring event info $ecp->enable_recurring_info_tooltip(); } else { $date_display = strip_tags(tribe_events_event_schedule_details($event)); } if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) { $has_image = true; $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium'); $image_src = $image_arr[0]; } if ($has_image) { $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75)); $image_tool_src = $image_tool_arr[0]; } if (has_excerpt($event->ID)) { $excerpt = $event->post_excerpt; } else { $excerpt = $event->post_content; } $excerpt = Tribe__Events__Main::instance()->truncate($excerpt, 30); $category_classes = tribe_events_event_classes($event->ID, false); $json['eventId'] = $event->ID; $json['title'] = $event->post_title; $json['permalink'] = tribe_get_event_link($event->ID); $json['imageSrc'] = $image_src; $json['dateDisplay'] = $date_display; $json['imageTooltipSrc'] = $image_tool_src; $json['excerpt'] = $excerpt; $json['categoryClasses'] = $category_classes; /** * Template overrides (of month/tooltip.php) set up in 3.9.3 or earlier may still expect * these vars and will break without them, so they are being kept temporarily for * backwards compatibility purposes. * * @todo consider removing in 4.0 */ $json['startTime'] = tribe_get_start_date($event); $json['endTime'] = tribe_get_end_date($event); } } /** * Internationalization Strings */ $json['i18n']['find_out_more'] = esc_attr__('Find out more »', 'tribe-events-calendar'); $json['i18n']['for_date'] = esc_attr(sprintf(__('%s for', 'tribe-events-calendar'), tribe_get_event_label_plural())); if ($additional) { $json = array_merge((array) $json, (array) $additional); } $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional); $json = tribe_prepare_for_json_deep($json); return json_encode($json); }
/** * Fetch and return required events. * @param array $atts shortcode attributes * @return string shortcode output */ public function ecs_fetch_events($atts) { /** * Check if events calendar plugin method exists */ if (!function_exists('tribe_get_events')) { return; } global $wp_query, $post; $output = ''; $atts = shortcode_atts(apply_filters('ecs_shortcode_atts', array('cat' => '', 'month' => '', 'limit' => 5, 'eventdetails' => 'true', 'time' => null, 'past' => null, 'venue' => 'false', 'author' => null, 'message' => 'There are no upcoming events at this time.', 'key' => 'End Date', 'order' => 'ASC', 'viewall' => 'false', 'excerpt' => 'false', 'thumb' => 'false', 'thumbwidth' => '', 'thumbheight' => '', 'contentorder' => apply_filters('ecs_default_contentorder', 'title, thumbnail, excerpt, date, venue', $atts), 'event_tax' => ''), $atts), $atts, 'ecs-list-events'); // Category if ($atts['cat']) { if (strpos($atts['cat'], ",") !== false) { $atts['cats'] = explode(",", $atts['cat']); $atts['cats'] = array_map('trim', $atts['cats']); } else { $atts['cats'] = $atts['cat']; } $atts['event_tax'] = array('relation' => 'OR', array('taxonomy' => 'tribe_events_cat', 'field' => 'name', 'terms' => $atts['cats']), array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => $atts['cats'])); } // Past Event $meta_date_compare = '>='; $meta_date_date = current_time('Y-m-d H:i:s'); if ($atts['time'] == 'past' || !empty($atts['past'])) { $meta_date_compare = '<'; } // Key if (str_replace(' ', '', trim(strtolower($atts['key']))) == 'startdate') { $atts['key'] = '_EventStartDate'; } else { $atts['key'] = '_EventEndDate'; } // Date $atts['meta_date'] = array(array('key' => $atts['key'], 'value' => $meta_date_date, 'compare' => $meta_date_compare, 'type' => 'DATETIME')); // Specific Month if ($atts['month'] == 'current') { $atts['month'] = date('Y-m'); } if ($atts['month']) { $month_array = explode("-", $atts['month']); $month_yearstr = $month_array[0]; $month_monthstr = $month_array[1]; $month_startdate = date("Y-m-d", strtotime($month_yearstr . "-" . $month_monthstr . "-01")); $month_enddate = date("Y-m-01", strtotime("+1 month", strtotime($month_startdate))); $atts['meta_date'] = array(array('key' => $atts['key'], 'value' => array($month_startdate, $month_enddate), 'compare' => 'BETWEEN', 'type' => 'DATETIME')); } $posts = tribe_get_events(apply_filters('ecs_get_events_args', array('post_status' => 'publish', 'hide_upcoming' => true, 'posts_per_page' => $atts['limit'], 'tax_query' => $atts['event_tax'], 'meta_key' => $atts['key'], 'orderby' => 'meta_value', 'author' => $atts['author'], 'order' => $atts['order'], 'meta_query' => array($atts['meta_date'])), $atts)); if ($posts) { $output .= apply_filters('ecs_start_tag', '<ul class="ecs-event-list">', $atts); $atts['contentorder'] = explode(',', $atts['contentorder']); foreach ($posts as $post) { setup_postdata($post); $output .= apply_filters('ecs_event_start_tag', '<li class="ecs-event">', $atts, $post); // Put Values into $output foreach (apply_filters('ecs_event_contentorder', $atts['contentorder'], $atts, $post) as $contentorder) { switch (trim($contentorder)) { case 'title': $output .= apply_filters('ecs_event_title_tag_start', '<h4 class="entry-title summary">', $atts, $post) . '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . apply_filters('ecs_event_list_title', get_the_title(), $atts, $post) . '</a>' . apply_filters('ecs_event_title_tag_end', '</h4>', $atts, $post); break; case 'thumbnail': if (self::isValid($atts['thumb'])) { $thumbWidth = is_numeric($atts['thumbwidth']) ? $atts['thumbwidth'] : ''; $thumbHeight = is_numeric($atts['thumbheight']) ? $atts['thumbheight'] : ''; if (!empty($thumbWidth) && !empty($thumbHeight)) { $output .= apply_filters('ecs_event_thumbnail', get_the_post_thumbnail(get_the_ID(), apply_filters('ecs_event_thumbnail_size', array($thumbWidth, $thumbHeight), $atts, $post)), $atts, $post); } else { if ($thumb = get_the_post_thumbnail(get_the_ID(), apply_filters('ecs_event_thumbnail_size', 'medium', $atts, $post))) { $output .= apply_filters('ecs_event_thumbnail_link_start', '<a href="' . tribe_get_event_link() . '">', $atts, $post); $output .= apply_filters('ecs_event_thumbnail', $thumb, $atts, $post); $output .= apply_filters('ecs_event_thumbnail_link_end', '</a>', $atts, $post); } } } break; case 'excerpt': if (self::isValid($atts['excerpt'])) { $excerptLength = is_numeric($atts['excerpt']) ? $atts['excerpt'] : 100; $output .= apply_filters('ecs_event_excerpt_tag_start', '<p class="ecs-excerpt">', $atts, $post) . apply_filters('ecs_event_excerpt', self::get_excerpt($excerptLength), $atts, $post) . apply_filters('ecs_event_excerpt_tag_end', '</p>', $atts, $post); } break; case 'date': if (self::isValid($atts['eventdetails'])) { $output .= apply_filters('ecs_event_date_tag_start', '<span class="duration time">', $atts, $post) . apply_filters('ecs_event_list_details', tribe_events_event_schedule_details(), $atts, $post) . apply_filters('ecs_event_date_tag_end', '</span>', $atts, $post); } break; case 'venue': if (self::isValid($atts['venue'])) { $output .= apply_filters('ecs_event_venue_tag_start', '<span class="duration venue">', $atts, $post) . apply_filters('ecs_event_venue_at_tag_start', '<em> ', $atts, $post) . apply_filters('ecs_event_venue_at_text', __('at', 'the-events-calendar-shortcode'), $atts, $post) . apply_filters('ecs_event_venue_at_tag_end', ' </em>', $atts, $post) . apply_filters('ecs_event_list_venue', tribe_get_venue(), $atts, $post) . apply_filters('ecs_event_venue_tag_end', '</span>', $atts, $post); } break; case 'date_thumb': if (self::isValid($atts['eventdetails'])) { $output .= apply_filters('ecs_event_date_thumb', '<div class="date_thumb"><div class="month">' . tribe_get_start_date(null, false, 'M') . '</div><div class="day">' . tribe_get_start_date(null, false, 'j') . '</div></div>', $atts, $post); } break; default: $output .= apply_filters('ecs_event_list_output_custom', '', trim($contentorder), $atts, $post); } } $output .= apply_filters('ecs_event_end_tag', '</li>', $atts, $post); } $output .= apply_filters('ecs_end_tag', '</ul>', $atts); if (self::isValid($atts['viewall'])) { $output .= apply_filters('ecs_view_all_events_tag_start', '<span class="ecs-all-events">', $atts) . '<a href="' . apply_filters('ecs_event_list_viewall_link', tribe_get_events_link(), $atts) . '" rel="bookmark">' . translate('View All Events', 'tribe-events-calendar') . '</a>'; $output .= apply_filters('ecs_view_all_events_tag_end', '</span>'); } } else { //No Events were Found $output .= apply_filters('ecs_no_events_found_message', translate($atts['message'], 'tribe-events-calendar'), $atts); } // endif wp_reset_query(); return $output; }
/** * Single Event Link (Display) * * Display link to a single event * * @param null|int $post Optional post ID * @return string Link html */ function tribe_event_link($post = null) { // pass in whole post object to retain start date echo apply_filters('tribe_event_link', tribe_get_event_link($post)); }
<?php } ?> <?php if (tribe_is_day() && $first) { $first = false; ?> <h4 class="event-day"><?php echo tribe_event_format_date(strtotime(get_query_var('eventDate')), false); ?> </h4> <?php } ?> <?php the_title('<h2 class="entry-title" itemprop="name"><a href="' . tribe_get_event_link() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>'); ?> <div class="entry-content tribe-events-event-entry" itemprop="description"> <?php if (has_excerpt()) { ?> <?php the_excerpt(); ?> <?php } else { ?> <?php the_content(); ?> <?php
function tribe_mini_display_day($day, $monthView, $month = NULL, $date = NULL) { $tribe_ecp = TribeEvents::instance(); $monthName = $tribe_ecp->monthsShort[date('M', $date)]; $dayofweeek = tribe_event_format_date(false, 'D'); $return = "<div class='daynum tribe-events-event' id='daynum_{$day}'>"; $return .= count($monthView[$day]) ? "<a class='tribe-events-mini-has-event'><span class='tribe-month-name'>{$monthName} {$dayofweeek}</span>{$day}</a>" : $day; /**/ $return .= "<div id='tooltip_day_{$day}' class='tribe-events-tooltip' style='display:none;'>"; for ($i = 0; $i < count($monthView[$day]); $i++) { $post = $monthView[$day][$i]; setup_postdata($post); $return .= '<h5 class="tribe-events-event-title-mini"><a href="' . tribe_get_event_link($post) . '">' . $post->post_title . '</a></h5>'; } //$return .= '<span class="tribe-events-arrow"></span>'; $return .= '</div>'; /**/ $return .= "</div>"; return $return; }
/** * @deprecated * * Display link to a single event * * @param null|int $post Optional post ID * * @return string Link html */ function tribe_event_link($post = null) { _deprecated_function(__FUNCTION__, '4.0', 'tribe_get_event_link()'); echo apply_filters('tribe_event_link', tribe_get_event_link($post)); }
/** * Get a "previous/next post" link for events. Ordered by start date instead of ID. * * @param WP_Post $post The post/event. * @param string $mode Either 'next' or 'previous'. * @param mixed $anchor * * @return string The link (with <a> tags). */ public function get_event_link($post, $mode = 'next', $anchor = false) { global $wpdb; $link = ''; if ('previous' === $mode) { $order = 'DESC'; $direction = '<'; } else { $order = 'ASC'; $direction = '>'; $mode = 'next'; } $args = array('post__not_in' => array($post->ID), 'order' => $order, 'orderby' => "TIMESTAMP( {$wpdb->postmeta}.meta_value ) ID", 'posts_per_page' => 1, 'meta_query' => array(array('key' => '_EventStartDate', 'value' => $post->EventStartDate, 'type' => 'DATETIME', 'compare' => $direction), array('key' => '_EventHideFromUpcoming', 'compare' => 'NOT EXISTS'), 'relation' => 'AND')); /** * Allows the query arguments used when retrieving the next/previous event link * to be modified. * * @var array $args * @var WP_Post $post * @var boolean $anchor */ $args = (array) apply_filters("tribe_events_get_{$mode}_event_link", $args, $post, $anchor); $results = tribe_get_events($args); // If we successfully located the next/prev event, we should have precisely one element in $results if (1 === count($results)) { $event = current($results); if (!$anchor) { $anchor = apply_filters('the_title', $event->post_title); } elseif (strpos($anchor, '%title%') !== false) { // get the nicely filtered post title $title = apply_filters('the_title', $event->post_title, $event->ID); // escape special characters used in the second parameter of preg_replace $title = str_replace(array('\\', '$'), array('\\\\', '\\$'), $title); $anchor = preg_replace('|%title%|', $title, $anchor); } $link = '<a href="' . esc_url(tribe_get_event_link($event)) . '">' . $anchor . '</a>'; } /** * Affords an opportunity to modify the event link (typically for the next or previous * event in relation to $post). * * @var string $link * @var WP_Post $post * @var string $mode (typically "previous" or "next") * @var string $anchor */ return apply_filters('tribe_events_get_event_link', $link, $post, $mode, $anchor); }
/** * return the featured image html to an event (within the loop automatically will get event ID) * * @since 3.0 * @param int $post_id * @param string $size * @return string */ function tribe_event_featured_image($post_id = null, $size = 'full') { if (is_null($post_id)) { $post_id = get_the_ID(); } $image_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size); $featured_image = ''; if (!empty($image_src)) { $featured_image .= '<div class="tribe-events-event-image"><a href="' . tribe_get_event_link() . '" title="' . get_the_title($post_id) . '"><img src="' . $image_src[0] . '" title="' . get_the_title($post_id) . '" /></a></div>'; } return apply_filters('tribe_event_featured_image', $featured_image); }
/** * Single Event Link (Display) * * Display link to a single event * * @param int $postId (optional) * @since 2.0 */ function tribe_event_link($post = null) { // pass in whole post object to retain start date echo tribe_get_event_link($post); }
/** * Get a "previous/next post" link for events. Ordered by start date instead of ID. * * @param WP_Post $post The post/event. * @param string $mode Either 'next' or 'previous'. * @param mixed $anchor * * @return string The link (with <a> tags). */ public function get_event_link($post, $mode = 'next', $anchor = false) { $link = null; $event = $this->get_closest_event($post, $mode); // If we successfully located the next/prev event, we should have precisely one element in $results if ($event) { if (!$anchor) { $anchor = apply_filters('the_title', $event->post_title, $event->ID); } elseif (strpos($anchor, '%title%') !== false) { // get the nicely filtered post title $title = apply_filters('the_title', $event->post_title, $event->ID); // escape special characters used in the second parameter of preg_replace $title = str_replace(array('\\', '$'), array('\\\\', '\\$'), $title); $anchor = preg_replace('|%title%|', $title, $anchor); } $link = '<a href="' . esc_url(tribe_get_event_link($event)) . '">' . $anchor . '</a>'; } /** * Affords an opportunity to modify the event link (typically for the next or previous * event in relation to $post). * * @var string $link * @var WP_Post $post * @var string $mode (typically "previous" or "next") * @var string $anchor */ return apply_filters('tribe_events_get_event_link', $link, $post, $mode, $anchor); }
* */ if (!defined('ABSPATH')) { die('-1'); } global $post; /** * We build and gather information specific to the individual event prior to * the tribe_events_template_data() call to reduce the opportunities for 3rd * party code to call wp_reset_postdata() or similar, which can result in the * $post global referencing something other than the event we're interested * in. */ $day = tribe_events_get_current_month_day(); $event_id = "{$post->ID}-{$day['daynum']}"; $link = tribe_get_event_link($post); $title = get_the_title($post); /** * How to Use the Javascript Templating System in this View * ======================================================== * * Month view (and week in events pro) has implemented javascript templating to power its rich tooltips and mobile views * as of Events Version 3.3. This is a guide on how to modify, extend and use this functionality. * * 1) Overview * * As of version 3.3 our tooltips and mobile views use a custom javascript templating solution. * * How it works: event data for each event - such as title, start and end time, excerpt etc - is stored on a data * attribute tagged "data-tribejson" in the markup. This particular json works with simple single level key value pairs. * The key is used in the javascript template to call our value output.
/** * Returns json for javascript templating functions throughout the plugin. * * @param $event * @param $additional * * @return string */ function tribe_events_template_data($event, array $additional = null) { $has_image = false; $start_time = ''; $end_time = ''; $image_src = ''; $image_tool_src = ''; // @TODO use tribe_events_event_schedule_details() $date_format = tribe_get_date_format(true); $time_format = get_option('time_format', TribeDateUtils::TIMEFORMAT); $date_time_separator = tribe_get_option('dateTimeSeparator', ' @ '); if (!empty($event->EventStartDate)) { $start_time .= date_i18n($date_format, strtotime($event->EventStartDate)); } if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $start_time .= $date_time_separator . date_i18n($time_format, strtotime($event->EventStartDate)); } if (!empty($event->EventEndDate) && $event->EventStartDate !== $event->EventEndDate) { if (date('Y-m-d', strtotime($event->EventStartDate)) == date('Y-m-d', strtotime($event->EventEndDate))) { if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= date_i18n($time_format, strtotime($event->EventEndDate)); } } else { $end_time .= date_i18n($date_format, strtotime($event->EventEndDate)); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= $date_time_separator . date_i18n($time_format, strtotime($event->EventEndDate)); } } } if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) { $has_image = true; $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium'); $image_src = $image_arr[0]; } if ($has_image) { $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75)); $image_tool_src = $image_tool_arr[0]; } if (has_excerpt($event->ID)) { $excerpt = $event->post_excerpt; } else { $excerpt = $event->post_content; } $excerpt = TribeEvents::instance()->truncate($excerpt, 30); $category_classes = tribe_events_event_classes($event->ID, false); $json = array('eventId' => $event->ID, 'title' => $event->post_title, 'permalink' => tribe_get_event_link($event->ID), 'imageSrc' => $image_src, 'startTime' => $start_time, 'endTime' => $end_time, 'imageTooltipSrc' => $image_tool_src, 'excerpt' => $excerpt, 'categoryClasses' => $category_classes); if ($additional) { $json = array_merge((array) $json, (array) $additional); } $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional); $json = tribe_prepare_for_json_deep($json); return json_encode($json); }