| 1 |
<?php |
| 2 |
namespace PixelavoOpt; |
| 3 |
|
| 4 |
use WP_REST_Controller; |
| 5 |
|
| 6 |
/** |
| 7 |
* REST_API Handler |
| 8 |
*/ |
| 9 |
class Api extends WP_REST_Controller { |
| 10 |
|
| 11 |
/** |
| 12 |
* [__construct description] |
| 13 |
*/ |
| 14 |
public function __construct() { |
| 15 |
$this->includes(); |
| 16 |
add_action('rest_api_init', [$this, 'register_routes']); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Include the controller classes |
| 21 |
* |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
private function includes() { |
| 25 |
if (!class_exists(__NAMESPACE__ . '\Api\Settings')) { |
| 26 |
require_once __DIR__ . '/Api/Settings.php'; |
| 27 |
} |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Register the API routes |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
public function register_routes() { |
| 37 |
(new Api\Settings())->register_routes(); |
| 38 |
} |
| 39 |
|
| 40 |
} |