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