/**
  * Publish the location if the event has just been approved and the location is pending. We assume an editor published the event and approves the location too.
  * @param EM_Event $EM_Event
  */
 public static function maybe_publish_location($EM_Event)
 {
     //do a dirty update for location too if it's not published
     if ($EM_Event->is_published() && !empty($EM_Event->location_id)) {
         $EM_Location = $EM_Event->get_location();
         if ($EM_Location->location_status !== 1) {
             //let's also publish the location
             $EM_Location->set_status(1, true);
         }
     }
 }
 /**
  * 
  * 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;
 }