PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9
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 / class-jwt-auth.php

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

84 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * REST API: LP_Jwt_Auth
4 *
5 * @package LPJWTAuth
6 * @since 1.0.0
7 * @author Nhamdv <daonham95@gmail.com>
8 */
9
10 class LP_Jwt_Auth {
11 public static $_instance = null;
12
13 protected $name;
14
15 protected $version;
16
17 public function __construct() {
18 $this->name = 'learnpress';
19 $this->version = 'v1';
20
21 // Is enable rest api?
22 // if ( LP_Settings::instance()->get( 'enable_jwt_rest_api' ) !== 'yes' ) {
23 // return;
24 // }
25
26 $this->includes();
27 $this->define_hooks();
28 }
29
30 private function includes() {
31 // JWT Classes.
32 if ( ! class_exists( '\LP\Firebase\JWT\JWT' ) ) {
33 foreach ( glob( LP_PLUGIN_PATH . 'inc/jwt/includes/php-jwt/*.php' ) as $filename ) {
34 require_once $filename;
35 }
36 }
37
38 // Authentic.
39 require_once LP_PLUGIN_PATH . 'inc/jwt/includes/class-jwt-public.php';
40
41 // Include Rest API.
42 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-controller.php';
43 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-posts-controller.php';
44 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php';
45 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php';
46 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php';
47 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-questions-v1-controller.php';
48 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php';
49 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-course-category-v1-controller.php';
50 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-sections-v1-controller.php';
51 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-section-items-v1-controller.php';
52
53 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/lp-rest-function.php';
54 require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/class-rest-api.php';
55 }
56
57 private function define_hooks() {
58 // Authentic.
59 $public = new LP_Jwt_Public( $this->name, $this->version );
60
61 add_action( 'rest_api_init', array( $public, 'register_routes' ) );
62 add_filter( 'rest_api_init', array( $public, 'add_cors_support' ) );
63 add_filter( 'rest_pre_dispatch', array( $public, 'rest_pre_dispatch' ), 10, 2 );
64 add_filter( 'determine_current_user', array( $public, 'determine_current_user' ), 30 );
65
66 // Rest API
67 add_action( 'init', array( $this, 'load_rest_api' ) );
68 }
69
70 public function load_rest_api() {
71 LP_Jwt_RestApi::instance()->init();
72 }
73
74 public static function instance() {
75 if ( is_null( self::$_instance ) ) {
76 self::$_instance = new LP_Jwt_Auth();
77 }
78
79 return self::$_instance;
80 }
81 }
82
83 LP_Jwt_Auth::instance();
84