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