PluginProbe
Tutor LMS – eLearning and online course solution / 3.9.14
Tutor LMS – eLearning and online course solution v3.9.14
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 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 All 191 releases
← All changes | classes/Tutor.php +17 -78 trunk3.9.14 View file →
@@ -3,9 +3,9 @@
3 3 * Initialize all the dependency classes
4 4 *
5 5 * @package Tutor
6 6 * @author Themeum <support@themeum.com>
7 - * @link https://www.themeum.com/
7 + * @link https://themeum.com
8 8 * @since 1.0.0
9 9 */
10 10
11 11 namespace TUTOR;
@@ -11,9 +11,8 @@
11 11 namespace TUTOR;
12 12
13 13 use Tutor\Models\CourseModel;
14 14 use Tutor\Ecommerce\Ecommerce;
15 -use Tutor\GDPR\GDPR;
16 15 use Tutor\Helpers\QueryHelper;
17 16 use Tutor\Migrations\Migration;
18 17
19 18 if ( ! defined( 'ABSPATH' ) ) {
@@ -25,9 +24,8 @@
25 24 *
26 25 * @since 1.0.0
27 26 */
28 27 final class Tutor extends Singleton {
29 -
30 28 /**
31 29 * Tutor version
32 30 *
33 31 * @since 1.0.0
@@ -234,17 +232,8 @@
234 232 */
235 233 private $user;
236 234
237 235 /**
238 - * UserPreference class object
239 - *
240 - * @since 4.0.0
241 - *
242 - * @var UserPreference
243 - */
244 - private $user_preference;
245 -
246 - /**
247 236 * Theme_Compatibility class object
248 237 *
249 238 * @since 1.1.0
250 239 *
@@ -485,10 +474,8 @@
485 474 $this->includes();
486 475
487 476 do_action( 'tutor_before_load' );
488 477
489 - GDPR::get_instance();
490 -
491 478 $this->addons = new Addons();
492 479 $this->post_types = new Post_types();
493 480 $this->taxonomies = new Taxonomies();
494 481 $this->assets = new Assets();
@@ -507,9 +494,8 @@
507 494 $this->q_attempt = new Quiz_Attempts_List();
508 495 $this->quiz = new Quiz();
509 496 $this->tools = new Tools();
510 497 $this->user = new User();
511 - $this->user_preference = new UserPreference();
512 498 $this->theme_compatibility = new Theme_Compatibility();
513 499 $this->gutenberg = new Gutenberg();
514 500 $this->course_settings_tabs = new Course_Settings_Tabs();
515 501 $this->withdraw = new Withdraw();
@@ -571,9 +557,8 @@
571 557
572 558 do_action( 'tutor_loaded' );
573 559
574 560 add_action( 'init', array( $this, 'init_action' ) );
575 - add_action( 'init', array( $this, 'update_instructor_capability' ) );
576 561
577 562 /**
578 563 * Check activated plugin
579 564 *
@@ -587,10 +572,8 @@
587 572 *
588 573 * @since 2.8.0
589 574 */
590 575 add_action( 'admin_init', array( $this, 'redirect_to_setup_page' ) );
591 -
592 - // add_filter( 'rest_request_before_callbacks', array( $this, 'enforce_courses_privacy_rest_api' ), 10, 3 );
593 576 }
594 577
595 578 /**
596 579 * Check activated plugin
@@ -661,8 +644,9 @@
661 644 if ( $is_droip_active && file_exists( $tutor_droip_path ) ) {
662 645 include $tutor_droip_path;
663 646 }
664 647 }
648 +
665 649 }
666 650
667 651 /**
668 652 * Providing hooks
@@ -687,15 +671,10 @@
687 671 }
688 672
689 673 /**
690 674 * Do some task during plugin activation
691 - *
692 - * @since 4.0.0 Flush rewrite rules on activation.
693 675 */
694 676 public static function tutor_activate() {
695 - // Rewrite Flush.
696 - Permalink::set_permalink_flag();
697 -
698 677 $version = get_option( 'tutor_version' );
699 678 if ( ! function_exists( 'tutor_time' ) ) {
700 679 include tutor()->path . 'includes/tutor-general-functions.php';
701 680 }
@@ -708,8 +687,10 @@
708 687
709 688 $options = self::default_options();
710 689 update_option( 'tutor_option', $options );
711 690
691 + // Rewrite Flush.
692 + Permalink::set_permalink_flag();
712 693 self::manage_tutor_roles_and_permissions();
713 694
714 695 // Save initial Page.
715 696 self::save_data();
@@ -730,8 +711,10 @@
730 711 */
731 712 self::create_withdraw_database();
732 713 // Update the tutor version.
733 714 update_option( 'tutor_version', '1.2.0' );
715 + // Rewrite Flush.
716 + Permalink::set_permalink_flag();
734 717 }
735 718
736 719 /**
737 720 * Backward Compatibility to < 1.3.1 for make course plural
@@ -742,8 +725,9 @@
742 725 if ( ! get_option( 'is_course_post_type_updated' ) ) {
743 726 $wpdb->update( $wpdb->posts, array( 'post_type' => tutor()->course_post_type ), array( 'post_type' => 'course' ) );
744 727 update_option( 'is_course_post_type_updated', true );
745 728 update_option( 'tutor_version', '1.3.1' );
729 + Permalink::set_permalink_flag();
746 730 }
747 731 }
748 732
749 733 /**
@@ -1082,8 +1066,10 @@
1082 1066 'read_tutor_course',
1083 1067 'delete_tutor_course',
1084 1068 'delete_tutor_courses',
1085 1069 'edit_tutor_courses',
1070 + 'edit_others_tutor_courses',
1071 + 'read_private_tutor_courses',
1086 1072 'edit_tutor_courses',
1087 1073
1088 1074 'edit_tutor_lesson',
1089 1075 'read_tutor_lesson',
@@ -1089,8 +1075,10 @@
1089 1075 'read_tutor_lesson',
1090 1076 'delete_tutor_lesson',
1091 1077 'delete_tutor_lessons',
1092 1078 'edit_tutor_lessons',
1079 + 'edit_others_tutor_lessons',
1080 + 'read_private_tutor_lessons',
1093 1081 'edit_tutor_lessons',
1094 1082 'publish_tutor_lessons',
1095 1083
1096 1084 'edit_tutor_quiz',
@@ -1097,8 +1085,10 @@
1097 1085 'read_tutor_quiz',
1098 1086 'delete_tutor_quiz',
1099 1087 'delete_tutor_quizzes',
1100 1088 'edit_tutor_quizzes',
1089 + 'edit_others_tutor_quizzes',
1090 + 'read_private_tutor_quizzes',
1101 1091 'edit_tutor_quizzes',
1102 1092 'publish_tutor_quizzes',
1103 1093
1104 1094 'edit_tutor_question',
@@ -1105,9 +1095,11 @@
1105 1095 'read_tutor_question',
1106 1096 'delete_tutor_question',
1107 1097 'delete_tutor_questions',
1108 1098 'edit_tutor_questions',
1099 + 'edit_others_tutor_questions',
1109 1100 'publish_tutor_questions',
1101 + 'read_private_tutor_questions',
1110 1102 'edit_tutor_questions',
1111 1103 );
1112 1104
1113 1105 $instructor = get_role( $instructor_role );
@@ -1209,8 +1201,9 @@
1209 1201 'courses_per_page' => '12',
1210 1202 'course_permalink_base' => 'courses',
1211 1203 'lesson_permalink_base' => 'lessons',
1212 1204 'quiz_when_time_expires' => 'autosubmit',
1205 + 'quiz_attempts_allowed' => '10',
1213 1206 'quiz_grade_method' => 'highest_grade',
1214 1207 'enable_public_profile' => '1',
1215 1208 'email_to_students' =>
1216 1209 array(
@@ -1228,8 +1221,9 @@
1228 1221 'email_from_address' => get_option( 'admin_email' ),
1229 1222 'email_footer_text' => '',
1230 1223 'earning_admin_commission' => '20',
1231 1224 'earning_instructor_commission' => '80',
1225 + 'color_preset_type' => 'default',
1232 1226
1233 1227 // Default options for tutor ecommerce.
1234 1228 'monetize_by' => Ecommerce::MONETIZE_BY,
1235 1229 'currency_code' => 'USD',
@@ -1421,62 +1415,7 @@
1421 1415 $prefix = $wpdb->prefix;
1422 1416 //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
1423 1417 $wpdb->query( "DROP TABLE IF EXISTS {$prefix}tutor_quiz_attempts, {$prefix}tutor_quiz_attempt_answers, {$prefix}tutor_quiz_questions, {$prefix}tutor_quiz_question_answers, {$prefix}tutor_earnings, {$prefix}tutor_withdraws " );
1424 1418
1425 - }
1426 - }
1427 -
1428 - /**
1429 - * Update instructor capability
1430 - *
1431 - * Remove other author items permission
1432 - *
1433 - * @since 4.0.5
1434 - *
1435 - * @since 4.0.6 read_private_{items} permissions removed
1436 - */
1437 - public function update_instructor_capability() {
1438 - // Remove edit_others content cap from tutor_instructor role.
1439 - $is_removed_edit_other_items_permissions = get_option( 'tutor_removed_edit_other_items_permission', false );
1440 - $is_removed_private_items_permissions = get_option( 'tutor_removed_read_private_items_permission', false );
1441 -
1442 - $role = get_role( tutor()->instructor_role );
1443 - if ( ! $is_removed_edit_other_items_permissions ) {
1444 - $role = get_role( tutor()->instructor_role );
1445 -
1446 - $caps_to_be_removed = array(
1447 - 'edit_others_tutor_courses',
1448 - 'edit_others_tutor_lessons',
1449 - 'edit_others_tutor_quizzes',
1450 - 'edit_others_tutor_questions',
1451 - 'edit_others_tutor_assignments',
1452 - );
1453 -
1454 - foreach ( $caps_to_be_removed as $cap ) {
1455 - if ( $role->has_cap( $cap ) ) {
1456 - $role->remove_cap( $cap );
1457 - }
1458 - }
1459 -
1460 - update_option( 'tutor_removed_edit_other_items_permission', true, false );
1461 - }
1462 -
1463 - // Removed private items permission @since 4.0.6.
1464 - if ( ! $is_removed_private_items_permissions ) {
1465 - $caps_to_be_removed = array(
1466 - 'read_private_tutor_courses',
1467 - 'read_private_tutor_lessons',
1468 - 'read_private_tutor_quizzes',
1469 - 'read_private_tutor_assignments',
1470 - 'read_private_tutor_questions',
1471 - );
1472 -
1473 - foreach ( $caps_to_be_removed as $cap ) {
1474 - if ( $role->has_cap( $cap ) ) {
1475 - $role->remove_cap( $cap );
1476 - }
1477 - }
1478 -
1479 - update_option( 'tutor_removed_read_private_items_permission', true, false );
1480 1419 }
1481 1420 }
1482 1421 }