-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
namespace NewfoldLabs\WP\Module\Performance\RestApi; | ||
|
||
final class RestApi { | ||
|
||
/** | ||
* List of custom REST API controllers | ||
* | ||
* @var array | ||
*/ | ||
protected $controllers = array( | ||
'NewfoldLabs\\WP\\Module\\Performance\\RestApi\\LinkPrefetchController', | ||
); | ||
|
||
/** | ||
* Setup the custom REST API | ||
*/ | ||
public function __construct() { | ||
add_action( 'rest_api_init', array( $this, 'register_routes' ) ); | ||
} | ||
|
||
/** | ||
* Register API routes. | ||
*/ | ||
public function register_routes() { | ||
foreach ( $this->controllers as $Controller ) { | ||
/** | ||
* Get an instance of the WP_REST_Controller. | ||
* | ||
* @var $instance \WP_REST_Controller | ||
*/ | ||
$instance = new $Controller(); | ||
$instance->register_routes(); | ||
} | ||
} | ||
} |