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.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 / init.php
tutor / classes Last commit date
Addons.php 7 years ago Admin.php 7 years ago Ajax.php 7 years ago Assets.php 7 years ago Course.php 7 years ago Gutenberg.php 7 years ago Instructor.php 7 years ago Instructors_List.php 7 years ago Lesson.php 7 years ago Options.php 7 years ago Post_types.php 7 years ago Q_and_A.php 7 years ago Question.php 7 years ago Question_Answers_List.php 7 years ago Quiz.php 7 years ago Quiz_Attempts_List.php 7 years ago Rewrite_Rules.php 7 years ago Shortcode.php 7 years ago Student.php 7 years ago Students_List.php 7 years ago Template.php 7 years ago Theme_Compatibility.php 7 years ago Tools.php 7 years ago Tutor_Base.php 7 years ago Tutor_List_Table.php 7 years ago User.php 7 years ago Utils.php 7 years ago Video_Stream.php 7 years ago init.php 7 years ago
init.php
304 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) )
5 exit;
6
7 class init{
8 public $version = TUTOR_VERSION;
9 public $path;
10 public $url;
11 public $basename;
12
13 //Components
14 public $utils;
15 public $admin;
16 public $ajax;
17 public $options;
18 public $shortcode;
19
20 private $post_types;
21 private $assets;
22 private $course;
23 private $lesson;
24 private $rewrite_rules;
25 private $template;
26 private $instructor;
27 private $student;
28 private $q_and_a;
29 private $quiz;
30 private $question;
31 private $tools;
32 private $user;
33 private $theme_compatibility;
34 private $gutenberg;
35
36 function __construct() {
37
38 $this->path = plugin_dir_path(TUTOR_FILE);
39 $this->url = plugin_dir_url(TUTOR_FILE);
40 $this->basename = plugin_basename(TUTOR_FILE);
41
42 /**
43 * Include Files
44 */
45 add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 );
46
47 /**
48 * Loading Autoloader
49 */
50
51 spl_autoload_register(array($this, 'loader'));
52
53 do_action('tutor_before_load');
54
55 $this->post_types = new Post_types();
56 $this->assets = new Assets();
57 $this->admin = new Admin();
58 $this->ajax = new Ajax();
59 $this->options = new Options();
60 $this->shortcode = new Shortcode();
61 $this->course = new Course();
62 $this->lesson = new Lesson();
63 $this->rewrite_rules = new Rewrite_Rules();
64 $this->template = new Template();
65 $this->instructor = new Instructor();
66 $this->student = new Student();
67 $this->q_and_a = new Q_and_A();
68 $this->quiz = new Quiz();
69 $this->question = new Question();
70 $this->tools = new Tools();
71 $this->user = new User();
72 $this->theme_compatibility = new Theme_Compatibility();
73 $this->gutenberg = new Gutenberg();
74
75 do_action('tutor_loaded');
76 }
77 /**
78 * @param $className
79 *
80 * Auto Load class and the files
81 */
82 private function loader($className) {
83 if ( ! class_exists($className)){
84 $className = preg_replace(
85 array('/([a-z])([A-Z])/', '/\\\/'),
86 array('$1-$2', DIRECTORY_SEPARATOR),
87 $className
88 );
89
90 $className = str_replace('TUTOR/', 'classes/', $className);
91 $file_name = $this->path.$className.'.php';
92
93 if (file_exists($file_name) && is_readable( $file_name ) ) {
94 require_once $file_name;
95 }
96 }
97 }
98
99 public function include_template_functions(){
100 include tutor()->path.'includes/tutor-template-functions.php';
101 include tutor()->path.'includes/tutor-template-hook.php';
102 }
103
104 //Run the TUTOR right now
105 public function run(){
106 do_action('tutor_before_run');
107
108 register_activation_hook( TUTOR_FILE, array( $this, 'tutor_activate' ) );
109 register_deactivation_hook(TUTOR_FILE, array($this, 'tutor_deactivation'));
110
111 do_action('tutor_after_run');
112 }
113
114 /**
115 * Do some task during plugin activation
116 */
117 public function tutor_activate(){
118 $version = get_option('tutor_version');
119 //Save Option
120 if ( ! $version){
121 $options = self::default_options();
122 update_option('tutor_option', $options);
123
124 //Rewrite Flush
125 update_option('required_rewrite_flush', time());
126 self::manage_tutor_roles_and_permissions();
127
128 self::save_data();//Save initial Page
129 update_option('tutor_version', TUTOR_VERSION);
130 }
131
132 //Set Schedule
133 if (! wp_next_scheduled ( 'tutor_once_in_day_run_schedule' )) {
134 wp_schedule_event(time(), 'twicedaily', 'tutor_once_in_day_run_schedule');
135 }
136 }
137
138 //Run task on deactivation
139 public function tutor_deactivation() {
140 wp_clear_scheduled_hook('tutor_once_in_day_run_schedule');
141 }
142
143
144 public static function manage_tutor_roles_and_permissions(){
145 /**
146 * Add role for instructor
147 */
148 $instructor_role = tutor()->instructor_role;
149
150 remove_role($instructor_role);
151 add_role( $instructor_role, __('Tutor Instructor', 'tutor'), array() );
152
153 $custom_post_type_permission = array(
154 //Manage Instructor
155 'manage_tutor_instructor',
156
157 //Tutor Posts Type Permission
158 'edit_tutor_course',
159 'read_tutor_course',
160 'delete_tutor_course',
161 'delete_tutor_courses',
162 'edit_tutor_courses',
163 'edit_others_tutor_courses',
164 'read_private_tutor_courses',
165 'edit_tutor_courses',
166
167 'edit_tutor_lesson',
168 'read_tutor_lesson',
169 'delete_tutor_lesson',
170 'delete_tutor_lessons',
171 'edit_tutor_lessons',
172 'edit_others_tutor_lessons',
173 'read_private_tutor_lessons',
174 'edit_tutor_lessons',
175 'publish_tutor_lessons',
176
177 'edit_tutor_quiz',
178 'read_tutor_quiz',
179 'delete_tutor_quiz',
180 'delete_tutor_quizzes',
181 'edit_tutor_quizzes',
182 'edit_others_tutor_quizzes',
183 'read_private_tutor_quizzes',
184 'edit_tutor_quizzes',
185 'publish_tutor_quizzes',
186
187 'edit_tutor_question',
188 'read_tutor_question',
189 'delete_tutor_question',
190 'delete_tutor_questions',
191 'edit_tutor_questions',
192 'edit_others_tutor_questions',
193 'publish_tutor_questions',
194 'read_private_tutor_questions',
195 'edit_tutor_questions',
196 );
197
198 $instructor = get_role( $instructor_role );
199 if ( $instructor ) {
200 $instructor_cap = array (
201 'edit_posts',
202 'read',
203 'upload_files',
204 );
205
206 $instructor_cap = array_merge($instructor_cap, $custom_post_type_permission);
207
208 $can_publish_course = (bool) tutor_utils()->get_option('instructor_can_publish_course');
209 if ($can_publish_course){
210 $instructor_cap[] = 'publish_tutor_courses';
211 }
212
213 foreach ($instructor_cap as $cap){
214 $instructor->add_cap( $cap );
215 }
216 }
217
218 $administrator = get_role( 'administrator' );
219 if ( $administrator ) {
220 $administrator_cap = array (
221 'manage_tutor',
222 );
223 $administrator_cap = array_merge($administrator_cap, $custom_post_type_permission);
224 $administrator_cap[] = 'publish_tutor_courses';
225
226 foreach ($administrator_cap as $cap){
227 $administrator->add_cap( $cap );
228 }
229 }
230 }
231
232 /**
233 * Save data like page
234 */
235 public static function save_data(){
236 $student_dashboard_args = array(
237 'post_title' => __('Student Dashboard', 'tutor'),
238 'post_content' => '[tutor_student_dashboard]',
239 'post_type' => 'page',
240 'post_status' => 'publish',
241 );
242 $student_dashboard_page_id = wp_insert_post( $student_dashboard_args );
243 tutor_utils()->update_option('student_dashboard', $student_dashboard_page_id);
244
245 $student_registration_args = array(
246 'post_title' => __('Student Registration', 'tutor'),
247 'post_content' => '[tutor_student_registration_form]',
248 'post_type' => 'page',
249 'post_status' => 'publish',
250 );
251 $student_register_page_id = wp_insert_post( $student_registration_args );
252 tutor_utils()->update_option('student_register_page', $student_register_page_id);
253
254 $instructor_registration_args = array(
255 'post_title' => __('Instructor Registration', 'tutor'),
256 'post_content' => '[tutor_instructor_registration_form]',
257 'post_type' => 'page',
258 'post_status' => 'publish',
259 );
260 $instructor_registration_id = wp_insert_post( $instructor_registration_args );
261 tutor_utils()->update_option('instructor_register_page', $instructor_registration_id);
262 }
263
264 public static function default_options(){
265 $options = array (
266 'load_tutor_css' => '1',
267 'load_tutor_js' => '1',
268 'course_allow_upload_private_files' => '1',
269 'display_course_instructors' => '1',
270 'enable_q_and_a_on_course' => '1',
271 'courses_col_per_row' => '3',
272 'courses_per_page' => '3',
273 'lesson_permalink_base' => 'lesson',
274 'quiz_time_limit' =>
275 array (
276 'value' => '0',
277 'time' => 'minutes',
278 ),
279 'quiz_when_time_expires' => 'autosubmit',
280 'quiz_attempts_allowed' => '10',
281 'quiz_grade_method' => 'highest_grade',
282 'enable_public_profile' => '1',
283 'email_to_students' =>
284 array (
285 'quiz_completed' => '1',
286 'completed_course' => '1',
287 ),
288 'email_to_instructors' =>
289 array (
290 'a_student_enrolled_in_course' => '1',
291 'a_student_completed_course' => '1',
292 'a_student_completed_lesson' => '1',
293 'a_student_placed_question' => '1',
294 ),
295 'email_from_name' => get_option('blogname'),
296 'email_from_address' => get_option('admin_email'),
297 'email_footer_text' => '',
298 'enable_course_sell_by_woocommerce' => '1',
299 );
300 return $options;
301 }
302
303
304 }