Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This is a short helper class that can be used to "concatenate"
- * events so that the dates of future recurring instances are listed
- * beside the main event.
- */
- class EventListOrganiser {
- protected static $alreadyLooped = array();
- protected static $query;
- public static function hasDisplayedAlready() {
- $displayed = in_array(get_the_ID(), self::$alreadyLooped);
- self::$alreadyLooped[] = get_the_ID();
- return $displayed;
- }
- public static function listFutureRecurringEventDates() {
- self::findRecurringPosts(get_the_ID(), array(__CLASS__, 'printDates'));
- }
- protected function findRecurringPosts($id, $callback) {
- self::$query = new WP_Query($GLOBALS['wp_query']->query_vars);
- $idList = array();
- while (self::$query->have_posts()) {
- self::$query->the_post();
- if (self::$query->post->ID === $id) {
- if (in_array($id, $idList))
- call_user_func($callback);
- $idList[] = $id;
- }
- }
- }
- protected function printDates() {
- echo '<li>'.tribe_get_start_date().'</li>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment