/**
  * Output the status of an ongoing import together with any messages
  * generated during import.
  *
  * Triggered by an AJAX call.
  *
  * Runs on staging environment.
  */
 public function import_status_request()
 {
     $batch_id = intval($_POST['batch_id']);
     $response = $this->api->import_status_request($batch_id);
     // Deploy status.
     $status = isset($response['status']) ? $response['status'] : 2;
     // Get status from content stage.
     $stage_status = $this->api->get_deploy_status($batch_id);
     // Use stage status if stage verification has failed.
     if ($stage_status == 2) {
         $status = $stage_status;
     }
     // Get content stage messages.
     $stage_messages = $this->api->get_deploy_messages($batch_id);
     // All pre-flight messages.
     $messages = array_merge($response['messages'], $stage_messages);
     // Deploy has finished.
     if ($status == 3) {
         do_action('sme_deployed');
     }
     // Convert message objects into arrays.
     $messages = $this->api->convert_messages($messages);
     header('Content-Type: application/json');
     echo json_encode(array('status' => $status, 'messages' => $messages));
     die;
     // Required to return a proper result.
 }