-
Notifications
You must be signed in to change notification settings - Fork 63
/
tutor.php
185 lines (165 loc) · 5.32 KB
/
tutor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/**
* Plugin Name: Tutor LMS
* Plugin URI: https://www.themeum.com/product/tutor-lms/
* Description: Tutor is a complete solution for creating a Learning Management System in WordPress way. It can help you to create small to large scale online education site very conveniently. Power features like report, certificate, course preview, private file sharing make Tutor a robust plugin for any educational institutes.
* Author: Themeum
* Version: 3.0.1
* Author URI: https://themeum.com
* Requires PHP: 7.4
* Requires at least: 5.3
* Tested up to: 6.7
* License: GPLv2 or later
* Text Domain: tutor
*
* @package Tutor
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
/**
* Defined the tutor main file
*/
define( 'TUTOR_VERSION', '3.0.1' );
define( 'TUTOR_FILE', __FILE__ );
/**
* Load tutor text domain for translation
*/
add_action(
'init',
function () {
load_plugin_textdomain( 'tutor', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
);
if ( ! function_exists( 'tutor' ) ) {
/**
* Tutor helper function.
*
* @since 1.0.0
*
* @return object
*/
function tutor() {
if ( isset( $GLOBALS['tutor_plugin_info'] ) ) {
return $GLOBALS['tutor_plugin_info'];
}
$path = plugin_dir_path( TUTOR_FILE );
$has_pro = defined( 'TUTOR_PRO_VERSION' );
// Prepare the basepath.
$home_url = get_home_url();
$parsed = parse_url( $home_url );
$base_path = ( is_array( $parsed ) && isset( $parsed['path'] ) ) ? $parsed['path'] : '/';
$base_path = rtrim( $base_path, '/' ) . '/';
// Get current URL.
$current_url = trailingslashit( $home_url ) . substr( $_SERVER['REQUEST_URI'], strlen( $base_path ) );//phpcs:ignore
$info = array(
'path' => $path,
'url' => plugin_dir_url( TUTOR_FILE ),
'icon_dir' => plugin_dir_url( TUTOR_FILE ) . 'assets/images/images-v2/icons/',
'v2_img_dir' => plugin_dir_url( TUTOR_FILE ) . 'assets/images/images-v2/',
'current_url' => $current_url,
'basename' => plugin_basename( TUTOR_FILE ),
'basepath' => $base_path,
'version' => TUTOR_VERSION,
'nonce_action' => 'tutor_nonce_action',
'nonce' => '_tutor_nonce',
'course_post_type' => apply_filters( 'tutor_course_post_type', 'courses' ),
'bundle_post_type' => apply_filters( 'tutor_bundle_post_type', 'course-bundle' ),
'lesson_post_type' => apply_filters( 'tutor_lesson_post_type', 'lesson' ),
'instructor_role' => apply_filters( 'tutor_instructor_role', 'tutor_instructor' ),
'instructor_role_name' => apply_filters( 'tutor_instructor_role_name', __( 'Tutor Instructor', 'tutor' ) ),
'template_path' => apply_filters( 'tutor_template_path', 'tutor/' ),
'has_pro' => apply_filters( 'tutor_has_pro', $has_pro ),
// @since v2.0.6.
'topics_post_type' => apply_filters( 'tutor_topics_post_type', 'topics' ),
'announcement_post_type' => apply_filters( 'tutor_announcement_post_type', 'tutor_announcements' ),
'assignment_post_type' => apply_filters( 'tutor_assignment_post_type', 'tutor_assignments' ),
'enrollment_post_type' => apply_filters( 'tutor_enrollment_post_type', 'tutor_enrolled' ),
'quiz_post_type' => apply_filters( 'tutor_quiz_post_type', 'tutor_quiz' ),
'zoom_post_type' => apply_filters( 'tutor_zoom_meeting_post_type', 'tutor_zoom_meeting' ),
'meet_post_type' => apply_filters( 'tutor_google_meeting_post_type', 'tutor-google-meet' ),
);
$GLOBALS['tutor_plugin_info'] = (object) $info;
return $GLOBALS['tutor_plugin_info'];
}
}
if ( ! class_exists( 'Tutor' ) ) {
include_once 'classes/Tutor.php';
}
/**
* Get all helper functions/methods
*
* @return \TUTOR\Utils
*/
if ( ! class_exists( '\TUTOR\Utils' ) ) {
include_once 'classes/Utils.php';
}
if ( ! function_exists( 'tutor_utils' ) ) {
/**
* Access tutor utils functions
*
* @since 1.0.0
*
* @return \TUTOR\Utils
*/
function tutor_utils() {
if ( ! isset( $GLOBALS['tutor_utils_object'] ) ) {
// Use runtime cache.
$GLOBALS['tutor_utils_object'] = new \TUTOR\Utils();
}
return $GLOBALS['tutor_utils_object'];
}
}
if ( ! function_exists( 'tutils' ) ) {
/**
* Alis of tutor_utils()
*
* @since 1.3.4
*
* @return \TUTOR\Utils
*/
function tutils() {
return tutor_utils();
}
}
/**
* Do some task during activation
*
* @since 1.5.2
*
* @since 2.6.2
*
* Uninstall hook registered
*/
register_activation_hook( TUTOR_FILE, array( '\TUTOR\Tutor', 'tutor_activate' ) );
register_deactivation_hook( TUTOR_FILE, array( '\TUTOR\Tutor', 'tutor_deactivation' ) );
register_uninstall_hook( TUTOR_FILE, array( '\TUTOR\Tutor', 'tutor_uninstall' ) );
if ( ! function_exists( 'tutor_lms' ) ) {
/**
* Run main instance of the Tutor
*
* @since 1.2.0
*
* @return null|\TUTOR\Tutor
*/
function tutor_lms() {
return \TUTOR\Tutor::instance();
}
}
if ( ! function_exists( 'str_contains' ) ) {
/**
* String helper for str contains
*
* @since 1.0.0
*
* @param string $haystack haystack.
* @param string $needle needle.
*
* @return bool
*/
function str_contains( string $haystack, string $needle ) {
return empty( $needle ) || strpos( $haystack, $needle ) !== false;
}
}
$GLOBALS['tutor'] = tutor_lms();