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