$next = eo_get_next_occurrence($date_format); ?> <?php if ($next) { ?> <!-- If the event is occurring again in the future, display the date --> <?php printf(__('This event is running from %1$s until %2$s. It is next occurring at %3$s', 'eventorganiser'), eo_get_schedule_start('d F Y'), eo_get_schedule_end('d F Y'), $next); ?> <?php } else { ?> <!-- Otherwise the event has finished (no more occurrences) --> <?php printf(__('This event finished on %s', 'eventorganiser'), eo_get_schedule_end('d F Y', '')); ?> <?php } ?> <?php } else { ?> <!-- Event is a single event --> <?php printf(__('This event is on %s', 'eventorganiser'), eo_get_the_start($date_format)); ?> <?php } ?>
static function parse_template($matches) { global $post; $replacement = ''; switch ($matches[1]) { case 'event_title': $replacement = get_the_title(); break; case 'start': case 'end': case 'schedule_start': case 'schedule_last': case 'schedule_end': switch (count($matches)) { case 2: $dateFormat = get_option('date_format'); $dateTime = get_option('time_format'); break; case 3: $dateFormat = self::eo_clean_input($matches[2]); $dateTime = ''; break; case 5: $dateFormat = self::eo_clean_input($matches[3]); $dateTime = self::eo_clean_input($matches[4]); break; } $format = eo_is_all_day(get_the_ID()) ? $dateFormat : $dateFormat . $dateTime; switch ($matches[1]) { case 'start': $replacement = eo_get_the_start($format); break; case 'end': $replacement = eo_get_the_end($format); break; case 'schedule_start': $replacement = eo_get_schedule_start($format); break; case 'schedule_last': case 'schedule_end': $replacement = eo_get_schedule_end($format); break; } break; case 'event_duration': $start = eo_get_the_start(DATETIMEOBJ); $end = clone eo_get_the_end(DATETIMEOBJ); if (eo_is_all_day()) { $end->modify('+1 minute'); } if (function_exists('date_diff')) { $duration = date_diff($start, $end); $replacement = $duration->format($matches[2]); } else { $replacement = eo_date_interval($start, $end, $matches[2]); } $replacement = false; break; case 'event_tags': $replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); break; case 'event_cats': $replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', ''); break; case 'event_venue': $replacement = eo_get_venue_name(); break; case 'event_venue_map': if (eo_get_venue()) { $class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $class = !empty($class) ? 'class=' . $class : ''; $replacement = eo_get_venue_map(eo_get_venue(), compact('class')); } break; case 'event_venue_url': $venue_link = eo_get_venue_link(); $replacement = !is_wp_error($venue_link) ? $venue_link : ''; break; case 'event_venue_address': $address = eo_get_venue_address(); $replacement = $address['address']; break; case 'event_venue_postcode': $address = eo_get_venue_address(); $replacement = $address['postcode']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_venue_country': $address = eo_get_venue_address(); $replacement = $address['country']; break; case 'event_venue_state': $address = eo_get_venue_address(); $replacement = $address['state']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_thumbnail': $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $size = !empty($size) ? $size : 'thumbnail'; $attr = isset($matches[3]) ? self::eo_clean_input($matches[3]) : ''; //Decode HTML entities as shortcode encodes them $attr = html_entity_decode($attr); $replacement = get_the_post_thumbnail(get_the_ID(), $size, $attr); break; case 'event_url': $replacement = get_permalink(); break; case 'event_custom_field': $field = $matches[2]; $meta = get_post_meta(get_the_ID(), $field); $replacement = implode($meta); break; case 'event_excerpt': $length = isset($matches[2]) ? intval($matches[2]) : 55; //Using get_the_excerpt adds a link.... if (post_password_required($post)) { $output = __('There is no excerpt because this is a protected post.'); } else { $output = $post->post_excerpt; } $replacement = eventorganiser_trim_excerpt($output, $length); break; case 'event_content': $replacement = get_the_content(); break; case 'cat_color': $replacement = eo_get_event_color(); break; case 'event_title_attr': $replacement = get_the_title(); break; } return $replacement; }
/** * Echos the formated date of the last occurrence * * @param string - the format to use, using PHP Date format * @param id - Optional, the event (post) ID, * * @uses eo_get_schedule_start * * @since 1.0.0 */ function eo_schedule_end($format = 'd-m-Y', $id = '') { echo eo_get_schedule_end($format, $id); }