Calendar Feed Requirements:
The Booked calendar feeds now require a secure hash to access. Please take a look at your "Appointments > Calendar Feeds" page for the updated feed URLs.');
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=appointment-feed-'.BOOKED_VERSION.'.ics');
if (isset($_GET['calendar']) && $_GET['calendar']):
$calendar_id = $_GET['calendar'];
else:
$calendar_id = false;
endif;
// 1 year ago to 5 years later.
$from_timestamp = strtotime(date('Y-m-01', strtotime("-1 year")));
$to_timestamp = strtotime(date('Y-m-d', strtotime("+5 years")));
$args = array(
'post_type' => 'booked_appointments',
'posts_per_page' => -1,
'post_status' => array('publish', 'future'),
'meta_query' => array(
array(
'key' => '_appointment_timestamp',
'value' => array( $from_timestamp, $to_timestamp ),
'compare' => 'BETWEEN',
)
)
);
if ($calendar_id):
$args['tax_query'] = array(
array(
'taxonomy' => 'booked_custom_calendars',
'field' => 'id',
'terms' => $calendar_id,
)
);
endif;
if ($calendar_id):
$calendar_name = get_term_by('id',$calendar_id,'booked_custom_calendars');
$calendar_name = $calendar_name->name;
else :
$calendar_name = 'Appointments';
endif;
$appts_in_this_timeslot = array();
$bookedAppointments = new WP_Query($args);
if($bookedAppointments->have_posts()):
while ($bookedAppointments->have_posts()):
$bookedAppointments->the_post();
global $post;
$timestamp = get_post_meta($post->ID, '_appointment_timestamp',true);
$timeslot = get_post_meta($post->ID, '_appointment_timeslot',true);
$user_id = get_post_meta($post->ID, '_appointment_user',true);
$day = date('d',$timestamp);
$appointments_array[$post->ID]['post_id'] = $post->ID;
$appointments_array[$post->ID]['timestamp'] = $timestamp;
$appointments_array[$post->ID]['timeslot'] = $timeslot;
$appointments_array[$post->ID]['status'] = $post->post_status;
$appointments_array[$post->ID]['user'] = $user_id;
$appts_in_this_timeslot[] = $post->ID;
endwhile;
endif;
?>BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//getbooked.io//Booked Calendar
CALSCALE:GREGORIAN
user_email;
else:
$display_name = esc_html__('[No name]','booked-calendar-feeds');
$email = esc_html__('[No email]','booked-calendar-feeds');
endif;
else:
$display_name = esc_html__('[No name]','booked-calendar-feeds');
$email = esc_html__('[No email]','booked-calendar-feeds');
endif;
else:
$display_name = $guest_name;
$email = $guest_email;
endif;
$display_name = clean_calendarString($display_name);
$email = clean_calendarString($email);
// Appointment Information
if ( isset($appt_id) ):
$time_format = get_option('time_format');
$date_format = get_option('date_format');
$appt_id = $appt_id;
$timestamp = get_post_meta($appt_id, '_appointment_timestamp',true);
$timeslot = get_post_meta($appt_id, '_appointment_timeslot',true);
$cf_meta_value = get_post_meta($appt_id, '_cf_meta_value',true);
$timeslots = explode('-',$timeslot);
if ($timeslots[0] == '0000' && $timeslots[1] == '2400'):
$formatted_start_date = dateToCal(get_post_meta($appt_id, '_appointment_timestamp',true),true);
$formatted_end_date = false;
else :
$end_date = date('Y-m-d',strtotime(get_gmt_from_date(date('Y-m-d H:i:s',get_post_meta($appt_id, '_appointment_timestamp',true)))));
$end_date_time = $end_date . date('H:i:s',strtotime(get_gmt_from_date(date('Y-m-d H:i:s',strtotime($end_date.' '.$timeslots[1])))));
$formatted_start_date = dateToCal(get_post_meta($appt_id, '_appointment_timestamp',true));
$formatted_end_date = date('Ymd\THis',strtotime($end_date_time));
endif;
$cf_fields = array(); $cf_counter = 0;
preg_match_all('/