function em_display_event_occurrences($format = '', $args = array()) { $occurrences = em_get_occurrences(); $all_day_event = em_is_all_day(); $html = ''; // default args $defaults = array('separator' => ' - ', 'format' => 'link', 'before' => '', 'after' => '', 'show_author_link' => false, 'echo' => true); $args = apply_filters('em_display_event_occurrences_args', wp_parse_args($args, $defaults)); // date format options $options = get_option('events_maker_general'); $date_format = $options['datetime_format']['date']; $time_format = $options['datetime_format']['time']; // if format was set, use it if (!empty($format) && is_array($format)) { $date_format = !empty($format['date']) ? $format['date'] : $date_format; $time_format = !empty($format['time']) ? $format['time'] : $time_format; } // generate output $html .= $args['before']; if (!empty($occurrences)) { foreach ($occurrences as $date) { // is all day if ($all_day_event && !empty($date['start']) && !empty($date['end'])) { // format date (date only) $date['start'] = em_format_date($date['start'], 'date', $date_format); $date['end'] = em_format_date($date['end'], 'date', $date_format); // one day only if ($date['start'] === $date['end']) { $date_output = $date['start']; } else { $date_output = implode(' ' . $args['separator'] . ' ', $date); } } elseif (!$all_day_event && !empty($date['start']) && !empty($date['end'])) { // one day only if (em_format_date($date['start'], 'date') === em_format_date($date['end'], 'date')) { $date_output = em_format_date($date['start'], 'datetime', $format) . ' ' . $args['separator'] . ' ' . em_format_date($date['end'], 'time', $format); } else { $date_output = em_format_date($date['start'], 'datetime', $format) . ' ' . $args['separator'] . ' ' . em_format_date($date['end'], 'datetime', $format); } } else { $date_output = em_format_date($date['start'], 'datetime', $format) . ' ' . $args['separator'] . ' ' . em_format_date($date['end'], 'datetime', $format); } // output format if ($args['format'] == 'link') { $html .= sprintf('<span class="entry-date date"><a href="%1$s" rel="bookmark"><abbr class="dtstart" title="%2$s"></abbr><abbr class="dtend" title="%3$s"></abbr>%4$s</a></span>', esc_url(get_permalink()), esc_attr($date['start']), esc_attr($date['end']), esc_html($date_output)); } else { $html .= sprintf('<span class="entry-date date"><abbr class="dtstart" title="%1$s"></abbr><abbr class="dtend" title="%2$s"></abbr>%3$s</span>', esc_attr($date['start']), esc_attr($date['end']), esc_html($date_output)); } } } // author link if ($args['show_author_link'] === true) { $html .= sprintf('<span class="byline"><span class="author vcard"><a class="url fn n" href="%1$s" rel="author">%2$s</a></span></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), get_the_author()); } $html .= $args['after']; $html = apply_filters('em_display_event_occurrences', $html); if ($args['echo'] === true) { echo $html; } else { return $html; } }
/** * Get event end date. * * @param int $post_id * @param string $type * @uses em_format_date() * @return string */ function em_get_the_end($post_id = 0, $type = 'datetime') { $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id); if (empty($post_id)) { return false; } $date = get_post_meta((int) $post_id, '_event_end_date', true); return apply_filters('em_get_the_end', !empty($date) ? em_format_date($date, $type) : false, $post_id); }
function em_page_title($echo = true) { $date = get_query_var('event_ondate'); if (em_is_event_archive('day')) { $page_title = sprintf(__('Event Daily Archives: %s', 'events-maker'), '<span>' . em_format_date($date, 'date') . '</span>'); } elseif (em_is_event_archive('month')) { $page_title = sprintf(__('Event Monthly Archives: %s', 'events-maker'), '<span>' . em_format_date($date . '/28', 'date', _x('F Y', 'monthly archives date format', 'events-maker')) . '</span>'); } elseif (em_is_event_archive('year')) { $page_title = sprintf(__('Event Yearly Archives: %s', 'events-maker'), '<span>' . em_format_date($date . '/01/28', 'date', _x('Y', 'yearly archives date format', 'events-maker')) . '</span>'); } elseif (is_tax('event-category')) { $page_title = sprintf(__('Events Category: %s', 'events-maker'), single_term_title('', false)); } elseif (is_tax('event-location')) { $page_title = sprintf(__('Events Location: %s', 'events-maker'), single_term_title('', false)); } elseif (is_tax('event-organizer')) { $page_title = sprintf(__('Events Organizer: %s', 'events-maker'), single_term_title('', false)); } elseif (is_tax('event-tag')) { $page_title = sprintf(__('Events Tag: %s', 'events-maker'), single_term_title('', false)); } else { $page_title = __('Events', 'events-maker'); } $page_title = apply_filters('em_page_title', $page_title); if ($echo) { echo $page_title; } else { return $page_title; } }