Skip to content

Commit

Permalink
added RestApi.php
Browse files Browse the repository at this point in the history
  • Loading branch information
geckod22 committed Nov 18, 2024
1 parent c9c5775 commit 2202638
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions includes/RestApi/RestApi.php
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();
}
}
}

0 comments on commit 2202638

Please sign in to comment.