| @@ -73,17 +73,16 @@ | ||
| 73 | 73 | * @param string $message The plaintext message displayed to the user |
| 74 | 74 | * that explains the status. |
| 75 | 75 | * @param array $data An array of data to sent as the response. |
| 76 | 76 | * |
| 77 | - * @return void | |
| 77 | + * @return \WP_REST_Response | |
| 78 | 78 | */ |
| 79 | - public function return_api_response( int $status_code, string $message, $data = array() ): void { | |
| 80 | - status_header( $status_code ); | |
| 81 | - print wp_json_encode( | |
| 79 | + public function return_api_response( int $status_code, string $message, $data = array() ): \WP_REST_Response { | |
| 80 | + return new \WP_REST_Response( | |
| 82 | 81 | array( |
| 83 | - 'code' => $status_code, | |
| 82 | + 'data' => $data, | |
| 84 | 83 | 'message' => $message, |
| 85 | - 'data' => $data, | |
| 86 | - ) | |
| 84 | + ), | |
| 85 | + $status_code | |
| 87 | 86 | ); |
| 88 | 87 | } |
| 89 | 88 | } |