Sindbad~EG File Manager
<?php
// - standalone json feed -
header('Content-Type:application/json');
// - grab wp load, wherever it's hiding -
if(!defined("ABSPATH")){
$pagePath = explode('/wp-content/', dirname(__FILE__));
include_once(str_replace('wp-content/' , '', $pagePath[0] . '/wp-load.php'));
}
// - grab date barrier -
$options = get_option('imic_options');
$today = adorechurch_date_localization('Y-m-d');
$start_date = (isset($_POST['start']))?$_POST['start']:adorechurch_date_localization('Y-m-d');
$current_month = adorechurch_date_localization('Y-m-d', strtotime($start_date. ' + 10 days'));
$events = imic_recur_events('', '', '', $current_month);
if (isset($_POST['event_cat_id'])&&!empty($_POST['event_cat_id'])){
$term_slug = get_term_by('id', $_POST['event_cat_id'], 'event-category');
$event_future = imic_recur_events('future', 'nos', $term_slug->slug);
$event_past = imic_recur_events('past', 'nos', $term_slug->slug);
}
else{
$event_future = imic_recur_events('future');
$event_past = imic_recur_events('past');
}
$events = $event_future+$event_past;
$jsonevents = array();
// - loop -
if ($events) {
global $post;
foreach ($events as $key=>$value) {
//setup_postdata($post);
$cat_id = $event_color = '';
$frequency = get_post_meta($value,'imic_event_frequency_type',true);
$cat_id = wp_get_post_terms( $value, 'event-category', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all') );
if(!is_wp_error($cat_id) && !empty($cat_id)) {
$cat_id = $cat_id[0]->term_id;
$cat_data = get_option("category_".$cat_id);
$event_cat_color = $cat_data['catBG'];
$event_color = ($cat_data['catBG']!='')?$cat_data['catBG']:$options['event_default_color'];
}
$frequency_count = '';
$frequency_count = get_post_meta($value,'imic_event_frequency_count',true);
if($frequency>0&&$options['recurring_event_color']!='') {
$color = $options['recurring_event_color'];
$color = ($event_cat_color != '')?$event_cat_color:$options['recurring_event_color'];
$frequency_count = $frequency_count;
} else {
$frequency_count = 0;
$color = $event_color;
}
// - custom post type variables -
$start = get_post_meta($value,'imic_event_start_dt',true);
$start_new = adorechurch_date_localization('Y-m-d', $key);
$start_new_time = adorechurch_date_localization('H:i', strtotime($start));
$end = get_post_meta($value,'imic_event_end_dt',true);
// - set to ISO 8601 date format -
$stime = esc_attr(adorechurch_date_localization('Y-m-d H:i:s', strtotime($start_new.' '.$start_new_time)));
$etime = esc_attr(adorechurch_date_localization('Y-m-d H:i:s', strtotime($end)));
$date_converted = adorechurch_date_localization('Y-m-d',$key);
// - json items -
$jsonevents[]= array(
'id' => $value.'|'.$key,
'title' => esc_attr(get_the_title($value)),
'allDay' => false, // <- true by default with FullCalendar
'start' => $stime,
'end' => $etime,
'url' => esc_url(imic_query_arg($date_converted, $value)),
'backgroundColor' => $color,
'borderColor' => $color
);
}
}
// - fire away -
$events_feeds = $options['event_feeds'];
if($events_feeds==1) {
echo json_encode($jsonevents); }
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists