PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 1.9.10
Tutor LMS – eLearning and online course solution v1.9.10
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 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Assets.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_Settings_Tabs.php 5 years ago Course_Widget.php 5 years ago Custom_Validation.php 5 years ago Dashboard.php 4 years ago Email.php 5 years ago FormHandler.php 5 years ago Frontend.php 5 years ago Gutenberg.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 5 years ago Q_and_A.php 5 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 5 years ago Rewrite_Rules.php 4 years ago Shortcode.php 4 years ago Student.php 4 years ago Students_List.php 4 years ago Taxonomies.php 5 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 4 years ago Tutor.php 4 years ago TutorEDD.php 5 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 5 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 5 years ago Withdraw.php 5 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
Tutor.php
672 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 $wpdb->tutor_email_queue = $wpdb->prefix.'tutor_email_queue';
91
92 /**
93 * Changing default wp doing ajax return based on tutor ajax action
94 */
95 add_filter('wp_doing_ajax', array($this, 'wp_doing_ajax'));
96
97 /**
98 * Include Files
99 */
100 //add_action( 'init', array( $this, 'includes' ), 11 );
101 $this->includes();
102
103 /**
104 * Loading Autoloader
105 */
106
107 if ( function_exists( '__autoload' ) ) {
108 spl_autoload_register( '__autoload' );
109 }
110 spl_autoload_register(array($this, 'loader'));
111
112 do_action('tutor_before_load');
113
114 $this->addons = new Addons();
115 $this->post_types = new Post_types();
116 $this->taxonomies = new Taxonomies();
117 $this->assets = new Assets();
118 $this->admin = new Admin();
119 $this->ajax = new Ajax();
120 $this->options = new Options();
121 $this->shortcode = new Shortcode();
122 $this->course = new Course();
123 $this->lesson = new Lesson();
124 $this->rewrite_rules = new Rewrite_Rules();
125 $this->template = new Template();
126 $this->instructor = new Instructor();
127 $this->student = new Student();
128 $this->q_and_a = new Q_and_A();
129 $this->quiz = new Quiz();
130 $this->tools = new Tools();
131 $this->user = new User();
132 $this->theme_compatibility = new Theme_Compatibility();
133 $this->gutenberg = new Gutenberg();
134 $this->course_settings_tabs = new Course_Settings_Tabs();
135 $this->withdraw = new Withdraw();
136 $this->course_widget = new Course_Widget();
137 $this->upgrader = new Upgrader();
138 $this->dashboard = new Dashboard();
139 $this->form_handler = new FormHandler();
140 $this->frontend = new Frontend();
141 $this->email = new Email();
142 $this->rest_api = new RestAPI();
143 $this->setup = new Tutor_Setup();
144 $this->private_course_access = new Private_Course_Access();
145 $this->course_filter = new Course_Filter();
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' ), 10, 2 );
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, $network_wide = null ) {
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
240 // Create Database
241 self::create_database();
242
243 //Save Option
244 if ( ! $version ) {
245
246 $options = self::default_options();
247 update_option('tutor_option', $options);
248
249 //Rewrite Flush
250 update_option('required_rewrite_flush', tutor_time());
251 self::manage_tutor_roles_and_permissions();
252
253 self::save_data();//Save initial Page
254 update_option('tutor_version', TUTOR_VERSION);
255 }
256
257 //Set Schedule
258 if ( ! wp_next_scheduled ( 'tutor_once_in_day_run_schedule' ) ) {
259 wp_schedule_event( tutor_time(), 'twicedaily', 'tutor_once_in_day_run_schedule' );
260 }
261
262 /**
263 * Backward Compatibility for version < 1.2.0
264 */
265 if ( version_compare( get_option( 'tutor_version' ), '1.2.0', '<' ) ) {
266 /**
267 * Creating New Database
268 */
269 self::create_withdraw_database();
270 //Update the tutor version
271 update_option( 'tutor_version', '1.2.0' );
272 //Rewrite Flush
273 update_option( 'required_rewrite_flush', tutor_time() );
274 }
275
276 /**
277 * Backward Compatibility to < 1.3.1 for make course plural
278 */
279 if (version_compare(get_option('tutor_version'), '1.3.1', '<')){
280 global $wpdb;
281
282 if ( ! get_option('is_course_post_type_updated')){
283 $wpdb->update($wpdb->posts, array('post_type' => 'courses'), array('post_type' => 'course'));
284 update_option('is_course_post_type_updated', true);
285 update_option('tutor_version', '1.3.1');
286 flush_rewrite_rules();
287 }
288 }
289
290 /**
291 * Save First activation Time
292 */
293 $first_activation_date = get_option('tutor_first_activation_time');
294 if ( ! $first_activation_date){
295 update_option('tutor_first_activation_time', tutor_time());
296 }
297 }
298
299 //Run task on deactivation
300 public static function tutor_deactivation() {
301 wp_clear_scheduled_hook('tutor_once_in_day_run_schedule');
302 }
303
304 public static function create_database(){
305 global $wpdb;
306
307 $charset_collate = $wpdb->get_charset_collate();
308
309 /**
310 * Table SQL
311 *
312 * {$wpdb->prefix}tutor_quiz_attempts
313 * {$wpdb->prefix}tutor_quiz_attempt_answers
314 * {$wpdb->prefix}tutor_quiz_questions
315 * {$wpdb->prefix}tutor_quiz_question_answers
316 * {$wpdb->prefix}tutor_earnings
317 * {$wpdb->prefix}tutor_withdraws
318 *
319 * @since v.1.0.0
320 */
321 $quiz_attempts_sql = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempts (
322 attempt_id int(11) NOT NULL AUTO_INCREMENT,
323 course_id int(11) DEFAULT NULL,
324 quiz_id int(11) DEFAULT NULL,
325 user_id int(11) DEFAULT NULL,
326 total_questions int(11) DEFAULT NULL,
327 total_answered_questions int(11) DEFAULT NULL,
328 total_marks decimal(9,2) DEFAULT NULL,
329 earned_marks decimal(9,2) DEFAULT NULL,
330 attempt_info text,
331 attempt_status varchar(50) DEFAULT NULL,
332 attempt_ip varchar(250) DEFAULT NULL,
333 attempt_started_at datetime DEFAULT NULL,
334 attempt_ended_at datetime DEFAULT NULL,
335 is_manually_reviewed int(1) DEFAULT NULL,
336 manually_reviewed_at datetime DEFAULT NULL,
337 PRIMARY KEY (attempt_id)
338 ) $charset_collate;";
339
340 $quiz_attempt_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempt_answers (
341 attempt_answer_id int(11) NOT NULL AUTO_INCREMENT,
342 user_id int(11) DEFAULT NULL,
343 quiz_id int(11) DEFAULT NULL,
344 question_id int(11) DEFAULT NULL,
345 quiz_attempt_id int(11) DEFAULT NULL,
346 given_answer longtext,
347 question_mark decimal(8,2) DEFAULT NULL,
348 achieved_mark decimal(8,2) DEFAULT NULL,
349 minus_mark decimal(8,2) DEFAULT NULL,
350 is_correct tinyint(4) DEFAULT NULL,
351 PRIMARY KEY (attempt_answer_id)
352 ) $charset_collate;";
353
354 $tutor_quiz_questions = "CREATE TABLE {$wpdb->prefix}tutor_quiz_questions (
355 question_id int(11) NOT NULL AUTO_INCREMENT,
356 quiz_id int(11) DEFAULT NULL,
357 question_title text,
358 question_description longtext,
359 question_type varchar(50) DEFAULT NULL,
360 question_mark decimal(9,2) DEFAULT NULL,
361 question_settings longtext,
362 question_order int(11) DEFAULT NULL,
363 PRIMARY KEY (question_id)
364 ) $charset_collate;";
365
366 $tutor_quiz_question_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_question_answers (
367 answer_id int(11) NOT NULL AUTO_INCREMENT,
368 belongs_question_id int(11) DEFAULT NULL,
369 belongs_question_type varchar(250) DEFAULT NULL,
370 answer_title text,
371 is_correct tinyint(4) DEFAULT NULL,
372 image_id int(11) DEFAULT NULL,
373 answer_two_gap_match text,
374 answer_view_format varchar(250) DEFAULT NULL,
375 answer_settings text,
376 answer_order int(11) DEFAULT '0',
377 PRIMARY KEY (answer_id)
378 ) $charset_collate;";
379
380 $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings (
381 earning_id int(11) NOT NULL AUTO_INCREMENT,
382 user_id int(11) DEFAULT NULL,
383 course_id int(11) DEFAULT NULL,
384 order_id int(11) DEFAULT NULL,
385 order_status varchar(50) DEFAULT NULL,
386 course_price_total decimal(16,2) DEFAULT NULL,
387 course_price_grand_total decimal(16,2) DEFAULT NULL,
388 instructor_amount decimal(16,2) DEFAULT NULL,
389 instructor_rate decimal(16,2) DEFAULT NULL,
390 admin_amount decimal(16,2) DEFAULT NULL,
391 admin_rate decimal(16,2) DEFAULT NULL,
392 commission_type varchar(20) DEFAULT NULL,
393 deduct_fees_amount decimal(16,2) DEFAULT NULL,
394 deduct_fees_name varchar(250) DEFAULT NULL,
395 deduct_fees_type varchar(20) DEFAULT NULL,
396 process_by varchar(20) DEFAULT NULL,
397 created_at datetime DEFAULT NULL,
398 PRIMARY KEY (earning_id)
399 ) $charset_collate;";
400
401 $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws (
402 withdraw_id int(11) NOT NULL AUTO_INCREMENT,
403 user_id int(11) DEFAULT NULL,
404 amount decimal(16,2) DEFAULT NULL,
405 method_data text DEFAULT NULL,
406 status varchar(50) DEFAULT NULL,
407 updated_at datetime DEFAULT NULL,
408 created_at datetime DEFAULT NULL,
409 PRIMARY KEY (withdraw_id)
410 ) $charset_collate;";
411
412 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
413 dbDelta( $quiz_attempts_sql );
414 dbDelta( $quiz_attempt_answers );
415 dbDelta( $tutor_quiz_questions );
416 dbDelta( $tutor_quiz_question_answers );
417 dbDelta( $earning_table );
418 dbDelta( $withdraw_table );
419 }
420
421 public static function manage_tutor_roles_and_permissions(){
422 /**
423 * Add role for instructor
424 */
425 $instructor_role = tutor()->instructor_role;
426
427 remove_role($instructor_role);
428 add_role( $instructor_role, __('Tutor Instructor', 'tutor'), array() );
429
430 $custom_post_type_permission = array(
431 //Manage Instructor
432 'manage_tutor_instructor',
433
434 //Tutor Posts Type Permission
435 'edit_tutor_course',
436 'read_tutor_course',
437 'delete_tutor_course',
438 'delete_tutor_courses',
439 'edit_tutor_courses',
440 'edit_others_tutor_courses',
441 'read_private_tutor_courses',
442 'edit_tutor_courses',
443
444 'edit_tutor_lesson',
445 'read_tutor_lesson',
446 'delete_tutor_lesson',
447 'delete_tutor_lessons',
448 'edit_tutor_lessons',
449 'edit_others_tutor_lessons',
450 'read_private_tutor_lessons',
451 'edit_tutor_lessons',
452 'publish_tutor_lessons',
453
454 'edit_tutor_quiz',
455 'read_tutor_quiz',
456 'delete_tutor_quiz',
457 'delete_tutor_quizzes',
458 'edit_tutor_quizzes',
459 'edit_others_tutor_quizzes',
460 'read_private_tutor_quizzes',
461 'edit_tutor_quizzes',
462 'publish_tutor_quizzes',
463
464 'edit_tutor_question',
465 'read_tutor_question',
466 'delete_tutor_question',
467 'delete_tutor_questions',
468 'edit_tutor_questions',
469 'edit_others_tutor_questions',
470 'publish_tutor_questions',
471 'read_private_tutor_questions',
472 'edit_tutor_questions',
473 );
474
475 $instructor = get_role( $instructor_role );
476 if ( $instructor ) {
477 $instructor_cap = array (
478 'edit_posts',
479 'read',
480 'upload_files',
481 );
482
483 $instructor_cap = array_merge($instructor_cap, $custom_post_type_permission);
484
485 $can_publish_course = (bool) tutor_utils()->get_option('instructor_can_publish_course');
486 if ($can_publish_course){
487 $instructor_cap[] = 'publish_tutor_courses';
488 }
489
490 foreach ($instructor_cap as $cap){
491 $instructor->add_cap( $cap );
492 }
493 }
494
495 $administrator = get_role( 'administrator' );
496 if ( $administrator ) {
497
498 $administrator_cap = array (
499 'manage_tutor',
500 );
501 $administrator_cap = array_merge($administrator_cap, $custom_post_type_permission);
502 $administrator_cap[] = 'publish_tutor_courses';
503
504 foreach ($administrator_cap as $cap){
505 $administrator->add_cap( $cap );
506 }
507 }
508
509 /**
510 * Add Instructor role to administrator
511 */
512 if (current_user_can('administrator')){
513 tutor_utils()->add_instructor_role(get_current_user_id());
514 }
515
516 }
517
518 /**
519 * Save data like page
520 */
521 public static function save_data(){
522 $student_dashboard_args = array(
523 'post_title' => __('Dashboard', 'tutor'),
524 'post_content' => '',
525 'post_type' => 'page',
526 'post_status' => 'publish',
527 );
528 $student_dashboard_page_id = wp_insert_post( $student_dashboard_args );
529 tutor_utils()->update_option('tutor_dashboard_page_id', $student_dashboard_page_id);
530
531 $student_registration_args = array(
532 'post_title' => __('Student Registration', 'tutor'),
533 'post_content' => '[tutor_student_registration_form]',
534 'post_type' => 'page',
535 'post_status' => 'publish',
536 );
537 $student_register_page_id = wp_insert_post( $student_registration_args );
538 tutor_utils()->update_option('student_register_page', $student_register_page_id);
539
540 $instructor_registration_args = array(
541 'post_title' => __('Instructor Registration', 'tutor'),
542 'post_content' => '[tutor_instructor_registration_form]',
543 'post_type' => 'page',
544 'post_status' => 'publish',
545 );
546 $instructor_registration_id = wp_insert_post( $instructor_registration_args );
547 tutor_utils()->update_option('instructor_register_page', $instructor_registration_id);
548 }
549
550 public static function default_options(){
551 $options = array (
552 'pagination_per_page' => '20',
553 'load_tutor_css' => '1',
554 'load_tutor_js' => '1',
555 'course_allow_upload_private_files' => '1',
556 'display_course_instructors' => '1',
557 'enable_q_and_a_on_course' => '1',
558 'courses_col_per_row' => '3',
559 'courses_per_page' => '12',
560 'lesson_permalink_base' => 'lesson',
561 'quiz_time_limit' =>
562 array (
563 'value' => '0',
564 'time' => 'minutes',
565 ),
566 'quiz_when_time_expires' => 'autosubmit',
567 'quiz_attempts_allowed' => '10',
568 'quiz_grade_method' => 'highest_grade',
569 'enable_public_profile' => '1',
570 'email_to_students' =>
571 array (
572 'quiz_completed' => '1',
573 'completed_course' => '1',
574 ),
575 'email_to_instructors' =>
576 array (
577 'a_student_enrolled_in_course' => '1',
578 'a_student_completed_course' => '1',
579 'a_student_completed_lesson' => '1',
580 'a_student_placed_question' => '1',
581 ),
582 'email_from_name' => get_option('blogname'),
583 'email_from_address' => get_option('admin_email'),
584 'email_footer_text' => '',
585 'earning_admin_commission' => '20',
586 'earning_admin_commission' => '20',
587 'earning_instructor_commission' => '80'
588 );
589 return $options;
590 }
591
592
593 /**
594 * Create withdraw database
595 *
596 * @since v.1.2.0
597 */
598 public static function create_withdraw_database(){
599 global $wpdb;
600
601 $charset_collate = $wpdb->get_charset_collate();
602
603 /**
604 * Table SQL
605 *
606 * {$wpdb->prefix}tutor_earnings
607 * {$wpdb->prefix}tutor_withdraws
608 *
609 * @since v.1.2.0
610 */
611
612 $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings (
613 earning_id int(11) NOT NULL AUTO_INCREMENT,
614 user_id int(11) DEFAULT NULL,
615 course_id int(11) DEFAULT NULL,
616 order_id int(11) DEFAULT NULL,
617 order_status varchar(50) DEFAULT NULL,
618 course_price_total decimal(16,2) DEFAULT NULL,
619 course_price_grand_total decimal(16,2) DEFAULT NULL,
620 instructor_amount decimal(16,2) DEFAULT NULL,
621 instructor_rate decimal(16,2) DEFAULT NULL,
622 admin_amount decimal(16,2) DEFAULT NULL,
623 admin_rate decimal(16,2) DEFAULT NULL,
624 commission_type varchar(20) DEFAULT NULL,
625 deduct_fees_amount decimal(16,2) DEFAULT NULL,
626 deduct_fees_name varchar(250) DEFAULT NULL,
627 deduct_fees_type varchar(20) DEFAULT NULL,
628 process_by varchar(20) DEFAULT NULL,
629 created_at datetime DEFAULT NULL,
630 PRIMARY KEY (earning_id)
631 ) $charset_collate;";
632
633 $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws (
634 withdraw_id int(11) NOT NULL AUTO_INCREMENT,
635 user_id int(11) DEFAULT NULL,
636 amount decimal(16,2) DEFAULT NULL,
637 method_data text DEFAULT NULL,
638 status varchar(50) DEFAULT NULL,
639 updated_at datetime DEFAULT NULL,
640 created_at datetime DEFAULT NULL,
641 PRIMARY KEY (withdraw_id)
642 ) $charset_collate;";
643
644 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
645 dbDelta( $earning_table );
646 dbDelta( $withdraw_table );
647
648 /**
649 * Setting previous dashboard to new dashboard
650 */
651 $previous_dashboard_page_id = (int) tutor_utils()->get_option('student_dashboard');
652 tutor_utils()->update_option('tutor_dashboard_page_id', $previous_dashboard_page_id);
653 }
654
655 /**
656 * @param $bool
657 *
658 * @return bool
659 *
660 * Filter the wp_doing_ajax from tutor requests to get advanced advantages from Tutor
661 *
662 * @since v.1.3.4
663 */
664 public function wp_doing_ajax($bool){
665 if (isset($_REQUEST['tutor_ajax_action'])){
666 return true;
667 }
668 return $bool;
669 }
670
671
672 }