Example #1
0
 /**
  * 
  * get event post data in array. 
  * if the post is not event, return empty array
  */
 public static function getEventPostData($postID)
 {
     if (self::isEventsExists() == false) {
         return array();
     }
     $postType = get_post_type($postID);
     if ($postType != EM_POST_TYPE_EVENT) {
         return array();
     }
     $event = new EM_Event($postID, 'post_id');
     $location = $event->get_location();
     $arrEvent = $event->to_array();
     $arrLocation = $location->to_array();
     $date_format = get_option('date_format');
     $time_format = get_option('time_format');
     $arrEvent["event_start_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_start_date"]), $date_format);
     $arrEvent["event_end_date"] = date_format(date_create_from_format('Y-m-d', $arrEvent["event_end_date"]), $date_format);
     $arrEvent["event_start_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_start_time"]), $time_format);
     $arrEvent["event_end_time"] = date_format(date_create_from_format('H:i:s', $arrEvent["event_end_time"]), $time_format);
     $response = array();
     $response["start_date"] = $arrEvent["event_start_date"];
     $response["end_date"] = $arrEvent["event_end_date"];
     $response["start_time"] = $arrEvent["event_start_time"];
     $response["end_time"] = $arrEvent["event_end_time"];
     $response["id"] = $arrEvent["event_id"];
     $response["location_name"] = $arrLocation["location_name"];
     $response["location_address"] = $arrLocation["location_address"];
     $response["location_slug"] = $arrLocation["location_slug"];
     $response["location_town"] = $arrLocation["location_town"];
     $response["location_state"] = $arrLocation["location_state"];
     $response["location_postcode"] = $arrLocation["location_postcode"];
     $response["location_region"] = $arrLocation["location_region"];
     $response["location_country"] = $arrLocation["location_country"];
     $response["location_latitude"] = $arrLocation["location_latitude"];
     $response["location_longitude"] = $arrLocation["location_longitude"];
     return $response;
 }