PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.2.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.2.1
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / inc / jwt / rest-api / class-rest-api.php

class-rest-api.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.2.1, at inc/jwt/rest-api/class-rest-api.php

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Initialize this version of the REST API.
4 *
5 * @author Nhamdv <daonham95@gmail.com>
6 * @package LP/JWT/RestApi
7 */
8 class LP_Jwt_RestApi {
9
10 protected static $instance = null;
11
12 protected $controllers = array();
13
14 public function init() {
15 add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
16 }
17
18 public function register_rest_routes() {
19 foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) {
20 foreach ( $controllers as $controller_name => $controller_class ) {
21 $this->controllers[ $namespace ][ $controller_name ] = new $controller_class();
22 $this->controllers[ $namespace ][ $controller_name ]->register_routes();
23 }
24 }
25 }
26
27 protected function get_rest_namespaces() {
28 return apply_filters(
29 'lp_rest_api_get_rest_namespaces',
30 array(
31 'learnpress/v1' => $this->get_v1_controllers(),
32 )
33 );
34 }
35
36 protected function get_v1_controllers() {
37 return array(
38 'courses' => 'LP_Jwt_Courses_V1_Controller',
39 'lessons' => 'LP_Jwt_Lessons_V1_Controller',
40 'quiz' => 'LP_Jwt_Quiz_V1_Controller',
41 'questions' => 'LP_Jwt_Questions_V1_Controller',
42 'users' => 'LP_Jwt_Users_V1_Controller',
43 'course_category' => 'LP_Jwt_Course_Category_V1_Controller',
44 'sections' => 'LP_Jwt_Sections_V1_Controller',
45 'section-items' => 'LP_Jwt_Section_Items_V1_Controller',
46 );
47 }
48
49 public static function get_path() {
50 return dirname( __DIR__ );
51 }
52
53 final public static function instance() {
54 if ( null === static::$instance ) {
55 static::$instance = new static();
56 }
57 return static::$instance;
58 }
59 }
60