PluginProbe
Force Refresh / 2.8.2
Force Refresh v2.8.2
3.2.1 3.2.0 3.1.2 3.1.1 3.1.0 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.12.0 All 54 releases
force-refresh / includes / api / api.php

api.php in Force Refresh 2.8.2, at includes/api/api.php

46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Custom intervals must be at least 30 seconds.
11 */
12 define( 'REFRESH_INTERVAL_CUSTOM_MINIMUM_IN_SECONDS', 30 );
13
14 /**
15 * Custom intervals must be, at max, four hours.
16 */
17 define( 'REFRESH_INTERVAL_CUSTOM_MAXIMUM_IN_SECONDS', 4 * 3600 );
18
19 /**
20 * Function to reply to the client with a response.
21 *
22 * @param int $status_code The standardized HTTP status code.
23 * @param string $message The plaintext message displayed to the user
24 * that explains the status.
25 * @param array $data An array of data to sent as the response.
26 *
27 * @return void
28 */
29 function return_api_response( int $status_code, string $message, $data = array() ) {
30 status_header( $status_code );
31 print wp_json_encode(
32 array(
33 'status_code' => $status_code,
34 'status_text' => $message,
35 'success' => 200 === $status_code,
36 'data' => $data,
37 )
38 );
39 wp_die();
40 }
41
42 // All ajax calls from admins.
43 require_once __DIR__ . '/admin/admin.php';
44 // All ajax calls from clients.
45 require_once __DIR__ . '/client/client.php';
46