| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of RestApi |
| 5 |
* |
| 6 |
* @author Ali2Woo Team |
| 7 |
* |
| 8 |
* @autoload: a2wl_init |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace AliNext_Lite;; |
| 12 |
|
| 13 |
class RestApi { |
| 14 |
public function __construct() { |
| 15 |
add_action('rest_api_init', array($this, 'register_routes')); |
| 16 |
} |
| 17 |
|
| 18 |
public function register_routes() { |
| 19 |
register_rest_route('a2wl-api/v1', '/info', array( |
| 20 |
'methods' => \WP_REST_Server::READABLE, |
| 21 |
'callback' => array($this, 'info'), |
| 22 |
'permission_callback' => '__return_true' |
| 23 |
)); |
| 24 |
} |
| 25 |
|
| 26 |
public function info($request) { |
| 27 |
$result = array(); |
| 28 |
|
| 29 |
$result['server_ping'] = SystemInfo::server_ping(); |
| 30 |
$result['plugin_version'] = A2WL()->version; |
| 31 |
|
| 32 |
return rest_ensure_response($result); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
|