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