PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 1.5.1
Tutor LMS – eLearning and online course solution v1.5.1
3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.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 / Tutor.php
tutor / classes Last commit date
Addons.php 6 years ago Admin.php 6 years ago Ajax.php 6 years ago Assets.php 6 years ago Course.php 6 years ago Course_Settings_Tabs.php 6 years ago Course_Widget.php 6 years ago Dashboard.php 6 years ago Email.php 6 years ago FormHandler.php 6 years ago Gutenberg.php 6 years ago Instructor.php 6 years ago Instructors_List.php 6 years ago Lesson.php 6 years ago Options.php 6 years ago Post_types.php 6 years ago Q_and_A.php 6 years ago Question_Answers_List.php 6 years ago Quiz.php 6 years ago Quiz_Attempts_List.php 6 years ago RestAPI.php 6 years ago Rewrite_Rules.php 6 years ago Shortcode.php 6 years ago Student.php 6 years ago Students_List.php 6 years ago Taxonomies.php 6 years ago Template.php 6 years ago Theme_Compatibility.php 6 years ago Tools.php 6 years ago Tutor.php 6 years ago TutorEDD.php 6 years ago Tutor_Base.php 6 years ago Tutor_List_Table.php 6 years ago Upgrader.php 6 years ago User.php 6 years ago Utils.php 6 years ago Video_Stream.php 6 years ago Withdraw.php 6 years ago Withdraw_Requests_List.php 6 years ago WooCommerce.php 6 years ago
Tutor.php
639 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) )
5 exit;
6
7 final class Tutor{
8 public $version = TUTOR_VERSION;
9 public $path;
10 public $url;
11 public $basename;
12
13 /**
14 * The single instance of the class.
15 *
16 * @since v.1.2.0
17 */
18 protected static $_instance = null;
19
20 //Components
21 public $utils;
22 public $admin;
23 public $ajax;
24 public $options;
25 public $shortcode;
26
27 private $addons;
28 private $post_types;
29 private $taxonomies;
30 private $assets;
31 private $course;
32 private $lesson;
33 private $rewrite_rules;
34 private $template;
35 private $instructor;
36 private $student;
37 private $q_and_a;
38 private $quiz;
39 private $tools;
40 private $user;
41 private $theme_compatibility;
42 private $gutenberg;
43 private $course_settings_tabs;
44 private $withdraw;
45
46 private $course_widget;
47 private $upgrader;
48 private $dashboard;
49 private $form_handler;
50 private $email;
51
52 //Integrations
53 private $woocommerce;
54 private $edd;
55
56 /**
57 * @return null|Tutor
58 *
59 * Run the TUTOR
60 *
61 * @since 1.2.0
62 */
63 public static function instance() {
64 if ( is_null( self::$_instance ) ) {
65 self::$_instance = new self();
66 }
67 return self::$_instance;
68 }
69
70 function __construct() {
71
72 $this->path = plugin_dir_path(TUTOR_FILE);
73 $this->url = plugin_dir_url(TUTOR_FILE);
74 $this->basename = plugin_basename(TUTOR_FILE);
75
76 /**
77 * Adding Tutor Database table to $wpdb;
78 * @since v.1.4.2
79 */
80 global $wpdb;
81 $wpdb->tutor_earnings = $wpdb->prefix.'tutor_earnings';
82 $wpdb->tutor_gradebooks = $wpdb->prefix.'tutor_gradebooks';
83 $wpdb->tutor_gradebooks_results = $wpdb->prefix.'tutor_gradebooks_results';
84 $wpdb->tutor_quiz_attempts = $wpdb->prefix.'tutor_quiz_attempts';
85 $wpdb->tutor_quiz_attempt_answers = $wpdb->prefix.'tutor_quiz_attempt_answers';
86 $wpdb->tutor_quiz_questions = $wpdb->prefix.'tutor_quiz_questions';
87 $wpdb->tutor_quiz_question_answers = $wpdb->prefix.'tutor_quiz_question_answers';
88 $wpdb->tutor_withdraws = $wpdb->prefix.'tutor_withdraws';
89
90 /**
91 * Changing default wp doing ajax return based on tutor ajax action
92 */
93 add_filter('wp_doing_ajax', array($this, 'wp_doing_ajax'));
94
95 /**
96 * Include Files
97 */
98 //add_action( 'init', array( $this, 'includes' ), 11 );
99 $this->includes();
100
101 /**
102 * Loading Autoloader
103 */
104
105 if ( function_exists( '__autoload' ) ) {
106 spl_autoload_register( '__autoload' );
107 }
108 spl_autoload_register(array($this, 'loader'));
109
110 do_action('tutor_before_load');
111
112 $this->addons = new Addons();
113 $this->post_types = new Post_types();
114 $this->taxonomies = new Taxonomies();
115 $this->assets = new Assets();
116 $this->admin = new Admin();
117 $this->ajax = new Ajax();
118 $this->options = new Options();
119 $this->shortcode = new Shortcode();
120 $this->course = new Course();
121 $this->lesson = new Lesson();
122 $this->rewrite_rules = new Rewrite_Rules();
123 $this->template = new Template();
124 $this->instructor = new Instructor();
125 $this->student = new Student();
126 $this->q_and_a = new Q_and_A();
127 $this->quiz = new Quiz();
128 $this->tools = new Tools();
129 $this->user = new User();
130 $this->theme_compatibility = new Theme_Compatibility();
131 $this->gutenberg = new Gutenberg();
132 $this->course_settings_tabs = new Course_Settings_Tabs();
133 $this->withdraw = new Withdraw();
134 $this->course_widget = new Course_Widget();
135 $this->upgrader = new Upgrader();
136 $this->dashboard = new Dashboard();
137 $this->form_handler = new FormHandler();
138 $this->email = new Email();
139 $this->rest_api = new RestAPI();
140
141 //Integrations
142 $this->woocommerce = new WooCommerce();
143 $this->edd = new TutorEDD();
144
145 /**
146 * Run Method
147 * @since v.1.2.0
148 */
149 $this->run();
150
151 do_action('tutor_loaded');
152
153 add_action( 'init', array( $this, 'init_action' ) );
154 }
155
156 /**
157 * @param $className
158 *
159 * Auto Load class and the files
160 */
161 private function loader($className) {
162 if ( ! class_exists($className)){
163 $className = preg_replace(
164 array('/([a-z])([A-Z])/', '/\\\/'),
165 array('$1$2', DIRECTORY_SEPARATOR),
166 $className
167 );
168
169 $className = str_replace('TUTOR'.DIRECTORY_SEPARATOR, 'classes'.DIRECTORY_SEPARATOR, $className);
170 $file_name = $this->path.$className.'.php';
171
172 if (file_exists($file_name) ) {
173 require_once $file_name;
174 }
175 }
176 }
177
178 public function includes(){
179 include tutor()->path.'includes/tutor-general-functions.php';
180 include tutor()->path.'includes/tutor-template-functions.php';
181 include tutor()->path.'includes/tutor-template-hook.php';
182 }
183
184 //Run the TUTOR right now
185 public function run(){
186 do_action('tutor_before_run');
187
188 register_activation_hook( TUTOR_FILE, array($this, 'tutor_activate' ) );
189 register_deactivation_hook(TUTOR_FILE, array($this, 'tutor_deactivation'));
190
191 do_action('tutor_after_run');
192 }
193
194 /**
195 * Tutor Action Via do_action
196 * @since 1.2.14
197 */
198 public function init_action(){
199 if (isset($_REQUEST['tutor_action'])){
200 do_action('tutor_action_'.$_REQUEST['tutor_action']);
201 }
202
203 }
204
205 /**
206 * Do some task during plugin activation
207 */
208 public function tutor_activate(){
209 $version = get_option('tutor_version');
210 //Save Option
211 if ( ! $version){
212 //Create Database
213 $this->create_database();
214
215 $options = self::default_options();
216 update_option('tutor_option', $options);
217
218 //Rewrite Flush
219 update_option('required_rewrite_flush', tutor_time());
220 self::manage_tutor_roles_and_permissions();
221
222 self::save_data();//Save initial Page
223 update_option('tutor_version', TUTOR_VERSION);
224 }
225
226 //Set Schedule
227 if (! wp_next_scheduled ( 'tutor_once_in_day_run_schedule' )) {
228 wp_schedule_event(tutor_time(), 'twicedaily', 'tutor_once_in_day_run_schedule');
229 }
230
231 /**
232 * Backward Compatibility for version < 1.2.0
233 */
234 if (version_compare(get_option('tutor_version'), '1.2.0', '<')){
235 /**
236 * Creating New Database
237 */
238 $this->create_withdraw_database();
239 //Update the tutor version
240 update_option('tutor_version', '1.2.0');
241 //Rewrite Flush
242 update_option('required_rewrite_flush', tutor_time());
243 }
244
245 /**
246 * Backward Compatibility to < 1.3.1 for make course plural
247 */
248 if (version_compare(get_option('tutor_version'), '1.3.1', '<')){
249 global $wpdb;
250
251 if ( ! get_option('is_course_post_type_updated')){
252 $wpdb->update($wpdb->posts, array('post_type' => 'courses'), array('post_type' => 'course'));
253 update_option('is_course_post_type_updated', true);
254 update_option('tutor_version', '1.3.1');
255 flush_rewrite_rules();
256 }
257 }
258
259 /**
260 * Save First activation Time
261 */
262 $first_activation_date = get_option('tutor_first_activation_time');
263 if ( ! $first_activation_date){
264 update_option('tutor_first_activation_time', tutor_time());
265 }
266
267 }
268
269 //Run task on deactivation
270 public function tutor_deactivation() {
271 wp_clear_scheduled_hook('tutor_once_in_day_run_schedule');
272 }
273
274 public function create_database(){
275 global $wpdb;
276
277 $charset_collate = $wpdb->get_charset_collate();
278
279 /**
280 * Table SQL
281 *
282 * {$wpdb->prefix}tutor_quiz_attempts
283 * {$wpdb->prefix}tutor_quiz_attempt_answers
284 * {$wpdb->prefix}tutor_quiz_questions
285 * {$wpdb->prefix}tutor_quiz_question_answers
286 * {$wpdb->prefix}tutor_earnings
287 * {$wpdb->prefix}tutor_withdraws
288 *
289 * @since v.1.0.0
290 */
291 $quiz_attempts_sql = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempts (
292 attempt_id int(11) NOT NULL AUTO_INCREMENT,
293 course_id int(11) DEFAULT NULL,
294 quiz_id int(11) DEFAULT NULL,
295 user_id int(11) DEFAULT NULL,
296 total_questions int(11) DEFAULT NULL,
297 total_answered_questions int(11) DEFAULT NULL,
298 total_marks decimal(9,2) DEFAULT NULL,
299 earned_marks decimal(9,2) DEFAULT NULL,
300 attempt_info text,
301 attempt_status varchar(50) DEFAULT NULL,
302 attempt_ip varchar(250) DEFAULT NULL,
303 attempt_started_at datetime DEFAULT NULL,
304 attempt_ended_at datetime DEFAULT NULL,
305 is_manually_reviewed int(1) DEFAULT NULL,
306 manually_reviewed_at datetime DEFAULT NULL,
307 PRIMARY KEY (attempt_id)
308 ) $charset_collate;";
309
310 $quiz_attempt_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempt_answers (
311 attempt_answer_id int(11) NOT NULL AUTO_INCREMENT,
312 user_id int(11) DEFAULT NULL,
313 quiz_id int(11) DEFAULT NULL,
314 question_id int(11) DEFAULT NULL,
315 quiz_attempt_id int(11) DEFAULT NULL,
316 given_answer longtext,
317 question_mark decimal(8,2) DEFAULT NULL,
318 achieved_mark decimal(8,2) DEFAULT NULL,
319 minus_mark decimal(8,2) DEFAULT NULL,
320 is_correct tinyint(4) DEFAULT NULL,
321 PRIMARY KEY (attempt_answer_id)
322 ) $charset_collate;";
323
324 $tutor_quiz_questions = "CREATE TABLE {$wpdb->prefix}tutor_quiz_questions (
325 question_id int(11) NOT NULL AUTO_INCREMENT,
326 quiz_id int(11) DEFAULT NULL,
327 question_title text,
328 question_description longtext,
329 question_type varchar(50) DEFAULT NULL,
330 question_mark decimal(9,2) DEFAULT NULL,
331 question_settings longtext,
332 question_order int(11) DEFAULT NULL,
333 PRIMARY KEY (question_id)
334 ) $charset_collate;";
335
336 $tutor_quiz_question_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_question_answers (
337 answer_id int(11) NOT NULL AUTO_INCREMENT,
338 belongs_question_id int(11) DEFAULT NULL,
339 belongs_question_type varchar(250) DEFAULT NULL,
340 answer_title text,
341 is_correct tinyint(4) DEFAULT NULL,
342 image_id int(11) DEFAULT NULL,
343 answer_two_gap_match text,
344 answer_view_format varchar(250) DEFAULT NULL,
345 answer_settings text,
346 answer_order int(11) DEFAULT '0',
347 PRIMARY KEY (answer_id)
348 ) $charset_collate;";
349
350 $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings (
351 earning_id int(11) NOT NULL AUTO_INCREMENT,
352 user_id int(11) DEFAULT NULL,
353 course_id int(11) DEFAULT NULL,
354 order_id int(11) DEFAULT NULL,
355 order_status varchar(50) DEFAULT NULL,
356 course_price_total decimal(16,2) DEFAULT NULL,
357 course_price_grand_total decimal(16,2) DEFAULT NULL,
358 instructor_amount decimal(16,2) DEFAULT NULL,
359 instructor_rate decimal(16,2) DEFAULT NULL,
360 admin_amount decimal(16,2) DEFAULT NULL,
361 admin_rate decimal(16,2) DEFAULT NULL,
362 commission_type varchar(20) DEFAULT NULL,
363 deduct_fees_amount decimal(16,2) DEFAULT NULL,
364 deduct_fees_name varchar(250) DEFAULT NULL,
365 deduct_fees_type varchar(20) DEFAULT NULL,
366 process_by varchar(20) DEFAULT NULL,
367 created_at datetime DEFAULT NULL,
368 PRIMARY KEY (earning_id)
369 ) $charset_collate;";
370
371 $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws (
372 withdraw_id int(11) NOT NULL AUTO_INCREMENT,
373 user_id int(11) DEFAULT NULL,
374 amount decimal(16,2) DEFAULT NULL,
375 method_data text DEFAULT NULL,
376 status varchar(50) DEFAULT NULL,
377 updated_at datetime DEFAULT NULL,
378 created_at datetime DEFAULT NULL,
379 PRIMARY KEY (withdraw_id)
380 ) $charset_collate;";
381
382 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
383 dbDelta( $quiz_attempts_sql );
384 dbDelta( $quiz_attempt_answers );
385 dbDelta( $tutor_quiz_questions );
386 dbDelta( $tutor_quiz_question_answers );
387 dbDelta( $earning_table );
388 dbDelta( $withdraw_table );
389 }
390
391 public static function manage_tutor_roles_and_permissions(){
392 /**
393 * Add role for instructor
394 */
395 $instructor_role = tutor()->instructor_role;
396
397 remove_role($instructor_role);
398 add_role( $instructor_role, __('Tutor Instructor', 'tutor'), array() );
399
400 $custom_post_type_permission = array(
401 //Manage Instructor
402 'manage_tutor_instructor',
403
404 //Tutor Posts Type Permission
405 'edit_tutor_course',
406 'read_tutor_course',
407 'delete_tutor_course',
408 'delete_tutor_courses',
409 'edit_tutor_courses',
410 'edit_others_tutor_courses',
411 'read_private_tutor_courses',
412 'edit_tutor_courses',
413
414 'edit_tutor_lesson',
415 'read_tutor_lesson',
416 'delete_tutor_lesson',
417 'delete_tutor_lessons',
418 'edit_tutor_lessons',
419 'edit_others_tutor_lessons',
420 'read_private_tutor_lessons',
421 'edit_tutor_lessons',
422 'publish_tutor_lessons',
423
424 'edit_tutor_quiz',
425 'read_tutor_quiz',
426 'delete_tutor_quiz',
427 'delete_tutor_quizzes',
428 'edit_tutor_quizzes',
429 'edit_others_tutor_quizzes',
430 'read_private_tutor_quizzes',
431 'edit_tutor_quizzes',
432 'publish_tutor_quizzes',
433
434 'edit_tutor_question',
435 'read_tutor_question',
436 'delete_tutor_question',
437 'delete_tutor_questions',
438 'edit_tutor_questions',
439 'edit_others_tutor_questions',
440 'publish_tutor_questions',
441 'read_private_tutor_questions',
442 'edit_tutor_questions',
443 );
444
445 $instructor = get_role( $instructor_role );
446 if ( $instructor ) {
447 $instructor_cap = array (
448 'edit_posts',
449 'read',
450 'upload_files',
451 );
452
453 $instructor_cap = array_merge($instructor_cap, $custom_post_type_permission);
454
455 $can_publish_course = (bool) tutor_utils()->get_option('instructor_can_publish_course');
456 if ($can_publish_course){
457 $instructor_cap[] = 'publish_tutor_courses';
458 }
459
460 foreach ($instructor_cap as $cap){
461 $instructor->add_cap( $cap );
462 }
463 }
464
465 $administrator = get_role( 'administrator' );
466 if ( $administrator ) {
467
468 $administrator_cap = array (
469 'manage_tutor',
470 );
471 $administrator_cap = array_merge($administrator_cap, $custom_post_type_permission);
472 $administrator_cap[] = 'publish_tutor_courses';
473
474 foreach ($administrator_cap as $cap){
475 $administrator->add_cap( $cap );
476 }
477 }
478
479 /**
480 * Add Instructor role to administrator
481 */
482 if (current_user_can('administrator')){
483 tutor_utils()->add_instructor_role(get_current_user_id());
484 }
485
486 }
487
488 /**
489 * Save data like page
490 */
491 public static function save_data(){
492 $student_dashboard_args = array(
493 'post_title' => __('Dashboard', 'tutor'),
494 'post_content' => '',
495 'post_type' => 'page',
496 'post_status' => 'publish',
497 );
498 $student_dashboard_page_id = wp_insert_post( $student_dashboard_args );
499 tutor_utils()->update_option('tutor_dashboard_page_id', $student_dashboard_page_id);
500
501 $student_registration_args = array(
502 'post_title' => __('Student Registration', 'tutor'),
503 'post_content' => '[tutor_student_registration_form]',
504 'post_type' => 'page',
505 'post_status' => 'publish',
506 );
507 $student_register_page_id = wp_insert_post( $student_registration_args );
508 tutor_utils()->update_option('student_register_page', $student_register_page_id);
509
510 $instructor_registration_args = array(
511 'post_title' => __('Instructor Registration', 'tutor'),
512 'post_content' => '[tutor_instructor_registration_form]',
513 'post_type' => 'page',
514 'post_status' => 'publish',
515 );
516 $instructor_registration_id = wp_insert_post( $instructor_registration_args );
517 tutor_utils()->update_option('instructor_register_page', $instructor_registration_id);
518 }
519
520 public static function default_options(){
521 $options = array (
522 'pagination_per_page' => '20',
523 'load_tutor_css' => '1',
524 'load_tutor_js' => '1',
525 'course_allow_upload_private_files' => '1',
526 'display_course_instructors' => '1',
527 'enable_q_and_a_on_course' => '1',
528 'courses_col_per_row' => '3',
529 'courses_per_page' => '3',
530 'lesson_permalink_base' => 'lesson',
531 'quiz_time_limit' =>
532 array (
533 'value' => '0',
534 'time' => 'minutes',
535 ),
536 'quiz_when_time_expires' => 'autosubmit',
537 'quiz_attempts_allowed' => '10',
538 'quiz_grade_method' => 'highest_grade',
539 'enable_public_profile' => '1',
540 'email_to_students' =>
541 array (
542 'quiz_completed' => '1',
543 'completed_course' => '1',
544 ),
545 'email_to_instructors' =>
546 array (
547 'a_student_enrolled_in_course' => '1',
548 'a_student_completed_course' => '1',
549 'a_student_completed_lesson' => '1',
550 'a_student_placed_question' => '1',
551 ),
552 'email_from_name' => get_option('blogname'),
553 'email_from_address' => get_option('admin_email'),
554 'email_footer_text' => '',
555 );
556 return $options;
557 }
558
559
560 /**
561 * Create withdraw database
562 *
563 * @since v.1.2.0
564 */
565 public function create_withdraw_database(){
566 global $wpdb;
567
568 $charset_collate = $wpdb->get_charset_collate();
569
570 /**
571 * Table SQL
572 *
573 * {$wpdb->prefix}tutor_earnings
574 * {$wpdb->prefix}tutor_withdraws
575 *
576 * @since v.1.2.0
577 */
578
579 $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings (
580 earning_id int(11) NOT NULL AUTO_INCREMENT,
581 user_id int(11) DEFAULT NULL,
582 course_id int(11) DEFAULT NULL,
583 order_id int(11) DEFAULT NULL,
584 order_status varchar(50) DEFAULT NULL,
585 course_price_total decimal(16,2) DEFAULT NULL,
586 course_price_grand_total decimal(16,2) DEFAULT NULL,
587 instructor_amount decimal(16,2) DEFAULT NULL,
588 instructor_rate decimal(16,2) DEFAULT NULL,
589 admin_amount decimal(16,2) DEFAULT NULL,
590 admin_rate decimal(16,2) DEFAULT NULL,
591 commission_type varchar(20) DEFAULT NULL,
592 deduct_fees_amount decimal(16,2) DEFAULT NULL,
593 deduct_fees_name varchar(250) DEFAULT NULL,
594 deduct_fees_type varchar(20) DEFAULT NULL,
595 process_by varchar(20) DEFAULT NULL,
596 created_at datetime DEFAULT NULL,
597 PRIMARY KEY (earning_id)
598 ) $charset_collate;";
599
600 $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws (
601 withdraw_id int(11) NOT NULL AUTO_INCREMENT,
602 user_id int(11) DEFAULT NULL,
603 amount decimal(16,2) DEFAULT NULL,
604 method_data text DEFAULT NULL,
605 status varchar(50) DEFAULT NULL,
606 updated_at datetime DEFAULT NULL,
607 created_at datetime DEFAULT NULL,
608 PRIMARY KEY (withdraw_id)
609 ) $charset_collate;";
610
611 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
612 dbDelta( $earning_table );
613 dbDelta( $withdraw_table );
614
615 /**
616 * Setting previous dashboard to new dashboard
617 */
618 $previous_dashboard_page_id = (int) tutor_utils()->get_option('student_dashboard');
619 tutor_utils()->update_option('tutor_dashboard_page_id', $previous_dashboard_page_id);
620 }
621
622 /**
623 * @param $bool
624 *
625 * @return bool
626 *
627 * Filter the wp_doing_ajax from tutor requests to get advanced advantages from Tutor
628 *
629 * @since v.1.3.4
630 */
631 public function wp_doing_ajax($bool){
632 if (isset($_REQUEST['tutor_ajax_action'])){
633 return true;
634 }
635 return $bool;
636 }
637
638
639 }