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