Move content of returning response into CRM_Utils_System and have user_system based...
[civicrm-core.git] / CRM / Utils / System / WordPress.php
index 2a13781180151fa8087197c355d2e2dfc8208d0f..84cba04f8847189ca92858346c53ea17eed006dc 100644 (file)
@@ -863,4 +863,19 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     ];
   }
 
+  /**
+   * Set the HTTP Status Code for a request
+   * @param string $statusCode
+   */
+  public function setStatusCode($statusCode) {
+    status_header($statusCode);
+    if (function_exists('http_response_code')) {
+      // PHP 5.4+
+      http_response_code($statusCode);
+    }
+    else {
+      header('X-PHP-Response-Code: ' . $statusCode, TRUE, $statusCode);
+    }
+  }
+
 }