/** * Returns an array with details of the event's reoccurences * @since 1.0.0 * @deprecated 1.6 * @see eo_get_event_schedule() * * @param int $post_id Optional, the event (post) ID, * @return array Schedule information */ function eo_get_reoccurrence($post_id = 0) { return eo_get_reoccurence($post_id); }
/** * Returns a summary of the events schedule. * * @param id - Optional, the event (post) ID, * @since 1.0.0 */ function eo_get_schedule_summary($id = '') { global $post, $wp_locale; $ical2day = array('SU' => $wp_locale->weekday[0], 'MO' => $wp_locale->weekday[1], 'TU' => $wp_locale->weekday[2], 'WE' => $wp_locale->weekday[3], 'TH' => $wp_locale->weekday[4], 'FR' => $wp_locale->weekday[5], 'SA' => $wp_locale->weekday[6]); $nth = array(__('last', 'eventorganiser'), '', __('first', 'eventorganiser'), __('second', 'eventorganiser'), __('third', 'eventorganiser'), __('fourth', 'eventorganiser')); $reoccur = eo_get_reoccurence($id); if (empty($reoccur)) { return false; } $return = ''; if ($reoccur['reoccurrence'] == 'once') { $return = __('one time only', 'eventorganiser'); } else { switch ($reoccur['reoccurrence']) { case 'daily': if ($reoccur['frequency'] == 1) { $return .= __('every day', 'eventorganiser'); } else { $return .= sprintf(__('every %d days', 'eventorganiser'), $reoccur['frequency']); } break; case 'weekly': if ($reoccur['frequency'] == 1) { $return .= __('every week on', 'eventorganiser'); } else { $return .= sprintf(__('every %d weeks on', 'eventorganiser'), $reoccur['frequency']); } $weekdays = $reoccur['meta']; foreach ($weekdays as $ical_day) { $days[] = $ical2day[$ical_day]; } $return .= ' ' . implode(', ', $days); break; case 'monthly': if ($reoccur['frequency'] == 1) { $return .= __('every month on the', 'eventorganiser'); } else { $return .= sprintf(__('every %d months on the', 'eventorganiser'), $reoccur['frequency']); } $return .= ' '; $bymonthday = preg_match('/^BYMONTHDAY=(\\d{1,2})/', $reoccur['meta'], $matches); if ($bymonthday) { $d = intval($matches[1]); $m = intval($reoccur['start']->format('n')); $y = intval($reoccur['start']->format('Y')); $reoccur['start']->setDate($y, $m, $d); $return .= $reoccur['start']->format('jS'); } elseif ($reoccur['meta'] == 'date') { $return .= $reoccur['start']->format('jS'); } else { $byday = preg_match('/^BYDAY=(-?\\d{1,2})([a-zA-Z]{2})/', $reoccur['meta'], $matches); if ($byday) { $n = intval($matches[1]) + 1; $return .= $nth[$n] . ' ' . $ical2day[$matches[2]]; } else { $bydayOLD = preg_match('/^(-?\\d{1,2})([a-zA-Z]{2})/', $reoccur['meta'], $matchesOLD); $n = intval($matchesOLD[1]) + 1; $return .= $nth[$n] . ' ' . $ical2day[$matchesOLD[2]]; } } break; case 'yearly': if ($reoccur['frequency'] == 1) { $return .= __('every year', 'eventorganiser'); } else { $return .= sprintf(__('every %d years', 'eventorganiser'), $reoccur['frequency']); } break; } $return .= ' ' . __('until', 'eventorganiser') . ' ' . eo_format_datetime($reoccur['end'], 'M, jS Y'); } return $return; }