/** * Insert a rendered h-Event list from a VCal feed * @param array $atts * @param string $content * @return string */ public static function shortcode($atts, $content = "") { $atts = shortcode_atts(array('url' => '', 'paginated' => '10'), $atts); $body = $content; $vcal = new ICal(); // Request VCalendar and cache the response for 7 days $vcal->setCache(dirname(__FILE__) . '/cache', 7 * 24 * 3600)->initURL($atts['url']); if ($vcal->hasEvents()) { ob_start(); ?> <div class="icalfeed"> <ul> <?php foreach ($vcal->events() as $event) { $event['DTSTART'] = new \DateTime($event['DTSTART']); $event['DTEND'] = new \DateTime($event['DTEND']); // Render an event ?> <li class="hevent"> <p><strong class="p-name"><?php echo $event['SUMMARY']; ?> </strong><br/> Du <time class="dt-start" datetime="<?php echo $event['DTSTART']->format(\DateTime::ISO8601); ?> "><?php echo $event['DTSTART']->format('d/m'); ?> </time> au <time class="dt-end" datetime="<?php echo $event['DTEND']->format(\DateTime::ISO8601); ?> "><?php echo $event['DTEND']->format('d/m'); ?> </time><br/> <!--span class="p-location">Some bar in SF</span--> <?php if (strpos('://', $event['DESCRIPTION'])) { ?> <span class="p-summary"><?php echo preg_replace('#.*(https?://.+)$#is', '<a href="$1" target="icalfeedNewWindow">Voir le site</a>', $event['DESCRIPTION']); ?> </span> <?php } ?> </p> </li> <?php } ?> </ul> </div> <?php $body = ob_get_contents(); ob_clean(); } else { $body = '<p>Aucun événement...</p>'; } return $body; }