/** * Get a link to add a gig to Google Calendar. * * @since 1.0.0 * * @todo Need to add the artists' name to provide context in Google Calendar. * * @param int|object $post Optional post ID or object. Default is global $post object. * @return string */ function get_audiotheme_gig_gcal_link($post = null) { $gig = get_audiotheme_gig($post); $date = get_audiotheme_gig_time('Ymd', '', true); $time = get_audiotheme_gig_time('', 'His', true); $dtstart = $date; $dtstart .= empty($time) ? '' : 'T' . $time . 'Z'; $location = ''; if (audiotheme_gig_has_venue($gig)) { $venue = get_audiotheme_venue($gig->venue->ID); $location = $venue->name; $location .= empty($venue->address) ? '' : ', ' . esc_html($venue->address); $location .= empty($venue->city) ? '' : ', ' . $venue->city; $location .= !empty($location) && !empty($venue->state) ? ', ' : ''; $location .= empty($venue->state) ? '' : $venue->state; if (!empty($venue->country)) { $location .= !empty($location) ? ', ' : ''; $location .= empty($venue->country) ? '' : $venue->country; } } $args = array('action' => 'TEMPLATE', 'text' => rawurlencode(wp_strip_all_tags(get_audiotheme_gig_title())), 'dates' => $dtstart . '/' . $dtstart, 'details' => rawurlencode(wp_strip_all_tags(get_audiotheme_gig_description())), 'location' => rawurlencode($location), 'sprop' => rawurlencode(home_url('/'))); $link = add_query_arg($args, 'https://www.google.com/calendar/event'); return $link; }
header('Content-type: text/calendar'); header('Content-Disposition: attachment; filename="audiotheme-gigs.ics"'); ?> BEGIN:VCALENDAR VERSION:2.0 PRODID:-//AudioTheme <?php echo AUDIOTHEME_VERSION; ?> <?php foreach ($wp_query->posts as $post) { $post = get_audiotheme_gig($post); echo "BEGIN:VEVENT\n"; echo 'UID:' . get_the_guid($post->ID) . "\n"; echo 'URL:' . get_permalink($post->ID) . "\n"; $date = get_audiotheme_gig_time('Ymd', '', true); $time = get_audiotheme_gig_time('', 'His', true); $dtstart = sprintf("DTSTART%s%s%s\n", empty($time) ? ';VALUE=DATE:' : ';TZID=GMT:', $date, empty($time) ? '' : 'T' . $time); echo $dtstart; echo 'SUMMARY:' . get_audiotheme_gig_title() . "\n"; if (!empty($post->post_excerpt)) { echo 'DESCRIPTION:' . escape_ical_text($post->post_excerpt) . "\n"; } if (!empty($post->venue)) { $location = get_audiotheme_venue_location_ical($post->venue->ID); echo empty($location) ? '' : 'LOCATION:' . $location . "\n"; } echo "END:VEVENT\n"; } ?> END:VCALENDAR
" rel="self" type="application/rss+xml" /> <link><?php bloginfo_rss('url'); ?> </link> <description><?php bloginfo_rss('description'); ?> </description> <?php while (have_posts()) { the_post(); ?> <item> <title><?php echo get_audiotheme_gig_title(); ?> </title> <link><?php the_permalink_rss(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <guid isPermaLink="false"><?php the_guid(); ?> </guid>