Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
RestApi | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
register_routes | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | namespace NewfoldLabs\WP\Module\Performance\RestApi; |
3 | |
4 | /** |
5 | * Instantiate controllers and register routes. |
6 | */ |
7 | final class RestApi { |
8 | |
9 | /** |
10 | * List of custom REST API controllers |
11 | * |
12 | * @var array |
13 | */ |
14 | protected $controllers = array( |
15 | 'NewfoldLabs\\WP\\Module\\Performance\\RestApi\\Skip404Controller', |
16 | 'NewfoldLabs\\WP\\Module\\Performance\\RestApi\\LinkPrefetchController', |
17 | 'NewfoldLabs\\WP\\Module\\Performance\\RestApi\\JetpackController', |
18 | 'NewfoldLabs\\WP\\Module\\Performance\\RestApi\\CacheController', |
19 | ); |
20 | |
21 | /** |
22 | * Setup the custom REST API |
23 | */ |
24 | public function __construct() { |
25 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
26 | } |
27 | |
28 | /** |
29 | * Register the custom REST API routes |
30 | */ |
31 | public function register_routes() { |
32 | foreach ( $this->controllers as $controller ) { |
33 | /** |
34 | * Get an instance of the WP_REST_Controller. |
35 | * |
36 | * @var $instance WP_REST_Controller |
37 | */ |
38 | $instance = new $controller(); |
39 | $instance->register_routes(); |
40 | } |
41 | } |
42 | } |