| @@ -2,34 +2,20 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Our API calls responsible for handling requests from website visitors. |
| 4 | 4 | * |
| 5 | 5 | * @package ForceRefresh |
| 6 | - * @subpackage ApiCalls | |
| 7 | 6 | */ |
| 8 | 7 | |
| 8 | +namespace JordanLeven\Plugins\ForceRefresh\Api; | |
| 9 | + | |
| 9 | 10 | /** |
| 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 | -} | |
| 11 | +* Custom intervals must be at least 30 seconds. | |
| 12 | +*/ | |
| 13 | +define( 'REFRESH_INTERVAL_CUSTOM_MINIMUM_IN_SECONDS', 30 ); | |
| 31 | 14 | |
| 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'; | |
| 15 | +/** | |
| 16 | +* Custom intervals must be, at max, four hours. | |
| 17 | +*/ | |
| 18 | +define( 'REFRESH_INTERVAL_CUSTOM_MAXIMUM_IN_SECONDS', 4 * 3600 ); | |
| 19 | + | |
| 20 | +// Our admin API handlers. | |
| 21 | +require_once __DIR__ . '/register-endpoints.php'; | |