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