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