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.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / RestAPI.php
tutor / classes Last commit date
Addons.php 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Announcements.php 4 years ago Assets.php 4 years ago Backend_Page_Trait.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_List.php 4 years ago Course_Settings_Tabs.php 4 years ago Course_Widget.php 4 years ago Custom_Validation.php 4 years ago Dashboard.php 4 years ago FormHandler.php 4 years ago Frontend.php 4 years ago Gutenberg.php 4 years ago Input.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options_V2.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 4 years ago Q_and_A.php 4 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 4 years ago Reviews.php 4 years ago Rewrite_Rules.php 4 years ago Shortcode.php 4 years ago Student.php 4 years ago Students_List.php 4 years ago Taxonomies.php 4 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 4 years ago Tools_V2.php 4 years ago Tutor.php 4 years ago TutorEDD.php 4 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 4 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 4 years ago Withdraw.php 4 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
RestAPI.php
313 lines
1 <?php
2 /**
3 * RestAPI class
4 *
5 * @author: themeum
6 * @author_uri: https://themeum.com
7 * @package Tutor
8 * @since v.1.5.0
9 */
10
11 namespace TUTOR;
12
13 if (!defined('ABSPATH'))
14 exit;
15
16 class RestAPI {
17
18 use Custom_Validation;
19
20 private $namespace = 'tutor/v1';
21
22 protected $course_post_type;
23
24 private $path;
25
26 private $courseObj;
27
28 private $topicObj;
29
30 private $lessonObj;
31
32 private $annoucementObj;
33
34 private $quizObj;
35
36 private $authorObj;
37
38 private $ratingObj;
39
40 public function __construct() {
41
42 $this->path = plugin_dir_path(TUTOR_FILE);
43
44 spl_autoload_register(array($this, 'loader'));
45
46
47 $this->courseObj = new REST_Course;
48 $this->topicObj = new REST_Topic;
49 $this->lessonObj = new REST_Lesson;
50 $this->annoucementObj = new REST_Course_Announcement;
51 $this->quizObj = new REST_Quiz;
52 $this->authorObj = new REST_Author;
53 $this->ratingObj = new REST_Rating;
54
55 add_action('rest_api_init', array($this, 'init_routes'));
56 }
57
58
59 private function loader($className) {
60 if (!class_exists($className)) {
61 $className = preg_replace(
62 array('/([a-z])([A-Z])/', '/\\\/'),
63 array('$1$2', DIRECTORY_SEPARATOR),
64 $className
65 );
66
67 $className = str_replace('TUTOR' . DIRECTORY_SEPARATOR, 'restapi' . DIRECTORY_SEPARATOR, $className);
68 $file_name = $this->path . $className . '.php';
69
70 if (file_exists($file_name)) {
71 require_once $file_name;
72 }
73 }
74 }
75
76 /*
77 init all routes for api
78 */
79 public function init_routes() {
80 //courses
81 register_rest_route(
82 $this->namespace,
83 '/courses',
84 array(
85 'methods' => "GET",
86 'callback' => array(
87 $this->courseObj, 'course'
88 ),
89 'permission_callback' => '__return_true'
90 )
91 );
92
93 //courses by terms cat and tag
94 register_rest_route(
95 $this->namespace,
96 '/course-by-terms',
97 array(
98 'methods' => "POST",
99 'callback' => array(
100 $this->courseObj, 'course_by_terms'
101 ),
102 'permission_callback' => '__return_true'
103 )
104 );
105
106 //courses by terms cat and tag
107 register_rest_route(
108 $this->namespace,
109 '/course-sorting-by-price',
110 array(
111 'methods' => "GET",
112 'callback' => array(
113 $this->courseObj, 'course_sort_by_price'
114 ),
115 'args' => array(
116 'order' => array(
117 'required' => true,
118 'type' => 'string',
119 'validate_callback' => function ($order) {
120 return $this->validate_order($order);
121 }
122 ),
123 'page' => array(
124 'required' => false,
125 'type' => 'number'
126 )
127 ),
128 'permission_callback' => '__return_true'
129 )
130 );
131
132 //course details
133 register_rest_route(
134 $this->namespace,
135 '/course-detail/(?P<id>\d+)',
136 array(
137 'methods' => 'GET',
138 'callback' => array(
139 $this->courseObj, 'course_detail'
140 ),
141 'args' => array(
142 'id' => array(
143 'validate_callback' => function ($param) {
144 return is_numeric($param);
145 }
146 )
147 ),
148 'permission_callback' => '__return_true'
149 )
150 );
151
152 //course topic
153 register_rest_route(
154 $this->namespace,
155 '/course-topic/(?P<id>\d+)',
156 array(
157 'methods' => 'GET',
158 'callback' => array(
159 $this->topicObj, 'course_topic'
160 ),
161 'args' => array(
162 'id' => array(
163 'validate_callback' => function ($param) {
164 return is_numeric($param);
165 }
166 )
167 ),
168 'permission_callback' => '__return_true'
169 )
170 );
171
172 //lesson by topic
173 register_rest_route(
174 $this->namespace,
175 '/lesson/(?P<id>\d+)',
176 array(
177 'methods' => 'GET',
178 'callback' => array(
179 $this->lessonObj, 'topic_lesson'
180 ),
181 'args' => array(
182 'id' => array(
183 'validate_callback' => function ($param) {
184 return is_numeric($param);
185 }
186 )
187 ),
188 'permission_callback' => '__return_true'
189 )
190 );
191
192 //course annoucement by course id
193 register_rest_route(
194 $this->namespace,
195 '/course-annoucement/(?P<id>\d+)',
196 array(
197 'methods' => 'GET',
198 'callback' => array(
199 $this->annoucementObj, 'course_annoucement'
200 ),
201 'args' => array(
202 'id' => array(
203 'validate_callback' => function ($param) {
204 return is_numeric($param);
205 }
206 )
207 ),
208 'permission_callback' => '__return_true'
209 )
210 );
211
212 //quiz by topic id
213 register_rest_route(
214 $this->namespace,
215 '/quiz/(?P<id>\d+)',
216 array(
217 'methods' => 'GET',
218 'callback' => array(
219 $this->quizObj, 'quiz_with_settings'
220 ),
221 'args' => array(
222 'id' => array(
223 'validate_callback' => function ($param) {
224 return is_numeric($param);
225 }
226 )
227 ),
228 'permission_callback' => '__return_true'
229 )
230 );
231
232 //quiz question answer by quiz id
233 register_rest_route(
234 $this->namespace,
235 '/quiz-question-answer/(?P<id>\d+)',
236 array(
237 'methods' => 'GET',
238 'callback' => array(
239 $this->quizObj, 'quiz_question_ans'
240 ),
241 'args' => array(
242 'id' => array(
243 'validate_callback' => function ($param) {
244 return is_numeric($param);
245 }
246 )
247 ),
248 'permission_callback' => '__return_true'
249 )
250 );
251
252 //quiz attempt details by quiz id
253 register_rest_route(
254 $this->namespace,
255 '/quiz-attempt-details/(?P<id>\d+)',
256 array(
257 'methods' => 'GET',
258 'callback' => array(
259 $this->quizObj, 'quiz_attempt_details'
260 ),
261 'args' => array(
262 'id' => array(
263 'validate_callback' => function ($param) {
264 return is_numeric($param);
265 }
266 )
267 ),
268 'permission_callback' => '__return_true'
269 )
270 );
271
272 //author detail by id
273 register_rest_route(
274 $this->namespace,
275 '/author-information/(?P<id>\d+)',
276 array(
277 'methods' => 'GET',
278 'callback' => array(
279 $this->authorObj, 'author_detail'
280 ),
281 'args' => array(
282 'id' => array(
283 'validate_callback' => function ($param) {
284 return is_numeric($param);
285 }
286 )
287 ),
288 'permission_callback' => '__return_true'
289 )
290 );
291
292 //reviews by course id
293 register_rest_route(
294 $this->namespace,
295 '/course-rating/(?P<id>\d+)',
296 array(
297 'methods' => 'GET',
298 'callback' => array(
299 $this->ratingObj, 'course_rating'
300 ),
301 'args' => array(
302 'id' => array(
303 'validate_callback' => function ($param) {
304 return is_numeric($param);
305 }
306 )
307 ),
308 'permission_callback' => '__return_true'
309 )
310 );
311 }
312 }
313