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