function eo_get_reoccurence($id = '') { global $post, $allowed_reoccurs; $event = $post; if (isset($id) && $id != '') { $event = eo_get_by_postid($id); } if (empty($event)) { return false; } if ($event->event_id) { $return['frequency'] = absint($event->event_frequency); $return['reoccurrence'] = esc_html($event->event_schedule); if ($return['reoccurrence'] == 'weekly') { $return['meta'] = array_map('esc_attr', unserialize($event->event_schedule_meta)); } else { $return['meta'] = esc_attr($event->event_schedule_meta); } $return['start'] = new DateTIme(esc_html($event->reoccurrence_start) . ' ' . esc_html($event->StartTime)); $return['end'] = new DateTIme(esc_html($event->reoccurrence_end) . ' ' . esc_html($event->FinishTime)); } else { return; } return $return; }
/** * Returns the end date of occurrence of event. * * If used inside the loop, with no id no set, returns end date of * current event occurrence. * * **Please note:** This function used to accept 3 arguments, it now accepts 4, but with the third deprecated. * The third argument specified the occurrence (are 3 for the 3rd occurrence of an event). * Instead now use the fourth argument - which specifies the occurrence by ID. * * ### Examples * Inside the loop, you can output the end date of event (occurrence) * <code> * <php echo eo_get_the_end('jS M YY'); ?> * </code> * Get the end date of the event with id 7 and occurrence ID 3 * <code> * <?php $date = eo_get_the_end('jS M YY',7,null, 3); ?> * </code> * Print a list of upcoming events with their start and end date * <code> * //Get upcoming events * $events = eo_get_events(array( * 'numberposts'=>5, * 'events_start_after'=>'today', * 'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe. * )); * * * if( $events ){ * echo '<ul>'; * foreach( $events as $event ){ * printf("<li><a href='%s' >%s</a> from %s to %s </li>", * get_the_permalink($post->ID), * get_the_title($post->ID), * eo_get_the_start('jS F Y', $post->ID,null,$post->occurrence_id), * eo_get_the_end('jS F Y', $post->ID,null,$post->occurrence_id) * ); * } * echo '</ul>'; * }else{ * echo 'No Upcoming Events'; * } * </code> * * @since 1.0.0 * @package event-date-functions * @param string $format String of format as accepted by PHP date * @param int $post_id The event (post) ID. Uses current event if empty. * @param int $deprecated The occurrence number. Deprecated. Use $occurrence_id instead * @param int $occurrence_id The occurrence ID * @return string the end date formated to given format, as accepted by PHP date */ function eo_get_the_end($format = 'd-m-Y', $post_id = 0, $deprecated = 0, $occurrence_id = 0) { global $post; $event = $post; if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '1.5.6', 'Third argument is depreciated. Please use a fourth argument - occurrence ID. Available from $post->occurrence_id'); //Backwards compatiblity if (!empty($post_id)) { $event = eo_get_by_postid($post_id, $deprecated, $occurrence_id); } if (empty($event)) { return false; } $date = trim($event->EndDate) . ' ' . trim($event->FinishTime); if (empty($date) || $date == " ") { return false; } return eo_format_date($date, $format); } $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id); $occurrence_id = (int) (empty($occurrence_id) && isset($event->occurrence_id) ? $event->occurrence_id : $occurrence_id); $occurrences = eo_get_the_occurrences_of($post_id); if (!$occurrences || !isset($occurrences[$occurrence_id])) { return false; } $end = $occurrences[$occurrence_id]['end']; /** * Filters the value returned by `eo_get_the_end()` * * @param string|DateTime $formatted_end The DateTime object or formatted returned value (as determined by $format) * @param DateTime $end The end date as a DateTime object * @param string $format The format the end date should be returned in * @param int $post_id Post ID of the event * @param int $occurrence_id The occurrence ID */ $formatted_date = apply_filters('eventorganiser_get_the_end', eo_format_datetime($end, $format), $end, $format, $post_id, $occurrence_id); return $formatted_date; }
/** * Returns the end date of occurrence of event. * * If used inside the loop, with no id no set, returns end date of * current event occurrence. * * **Please note:** This function used to accept 3 arguments, it now accepts 4, but with the third deprecated. * The third argument specified the occurrence (are 3 for the 3rd occurrence of an event). * Instead now use the fourth argument - which specifies the occurrence by ID. * * ### Examples * Inside the loop, you can output the end date of event (occurrence) * <code> * <php echo eo_get_the_end('jS M YY'); ?> * </code> * Get the end date of the event with id 7 and occurrence ID 3 * <code> * <?php $date = eo_get_the_end('jS M YY',7,null, 3); ?> * </code> * Print a list of upcoming events with their start and end date * <code> * //Get upcoming events * $events = eo_get_events(array( * 'numberposts'=>5, * 'events_start_after'=>'today', * 'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe. * )); * * * if( $events ){ * echo '<ul>'; * foreach( $events as $event ){ * printf("<li><a href='%s' >%s</a> from %s to %s </li>", * get_the_permalink($post->ID), * get_the_title($post->ID), * eo_get_the_start('jS F Y', $post->ID,null,$post->occurrence_id), * eo_get_the_end('jS F Y', $post->ID,null,$post->occurrence_id) * ); * } * echo '</ul>'; * }else{ * echo 'No Upcoming Events'; * } * </code> * * @since 1.0.0 * @package event-date-functions * @param string $format String of format as accepted by PHP date * @param int $post_id The event (post) ID. Uses current event if empty. * @param int $deprecated The occurrence number. Deprecated. Use $occurrence_id instead * @param int $occurrence_id The occurrence ID * @return string the end date formated to given format, as accepted by PHP date */ function eo_get_the_end($format = 'd-m-Y', $post_id = 0, $deprecated = 0, $occurrence_id = 0) { global $post; $event = $post; if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '1.5.6', 'Third argument is depreciated. Please use a fourth argument - occurrence ID. Available from $post->occurrence_id'); //Backwards compatiblity if (!empty($post_id)) { $event = eo_get_by_postid($post_id, $deprecated, $occurrence_id); } if (empty($event)) { return false; } $date = trim($event->EndDate) . ' ' . trim($event->FinishTime); if (empty($date) || $date == " ") { return false; } return eo_format_date($date, $format); } $occurrence_id = (int) (empty($occurrence_id) && isset($event->occurrence_id) ? $event->occurrence_id : $occurrence_id); $occurrences = eo_get_the_occurrences_of($post_id); if (!$occurrences || !isset($occurrences[$occurrence_id])) { return false; } $end = $occurrences[$occurrence_id]['end']; return apply_filters('eventorganiser_get_the_end', eo_format_datetime($end, $format), $end, $format, $post_id, $occurrence_id); }