-
-
Save Pebblo/23c231f46ffb84813b5a8511eff7f8b1 to your computer and use it in GitHub Desktop.
Example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if you already have one | |
function ee_events_shortcode( $atts ) { | |
//Pull the sites date and time formats. | |
$date_format = get_option( 'date_format' ); | |
$time_format = get_option( 'time_format' ); | |
//Pull upcoming events | |
$events = EEM_Event::instance()->get_upcoming_events(array( | |
'limit' => 1, | |
'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') | |
)); | |
// content-header | |
echo "BEGIN:VCALENDAR" . "<br>"; | |
echo "VERSION:2.0" . "<br>"; | |
echo "PRODID:-//" . the_title() . "//NONSGML Events //EN" . "<br>"; | |
echo "X-WR-CALNAME:" . the_title() . _e(' - Events','themeforce') . "<br>"; | |
echo "X-ORIGINAL-URL:" . the_permalink() . "<br>"; | |
echo "X-WR-CALDESC:" , the_title() . _e(' - Events','themeforce') . "<br>"; | |
echo "CALSCALE:GREGORIAN" . "<br>"; | |
foreach( $events as $event ) { | |
echo "BEGIN:VEVENT" . "<br>"; | |
// Pull the next upcoming datetime for this event. | |
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $event->ID(), $show_expired = false, $show_archived = false, $limit = null ); | |
// Reset the datetimes pointer to the earliest datetime and use that one. | |
$datetime = reset( $datetimes ); | |
if ($datetime instanceof EE_Datetime) { | |
echo 'ID:' . $event->ID() . '<br>'; | |
echo 'Title:' . $event->name() . '<br>'; | |
echo 'Start Date:' . date_i18n( $date_format, strtotime( $datetime->start_date('Y-m-d') ) ) . '<br>'; | |
echo 'End Date:' . date_i18n( $date_format, strtotime( $datetime->start_date('Y-m-d') ) ) . '<br>'; | |
// Loop over each datetime we have pulled from the database and output | |
foreach ($datetimes as $datetime) { | |
echo 'Datetime ID:' . $datetime->ID() . '<br>'; | |
echo 'Date:' . date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) ) . '<br>'; | |
echo 'Date:' . date_i18n( $date_format, strtotime( $datetime->start_date('Y-m-d') ) ) . '<br>'; | |
echo 'Start Date:' . date_i18n( $time_format, strtotime( $datetime->start_time('H:i:s') ) ) . '<br>'; | |
echo 'End Date:' . date_i18n( $time_format, strtotime( $datetime->end_time('H:i:s') ) ) . '<br>'; | |
//end foreach $datetimes | |
}; | |
}; | |
//$geteventdate = $event->first_datetime(); | |
//$eventdate = date('Y-m-d H:i:s', strtotime($geteventdate->start_date())); | |
//echo "DTSTART:" . $eventdate . "<br>"; | |
//echo "DTSTART:"; | |
//do_shortcode( '[TIME_START]' ); | |
//echo "<br>"; | |
//do_shortcode( '[ESPRESSO_EVENTS_TABLE_TEMPLATE show_all_datetimes=TRUE]' ); | |
//echo "<br>"; | |
//echo "DTEND:" . "" . "<br>"; | |
//echo "DTEND:" . $event->get('DTT_EVT_end'). "<br>"; | |
echo "SUMMARY:" . $event->name() . "<br>"; | |
echo "DESCRIPTION:" . $event->name() . "<br>"; | |
//echo "DESCRIPTION:" . $event->description() . "<br>"; | |
echo "END:VEVENT" . "<br>"; | |
$startdate = ""; | |
} | |
echo "END:VCALENDAR" . "<br>"; | |
} | |
add_shortcode( 'ee_events_shortcode_output', 'ee_events_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment