| Server IP : 104.21.28.229 / Your IP : 216.73.216.142 Web Server : Apache/2 System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : mienphi ( 1014) PHP Version : 8.2.14 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/mienphi/public_html/wp-content/plugins/learnpress/inc/jwt/rest-api/ |
Upload File : |
<?php
/**
* Initialize this version of the REST API.
*
* @author Nhamdv <[email protected]>
* @package LP/JWT/RestApi
*/
class LP_Jwt_RestApi {
protected static $instance = null;
protected $controllers = array();
public function init() {
add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
}
public function register_rest_routes() {
foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) {
foreach ( $controllers as $controller_name => $controller_class ) {
$this->controllers[ $namespace ][ $controller_name ] = new $controller_class();
$this->controllers[ $namespace ][ $controller_name ]->register_routes();
}
}
}
protected function get_rest_namespaces() {
return apply_filters(
'lp_rest_api_get_rest_namespaces',
array(
'learnpress/v1' => $this->get_v1_controllers(),
)
);
}
protected function get_v1_controllers() {
return array(
'courses' => 'LP_Jwt_Courses_V1_Controller',
'lessons' => 'LP_Jwt_Lessons_V1_Controller',
'quiz' => 'LP_Jwt_Quiz_V1_Controller',
'questions' => 'LP_Jwt_Questions_V1_Controller',
'users' => 'LP_Jwt_Users_V1_Controller',
'course_category' => 'LP_Jwt_Course_Category_V1_Controller',
'sections' => 'LP_Jwt_Sections_V1_Controller',
'section-items' => 'LP_Jwt_Section_Items_V1_Controller',
);
}
public static function get_path() {
return dirname( __DIR__ );
}
final public static function instance() {
if ( null === static::$instance ) {
static::$instance = new static();
}
return static::$instance;
}
}