| 1 |
<?php |
| 2 |
/** |
| 3 |
* Our API calls responsible for handling requests from website visitors. |
| 4 |
* |
| 5 |
* @package ForceRefresh |
| 6 |
* @subpackage ApiCalls |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Function to reply to the client with a response. |
| 11 |
* |
| 12 |
* @param int $status_code The standardized HTTP status code. |
| 13 |
* @param string $message The plaintext message displayed to the user |
| 14 |
* that explains the status. |
| 15 |
* @param array $data An array of data to sent as the response. |
| 16 |
* |
| 17 |
* @return void |
| 18 |
*/ |
| 19 |
function return_api_response( int $status_code, string $message, $data = array() ) { |
| 20 |
status_header( $status_code ); |
| 21 |
print wp_json_encode( |
| 22 |
array( |
| 23 |
'status_code' => $status_code, |
| 24 |
'status_text' => $message, |
| 25 |
'success' => 200 === $status_code, |
| 26 |
'data' => $data, |
| 27 |
) |
| 28 |
); |
| 29 |
wp_die(); |
| 30 |
} |
| 31 |
|
| 32 |
// All ajax calls from admins. |
| 33 |
require_once __DIR__ . '/admin/admin.php'; |
| 34 |
// All ajax calls from clients. |
| 35 |
require_once __DIR__ . '/client/client.php'; |
| 36 |
|