PluginProbe
Tutor LMS – eLearning and online course solution / 2.2.1
Tutor LMS – eLearning and online course solution v2.2.1
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/Admin.php +140 -476 4.0.22.2.1 View file →
@@ -9,15 +9,13 @@
9 9 */
10 10
11 11 namespace TUTOR;
12 12
13 -defined( 'ABSPATH' ) || exit;
13 +use TUTOR\Input;
14 14
15 -use Tutor\Ecommerce\OrderController;
16 -use Tutor\Helpers\HttpHelper;
17 -use TUTOR\Input;
18 -use Tutor\Models\CourseModel;
19 -use Tutor\Traits\JsonResponse;
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit;
17 +}
20 18
21 19 /**
22 20 * Admin Class
23 21 *
@@ -23,20 +21,15 @@
23 21 *
24 22 * @since 1.0.0
25 23 */
26 24 class Admin {
27 - use JsonResponse;
28 -
29 25 /**
30 26 * Constructor
31 27 *
32 28 * @since 1.0.0
33 - *
34 29 * @return void
35 30 */
36 31 public function __construct() {
37 - add_action( 'admin_notices', array( $this, 'show_unstable_version_admin_notice' ) );
38 -
39 32 add_action( 'admin_menu', array( $this, 'register_menu' ) );
40 33 // Force activate menu for necessary.
41 34 add_filter( 'parent_file', array( $this, 'parent_menu_active' ) );
42 35 add_filter( 'submenu_file', array( $this, 'submenu_file_active' ), 10, 2 );
@@ -41,11 +34,11 @@
41 34 add_filter( 'parent_file', array( $this, 'parent_menu_active' ) );
42 35 add_filter( 'submenu_file', array( $this, 'submenu_file_active' ), 10, 2 );
43 36
44 37 add_action( 'admin_init', array( $this, 'filter_posts_for_instructors' ) );
45 - add_action( 'admin_init', array( $this, 'redirect_to_welcome_page' ) );
46 38 add_action( 'load-post.php', array( $this, 'check_if_current_users_post' ) );
47 39
40 + add_action( 'admin_action_uninstall_tutor_and_erase', array( $this, 'erase_tutor_data' ) );
48 41 add_filter( 'plugin_action_links_' . plugin_basename( TUTOR_FILE ), array( $this, 'plugin_action_links' ) );
49 42
50 43 // Plugin Row Meta.
51 44 add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
@@ -56,151 +49,14 @@
56 49 add_action( 'widgets_init', array( $this, 'register_course_widget' ) );
57 50
58 51 // Handle flash toast message for redirect_to util helper.
59 52 add_action( 'admin_head', array( new Utils(), 'handle_flash_message' ), 999 );
60 -
61 - add_action( 'admin_bar_menu', array( $this, 'add_toolbar_items' ), 100 );
62 -
63 - add_action( 'wp_ajax_tutor_do_not_show_feature_page', array( $this, 'handle_do_not_show_feature_page' ) );
64 -
65 - add_action( 'upgrader_process_complete', array( $this, 'set_permalink_flag_on_upgrade' ), 10, 2 );
66 -
67 - add_action( 'admin_notices', array( $this, 'show_offer_notice' ) );
68 - add_action( 'wp_ajax_tutor_dismiss_offer_notice', array( $this, 'ajax_dismiss_offer_notice' ) );
69 53 }
70 54
71 55 /**
72 - * Flush Tutor permalink rewrite rules after updates.
73 - *
74 - * @since 4.0.0
75 - *
76 - * @param mixed $upgrader_object Upgrader instance.
77 - * @param array $options Extra arguments passed to the hook.
78 - *
79 - * @return void
80 - */
81 - public function set_permalink_flag_on_upgrade( $upgrader_object, $options ) {
82 - Permalink::set_permalink_reset_flag( $upgrader_object, $options );
83 - }
84 -
85 - /**
86 - * Check offer notice is dismissed.
87 - *
88 - * @since 4.0.0
89 - *
90 - * @return bool
91 - */
92 - private function is_offer_notice_dismissed() {
93 - return '4.0.0' === get_transient( 'tutor_offer_notice_dismissed' );
94 - }
95 -
96 - /**
97 - * Show offer notice
98 - *
99 - * @since 4.0.0
100 - *
101 - * @return void
102 - */
103 - public function show_offer_notice() {
104 - if ( ! User::is_admin() || Input::has( 'welcome', Input::GET_REQUEST ) ) {
105 - return;
106 - }
107 -
108 - $is_free_user = ! tutor()->has_pro;
109 - $cta_label = __( 'Claim 30% OFF', 'tutor' );
110 - $cta_link = 'https://tutorlms.com/pricing/?utm_source=tutor-plugin&utm_medium=notice&utm_campaign=tutor-lms-pro-offer';
111 -
112 - $now = new \DateTimeImmutable( 'now', wp_timezone() );
113 - $expiration_dt = '2026-07-15 23:59:59';
114 - $expiration = new \DateTimeImmutable( $expiration_dt, wp_timezone() );
115 -
116 - $remaining = max( 0, $expiration->getTimestamp() - $now->getTimestamp() );
117 -
118 - $days = floor( $remaining / DAY_IN_SECONDS );
119 - $hours = floor( ( $remaining % DAY_IN_SECONDS ) / HOUR_IN_SECONDS );
120 - $minutes = floor( ( $remaining % HOUR_IN_SECONDS ) / MINUTE_IN_SECONDS );
121 - $seconds = $remaining % MINUTE_IN_SECONDS;
122 -
123 - $expire_in = sprintf(
124 - '%dd:%02dh:%02d:%02d',
125 - $days,
126 - $hours,
127 - $minutes,
128 - $seconds
129 - );
130 -
131 - if ( $is_free_user && $remaining > 0 && ! self::is_offer_notice_dismissed() ) {
132 - ?>
133 - <div class="tutor-offer-notice">
134 - <div class="tutor-offer-notice-wrapper">
135 - <div class="tutor-offer-notice-left">
136 - <div data-subheader><?php esc_html_e( '4.0 launch offer', 'tutor' ); ?></div>
137 - <div data-header><?php esc_html_e( '30% OFF', 'tutor' ); ?></div>
138 - <div data-subtext><?php esc_html_e( 'on all annual plans', 'tutor' ); ?></div>
139 - </div>
140 - <div class="tutor-offer-notice-right">
141 - <div class="tutor-offer-notice-text"><?php esc_html_e( 'Offer ends by', 'tutor' ); ?> <span class="tutor-offer-notice-timer" data-expiry="<?php echo esc_attr( $expiration->getTimestamp() ); ?>"><?php echo esc_html( $expire_in ); ?></span></div>
142 - <a class="tutor-offer-notice-cta" href="<?php echo esc_url( $cta_link ); ?>" target="_blank">
143 - <?php echo esc_html( $cta_label ); ?>
144 - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="#fff" d="M13.938 6.937a.55.55 0 0 0-.786 0 .555.555 0 0 0 0 .778l3.338 3.34H5.243a.55.55 0 0 0-.55.551c0 .305.242.558.55.558h11.246l-3.337 3.334a.563.563 0 0 0 0 .785.55.55 0 0 0 .786 0L18.217 12a.543.543 0 0 0 0-.78z"/></svg>
145 - </a>
146 - </div>
147 - </div>
148 - <button type="button" class="tutor-offer-notice-dismiss"><span class="tutor-icon-times"></span></button>
149 - </div>
150 - <?php
151 - }
152 - }
153 -
154 - /**
155 - * Dismiss offer notice.
156 - *
157 - * @since 4.0.0
158 - *
159 - * @return void JSON response.
160 - */
161 - public function ajax_dismiss_offer_notice() {
162 - if ( ! User::is_admin() ) {
163 - $this->response_bad_request( tutor_utils()->error_message() );
164 - }
165 -
166 - if ( self::is_offer_notice_dismissed() ) {
167 - $this->response_bad_request( __( 'You have already dismissed the offer notice.', 'tutor' ) );
168 - }
169 -
170 - // Set expiry until next day.
171 - $expiration = strtotime( 'tomorrow' ) - time();
172 - set_transient( 'tutor_offer_notice_dismissed', '4.0.0', $expiration );
173 - $this->json_response( __( 'Notice dismissed', 'tutor' ) );
174 - }
175 -
176 - /**
177 - * Show unstable version notice.
178 - *
179 - * @since 3.0.0
180 - *
181 - * @return void
182 - */
183 - public function show_unstable_version_admin_notice() {
184 - $version = tutor_utils()->extract_version_details( TUTOR_VERSION );
185 - if ( ! $version->is_stable ) {
186 - /* translators: %s: version name */
187 - $message = sprintf( __( 'You\'re currently using Tutor LMS %s. To ensure stability, please do not use it on a live site.', 'tutor' ), '<strong>' . $version->version . '</strong>' );
188 - ?>
189 - <div class="notice notice-warning">
190 - <p><strong><?php esc_html_e( 'Warning!', 'tutor' ); ?></strong></p>
191 - <p><?php echo wp_kses_post( $message ); ?></p>
192 - </div>
193 - <?php
194 - }
195 - }
196 -
197 - /**
198 56 * Register admin menus
199 57 *
200 58 * @since 1.0.0
201 - * @since 3.8.0 re-organize admin menu.
202 - *
203 59 * @return void
204 60 */
205 61 public function register_menu() {
206 62 $has_pro = tutor()->has_pro;
@@ -214,9 +70,9 @@
214 70 $course_post_type = tutor()->course_post_type;
215 71
216 72 $pro_text = '';
217 73 if ( $has_pro ) {
218 - $pro_text = ' ' . apply_filters( 'tutor_pro_flag', __( 'Pro', 'tutor' ) );
74 + $pro_text = ' ' . __( 'Pro', 'tutor' );
219 75 }
220 76
221 77 $enable_course_marketplace = (bool) tutor_utils()->get_option( 'enable_course_marketplace' );
222 78
@@ -239,210 +95,60 @@
239 95 $icon_base64_uri,
240 96 $menu_position
241 97 );
242 98
243 - new WhatsNew();
99 + // Added @since v2.0.0.
100 + add_submenu_page( 'tutor', __( 'Courses', 'tutor' ), __( 'Courses', 'tutor' ), 'manage_tutor_instructor', 'tutor', array( $this, 'tutor_course_list' ) );
244 101
245 - $admin_menu = apply_filters(
246 - 'tutor_admin_menu',
247 - array(
248 - 'group_one' => array(
249 - 'courses' => array(
250 - 'parent_slug' => 'tutor',
251 - 'page_title' => __( 'Courses', 'tutor' ),
252 - 'menu_title' => __( 'Courses', 'tutor' ),
253 - 'capability' => 'manage_tutor_instructor',
254 - 'menu_slug' => 'tutor',
255 - 'callback' => array( $this, 'tutor_course_list' ),
256 - ),
257 - 'content_bank' => null,
258 - 'course_builder' => array(
259 - 'parent_slug' => 'tutor',
260 - 'page_title' => __( 'Course Builder', 'tutor' ),
261 - 'menu_title' => '<span class="tutor-create-course">Create Course</span>',
262 - 'capability' => 'manage_tutor_instructor',
263 - 'menu_slug' => 'create-course',
264 - 'callback' => array( new Course( false ), 'load_course_builder' ),
265 - ),
266 - 'categories' => array(
267 - 'parent_slug' => 'tutor',
268 - 'page_title' => __( 'Categories', 'tutor' ),
269 - 'menu_title' => __( 'Categories', 'tutor' ),
270 - 'capability' => 'manage_tutor',
271 - 'menu_slug' => 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type,
272 - ),
273 - 'tags' => array(
274 - 'parent_slug' => 'tutor',
275 - 'page_title' => __( 'Tags', 'tutor' ),
276 - 'menu_title' => __( 'Tags', 'tutor' ),
277 - 'capability' => 'manage_tutor',
278 - 'menu_slug' => 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type,
279 - ),
280 - ),
281 - 'group_two' => array(
282 - 'orders' => null,
283 - 'subscriptions' => null,
284 - 'coupons' => null,
285 - 'students' => array(
286 - 'parent_slug' => 'tutor',
287 - 'page_title' => __( 'Students', 'tutor' ),
288 - 'menu_title' => __( 'Students', 'tutor' ),
289 - 'capability' => 'manage_tutor',
290 - 'menu_slug' => Students_List::STUDENTS_LIST_PAGE,
291 - 'callback' => array( $this, 'tutor_students' ),
102 + // Extendable action hook @since 2.2.0.
103 + do_action( 'tutor_after_courses_menu' );
292 104
293 - ),
294 - 'announcements' => array(
295 - 'parent_slug' => 'tutor',
296 - 'page_title' => __( 'Announcements', 'tutor' ),
297 - 'menu_title' => __( 'Announcements', 'tutor' ),
298 - 'capability' => 'manage_tutor_instructor',
299 - 'menu_slug' => 'tutor_announcements',
300 - 'callback' => array( $this, 'tutor_announcements' ),
105 + if ( ! $has_pro ) {
106 + add_submenu_page( 'tutor', __( 'Course Bundles', 'tutor' ), __( 'Course Bundle <span class="tutor-badge-new">New</span>', 'tutor' ), 'manage_tutor', 'course-bundle', array( $this, 'course_bundle_page' ) );
107 + }
301 108
302 - ),
303 - 'assignments' => null,
304 - 'quiz_attempts' => array(
305 - 'parent_slug' => 'tutor',
306 - 'page_title' => __( 'Quiz Attempts', 'tutor' ),
307 - 'menu_title' => __( 'Quiz Attempts', 'tutor' ),
308 - 'capability' => 'manage_tutor_instructor',
309 - 'menu_slug' => Quiz_Attempts_List::QUIZ_ATTEMPT_PAGE,
310 - 'callback' => array( $this, 'quiz_attempts' ),
311 - ),
312 - 'q_and_a' => array(
313 - 'parent_slug' => 'tutor',
314 - 'page_title' => __( 'Q&A', 'tutor' ),
315 - 'menu_title' => __( 'Q&A ', 'tutor' ) . $unanswered_bubble,
316 - 'capability' => 'manage_tutor_instructor',
317 - 'menu_slug' => Question_Answers_List::QUESTION_ANSWER_PAGE,
318 - 'callback' => array( $this, 'question_answer' ),
319 - ),
320 - 'enrollments' => null,
321 - 'reports' => null,
322 - 'gradebook' => null,
323 - 'instructors' => $enable_course_marketplace ? array(
324 - 'parent_slug' => 'tutor',
325 - 'page_title' => __( 'Instructors', 'tutor' ),
326 - 'menu_title' => __( 'Instructors', 'tutor' ),
327 - 'capability' => 'manage_tutor',
328 - 'menu_slug' => Instructors_List::INSTRUCTOR_LIST_PAGE,
329 - 'callback' => array( $this, 'tutor_instructors' ),
330 - ) : null,
331 - 'withdraw_requests' => $enable_course_marketplace ? array(
332 - 'parent_slug' => 'tutor',
333 - 'page_title' => __( 'Withdraw Requests', 'tutor' ),
334 - 'menu_title' => __( 'Withdraw Requests', 'tutor' ),
335 - 'capability' => 'manage_tutor',
336 - 'menu_slug' => Withdraw_Requests_List::WITHDRAW_REQUEST_LIST_PAGE,
337 - 'callback' => array( $this, 'withdraw_requests' ),
338 - ) : null,
339 - ),
340 - 'group_three' => array(
341 - 'google_classroom' => null,
342 - 'zoom' => null,
343 - 'google_meet' => null,
344 - 'h5p' => null,
345 - 'addons' => array(
346 - 'parent_slug' => 'tutor',
347 - 'page_title' => __( 'Addons', 'tutor' ),
348 - 'menu_title' => __( 'Addons', 'tutor' ),
349 - 'capability' => 'manage_tutor',
350 - 'menu_slug' => 'tutor-addons',
351 - 'callback' => array( $this, 'enable_disable_addons' ),
352 - ),
353 - 'tools' => array(
354 - 'parent_slug' => 'tutor',
355 - 'page_title' => __( 'Tools', 'tutor' ),
356 - 'menu_title' => __( 'Tools', 'tutor' ),
357 - 'capability' => 'manage_tutor',
358 - 'menu_slug' => 'tutor-tools',
359 - 'callback' => array( new Tools_V2(), 'load_tools_page' ),
360 - ),
361 - 'settings' => array(
362 - 'parent_slug' => 'tutor',
363 - 'page_title' => __( 'Settings', 'tutor' ),
364 - 'menu_title' => __( 'Settings', 'tutor' ),
365 - 'capability' => 'manage_tutor',
366 - 'menu_slug' => 'tutor_settings',
367 - 'callback' => array( new Options_V2(), 'load_settings_page' ),
368 - ),
369 - 'license' => null,
370 - 'whats_new' => null,
371 - 'upgrade_to_pro' => $has_pro ? null : array(
372 - 'parent_slug' => 'tutor',
373 - 'page_title' => __( 'Upgrade to Pro', 'tutor' ),
374 - 'menu_title' => sprintf( '<span class="tutor-get-pro-text">%s</span>', __( 'Upgrade to Pro', 'tutor' ) ),
375 - 'capability' => 'manage_options',
376 - 'menu_slug' => 'tutor-get-pro',
377 - 'callback' => array( $this, 'tutor_get_pro' ),
378 - ),
379 - ),
380 - )
381 - );
109 + add_submenu_page( 'tutor', __( 'Categories', 'tutor' ), __( 'Categories', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type, null );
382 110
383 - foreach ( $admin_menu as $group => $menu ) {
384 - foreach ( $menu as $name => $args ) {
385 - if ( empty( $args ) ) {
386 - continue;
387 - }
111 + add_submenu_page( 'tutor', __( 'Tags', 'tutor' ), __( 'Tags', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type, null );
388 112
389 - // Backward compatibility hook.
390 - if ( 'addons' === $name ) {
391 - do_action( 'tutor_admin_register' );
392 - }
113 + add_submenu_page( 'tutor', __( 'Students', 'tutor' ), __( 'Students', 'tutor' ), 'manage_tutor', Students_List::STUDENTS_LIST_PAGE, array( $this, 'tutor_students' ) );
393 114
394 - // Backward compatibility hook.
395 - do_action( "tutor_before_{$name}_admin_menu" );
115 + if ( $enable_course_marketplace ) {
116 + add_submenu_page( 'tutor', __( 'Instructors', 'tutor' ), __( 'Instructors', 'tutor' ), 'manage_tutor', Instructors_List::INSTRUCTOR_LIST_PAGE, array( $this, 'tutor_instructors' ) );
117 + }
396 118
397 - do_action( "tutor_before_{$name}_menu" );
398 - add_submenu_page( $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['callback'] ?? '', $args['position'] ?? null );
119 + add_submenu_page( 'tutor', __( 'Announcements', 'tutor' ), __( 'Announcements', 'tutor' ), 'manage_tutor_instructor', 'tutor_announcements', array( $this, 'tutor_announcements' ) );
399 120
400 - // Backward compatibility hook.
401 - do_action( "tutor_after_{$name}_menu" );
121 + add_submenu_page( 'tutor', __( 'Q & A', 'tutor' ), __( 'Q & A ', 'tutor' ) . $unanswered_bubble, 'manage_tutor_instructor', Question_Answers_List::QUESTION_ANSWER_PAGE, array( $this, 'question_answer' ) );
402 122
403 - do_action( "tutor_after_{$name}_admin_menu" );
404 - }
123 + add_submenu_page( 'tutor', __( 'Quiz Attempts', 'tutor' ), __( 'Quiz Attempts', 'tutor' ), 'manage_tutor_instructor', Quiz_Attempts_List::QUIZ_ATTEMPT_PAGE, array( $this, 'quiz_attempts' ) );
405 124
406 - if ( 'group_three' !== $group ) {
407 - if ( 'group_two' === $group && ! current_user_can( 'manage_options' ) ) {
408 - continue;
409 - }
125 + if ( $enable_course_marketplace ) {
126 + add_submenu_page( 'tutor', __( 'Withdraw Requests', 'tutor' ), __( 'Withdraw Requests', 'tutor' ), 'manage_tutor', Withdraw_Requests_List::WITHDRAW_REQUEST_LIST_PAGE, array( $this, 'withdraw_requests' ) );
127 + }
410 128
411 - add_submenu_page( 'tutor', '', '<span class="tutor-admin-menu-separator"></span>', 'manage_tutor_instructor', '#' );
412 - }
413 - }
414 - }
129 + add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), __( 'Add-ons', 'tutor' ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) );
415 130
416 - /**
417 - * Welcome page opt-out
418 - *
419 - * @since 3.0.0
420 - */
421 - public function handle_do_not_show_feature_page() {
422 - tutor_utils()->check_nonce();
131 + do_action( 'tutor_admin_register' );
423 132
424 - if ( ! User::is_admin() ) {
425 - $this->json_response(
426 - tutor_utils()->error_message(),
427 - null,
428 - HttpHelper::STATUS_BAD_REQUEST
429 - );
133 + add_submenu_page( 'tutor', __( 'Tools', 'tutor' ), __( 'Tools', 'tutor' ), 'manage_tutor', 'tutor-tools', array( new \TUTOR\Tools_V2(), 'load_tools_page' ) );
134 +
135 + add_submenu_page( 'tutor', __( 'Settings', 'tutor' ), __( 'Settings', 'tutor' ), 'manage_tutor', 'tutor_settings', array( new \TUTOR\Options_V2(), 'load_settings_page' ) );
136 +
137 + if ( ! $has_pro ) {
138 + add_submenu_page( 'tutor', __( 'Get Pro', 'tutor' ), __( '<span class="dashicons dashicons-awards tutor-get-pro-text"></span> Get Pro', 'tutor' ), 'manage_options', 'tutor-get-pro', array( $this, 'tutor_get_pro' ) );
430 139 }
431 -
432 - update_option( 'tutor-new-feature', '3.0.0' );
433 - $this->json_response( __( 'Success', 'tutor' ) );
434 140 }
435 141
436 142 /**
437 - * Show Feature Promotion Page for Free User.
143 + * Show Course Bundle Page For Free User.
438 144 *
439 145 * @since 2.2.0
440 146 *
441 147 * @return void
442 148 */
443 - public function feature_promotion_page() {
444 - include tutor()->path . 'views/pages/welcome.php';
149 + public function course_bundle_page() {
150 + include tutor()->path . 'views/pages/course-bundle.php';
445 151 }
446 152
447 153 /**
448 154 * Show students page
@@ -447,9 +153,8 @@
447 153 /**
448 154 * Show students page
449 155 *
450 156 * @since 1.0.0
451 - *
452 157 * @return void
453 158 */
454 159 public function tutor_students() {
455 160 include tutor()->path . 'views/pages/students.php';
@@ -458,9 +163,8 @@
458 163 /**
459 164 * Show instructor page
460 165 *
461 166 * @since 1.0.0
462 - *
463 167 * @return void
464 168 */
465 169 public function tutor_instructors() {
466 170 include tutor()->path . 'views/pages/instructors.php';
@@ -469,9 +173,8 @@
469 173 /**
470 174 * Show announcements page
471 175 *
472 176 * @since 1.0.0
473 - *
474 177 * @return void
475 178 */
476 179 public function tutor_announcements() {
477 180 include tutor()->path . 'views/pages/announcements.php';
@@ -480,9 +183,8 @@
480 183 /**
481 184 * Show Q&A page
482 185 *
483 186 * @since 1.0.0
484 - *
485 187 * @return void
486 188 */
487 189 public function question_answer() {
488 190 include tutor()->path . 'views/pages/question_answer.php';
@@ -491,9 +193,8 @@
491 193 /**
492 194 * Show quiz attempts page
493 195 *
494 196 * @since 1.0.0
495 - *
496 197 * @return void
497 198 */
498 199 public function quiz_attempts() {
499 200 include tutor()->path . 'views/pages/quiz_attempts.php';
@@ -502,9 +203,8 @@
502 203 /**
503 204 * Show the withdraw requests table
504 205 *
505 206 * @since 1.2.0
506 - *
507 207 * @return void
508 208 */
509 209 public function withdraw_requests() {
510 210 include tutor()->path . 'views/pages/withdraw_requests.php';
@@ -513,13 +213,17 @@
513 213 /**
514 214 * Enable or disable addons
515 215 *
516 216 * @since 1.0.0
517 - *
518 217 * @return void
519 218 */
520 219 public function enable_disable_addons() {
521 - include tutor()->path . 'views/pages/enable_disable_addons.php';
220 +
221 + if ( defined( 'TUTOR_PRO_VERSION' ) ) {
222 + include tutor()->path . 'views/pages/enable_disable_addons.php';
223 + } else {
224 + include tutor()->path . 'views/pages/tutor-pro-addons.php';
225 + }
522 226 }
523 227
524 228 /**
525 229 * Tutor tools page (OLD)
@@ -524,9 +228,8 @@
524 228 /**
525 229 * Tutor tools page (OLD)
526 230 *
527 231 * @since 1.0.0
528 - *
529 232 * @return void
530 233 */
531 234 public function tutor_tools_old() {
532 235 $tutor_admin_tools_page = Input::get( 'tutor_admin_tools_page' );
@@ -559,9 +262,8 @@
559 262 /**
560 263 * Show pro upgrade page
561 264 *
562 265 * @since 1.0.0
563 - *
564 266 * @return void
565 267 */
566 268 public function tutor_get_pro() {
567 269 include tutor()->path . 'views/pages/get-pro.php';
@@ -572,14 +274,13 @@
572 274 *
573 275 * @since 1.0.0
574 276 *
575 277 * @param string $parent_file parent file.
576 - *
577 278 * @return string
578 279 */
579 280 public function parent_menu_active( $parent_file ) {
580 281 $taxonomy = Input::get( 'taxonomy' );
581 - if ( CourseModel::COURSE_CATEGORY === $taxonomy || CourseModel::COURSE_TAG === $taxonomy ) {
282 + if ( 'course-category' === $taxonomy || 'course-tag' === $taxonomy ) {
582 283 return 'tutor';
583 284 }
584 285
585 286 return $parent_file;
@@ -598,12 +299,12 @@
598 299 public function submenu_file_active( $submenu_file, $parent_file ) {
599 300 $taxonomy = Input::get( 'taxonomy' );
600 301 $course_post_type = tutor()->course_post_type;
601 302
602 - if ( CourseModel::COURSE_CATEGORY === $taxonomy ) {
303 + if ( 'course-category' === $taxonomy ) {
603 304 return 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type;
604 305 }
605 - if ( CourseModel::COURSE_TAG === $taxonomy ) {
306 + if ( 'course-tag' === $taxonomy ) {
606 307 return 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type;
607 308 }
608 309
609 310 return $submenu_file;
@@ -612,9 +313,8 @@
612 313 /**
613 314 * Filter posts for instructor
614 315 *
615 316 * @since 1.0.0
616 - *
617 317 * @return void
618 318 */
619 319 public function filter_posts_for_instructors() {
620 320 if ( ! current_user_can( 'administrator' ) && current_user_can( tutor()->instructor_role ) ) {
@@ -628,9 +328,8 @@
628 328 *
629 329 * @since 1.0.0
630 330 *
631 331 * @param mixed $clauses clauses.
632 - *
633 332 * @return mixed
634 333 */
635 334 public function posts_clauses_request( $clauses ) {
636 335
@@ -660,9 +359,8 @@
660 359 /**
661 360 * Prevent unauthorised course/lesson edit page by direct URL
662 361 *
663 362 * @since 1.0.0
664 - *
665 363 * @return void
666 364 */
667 365 public function check_if_current_users_post() {
668 366 if ( current_user_can( 'administrator' ) || ! current_user_can( tutor()->instructor_role ) ) {
@@ -701,9 +399,8 @@
701 399 *
702 400 * @since 1.0.0
703 401 *
704 402 * @param string $template_path template file path.
705 - *
706 403 * @return array
707 404 */
708 405 public static function scan_template_files( $template_path = null ) {
709 406 if ( ! $template_path ) {
@@ -733,9 +430,8 @@
733 430 /**
734 431 * Get Template overridden files
735 432 *
736 433 * @since 1.0.0
737 - *
738 434 * @return array
739 435 */
740 436 public static function template_overridden_files() {
741 437 $template_files = self::scan_template_files();
@@ -757,14 +453,99 @@
757 453 return $override_files;
758 454 }
759 455
760 456 /**
457 + * Erase tutor data
458 + *
459 + * @since 1.0.0
460 + * @return void
461 + */
462 + public function erase_tutor_data() {
463 + global $wpdb;
464 +
465 + $is_erase_data = tutor_utils()->get_option( 'delete_on_uninstall' );
466 + // Deleting Data.
467 +
468 + $plugin_file = tutor()->basename;
469 + if ( $is_erase_data && current_user_can( 'deactivate_plugin', $plugin_file ) ) {
470 + /**
471 + * Deleting Post Type, Meta Data, taxonomy
472 + */
473 + $course_post_type = tutor()->course_post_type;
474 + $lesson_post_type = tutor()->lesson_post_type;
475 +
476 + $post_types = array(
477 + $course_post_type,
478 + $lesson_post_type,
479 + 'tutor_quiz',
480 + 'tutor_enrolled',
481 + 'topics',
482 + 'tutor_enrolled',
483 + 'tutor_announcements',
484 + );
485 +
486 + $post_type_strings = "'" . implode( "','", $post_types ) . "'";
487 + $tutor_posts = $wpdb->get_col( "SELECT ID from {$wpdb->posts} WHERE post_type in({$post_type_strings}) ;" ); //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
488 +
489 + if ( is_array( $tutor_posts ) && count( $tutor_posts ) ) {
490 + foreach ( $tutor_posts as $post_id ) {
491 + // Delete categories.
492 + $terms = wp_get_object_terms( $post_id, 'course-category' );
493 + foreach ( $terms as $term ) {
494 + wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-category' );
495 + }
496 +
497 + // Delete tags if available.
498 + $terms = wp_get_object_terms( $post_id, 'course-tag' );
499 + foreach ( $terms as $term ) {
500 + wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-tag' );
501 + }
502 +
503 + // Delete All Meta.
504 + $wpdb->delete( $wpdb->postmeta, array( 'post_id' => $post_id ) );
505 + $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
506 + }
507 + }
508 +
509 + /**
510 + * Deleting Comments (reviews, questions, quiz_answers, etc)
511 + */
512 + $tutor_comments = $wpdb->get_col( "SELECT comment_ID from {$wpdb->comments} WHERE comment_agent = 'comment_agent' ;" );
513 + $comments_ids_strings = "'" . implode( "','", $tutor_comments ) . "'";
514 + if ( is_array( $tutor_comments ) && count( $tutor_comments ) ) {
515 + $wpdb->query( "DELETE from {$wpdb->commentmeta} WHERE comment_ID in({$comments_ids_strings}) " ); //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
516 + }
517 + $wpdb->delete( $wpdb->comments, array( 'comment_agent' => 'comment_agent' ) );
518 +
519 + /**
520 + * Delete Options
521 + */
522 +
523 + delete_option( 'tutor_option' );
524 + $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_student' ) );
525 + $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_approved' ) );
526 + $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_status' ) );
527 + $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_instructor' ) );
528 + $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_tutor_completed_lesson_id_%' " );
529 +
530 + // Deleting Table.
531 + $prefix = $wpdb->prefix;
532 + //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
533 + $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 " );
534 +
535 + deactivate_plugins( $plugin_file );
536 + }
537 +
538 + wp_redirect( 'plugins.php' );
539 + die();
540 + }
541 +
542 + /**
761 543 * Plugin activation link
762 544 *
763 545 * @since 1.0.0
764 546 *
765 547 * @param array $actions action list.
766 - *
767 548 * @return array
768 549 */
769 550 public function plugin_action_links( $actions ) {
770 551 $has_pro = tutor()->has_pro;
@@ -770,11 +551,11 @@
770 551 $has_pro = tutor()->has_pro;
771 552
772 553 if ( ! $has_pro ) {
773 554 $actions['tutor_pro_link'] =
774 - '<a href="https://tutorlms.com/pricing?utm_source=tutor_plugin_action_link&utm_medium=wordpress_dashboard&utm_campaign=go_premium" target="_blank">
555 + '<a href="https://www.themeum.com/product/tutor-lms/#pricing?utm_source=tutor_plugin_action_link&utm_medium=wordpress_dashboard&utm_campaign=go_premium" target="_blank">
775 556 <span style="color: #ff7742; font-weight: bold;">' .
776 - __( 'Upgrade to Pro', 'tutor' ) .
557 + __( 'Upgrade to Pro', 'wp-megamenu' ) .
777 558 '</span>
778 559 </a>';
779 560 }
780 561
@@ -796,16 +577,16 @@
796 577 public function plugin_row_meta( $plugin_meta, $plugin_file ) {
797 578
798 579 if ( tutor()->basename === $plugin_file ) {
799 580 $plugin_meta[] = sprintf(
800 - '<a href="%s"><strong style="color: #03bd24">%s</strong></a>',
801 - esc_url( 'https://tutorlms.com/docs/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ),
802 - esc_html__( 'Documentation', 'tutor' )
581 + '<a href="%s">%s</a>',
582 + esc_url( 'https://docs.themeum.com/tutor-lms/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ),
583 + __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor' )
803 584 );
804 585 $plugin_meta[] = sprintf(
805 - '<a href="%s"><strong style="color: #03bd24">%s</strong></a>',
806 - esc_url( 'https://tutorlms.com/support/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ),
807 - esc_html__( 'Get Support', 'tutor' )
586 + '<a href="%s">%s</a>',
587 + esc_url( 'https://www.themeum.com/contact-us/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ),
588 + __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor' )
808 589 );
809 590 }
810 591
811 592 return $plugin_meta;
@@ -816,9 +597,8 @@
816 597 *
817 598 * @since 1.0.0
818 599 *
819 600 * @param string $footer_text footer text.
820 - *
821 601 * @return string
822 602 */
823 603 public function admin_footer_text( $footer_text ) {
824 604 $current_screen = get_current_screen();
@@ -844,9 +624,9 @@
844 624 * @since 1.0.0
845 625 * @return void
846 626 */
847 627 public function register_course_widget() {
848 - register_widget( Course_Widget::class );
628 + register_widget( 'Tutor\Course_Widget' );
849 629 }
850 630
851 631 /**
852 632 * Tutor Course List
@@ -851,9 +631,8 @@
851 631 /**
852 632 * Tutor Course List
853 633 *
854 634 * @since 2.0.0
855 - *
856 635 * @return void
857 636 */
858 637 public function tutor_course_list() {
859 638 include tutor()->path . 'views/pages/course-list.php';
@@ -859,57 +638,11 @@
859 638 include tutor()->path . 'views/pages/course-list.php';
860 639 }
861 640
862 641 /**
863 - * Orders view page
864 - *
865 - * @since 3.0.0
866 - *
867 - * @return void
868 - */
869 - public function orders_view() {
870 - $current_page = Input::get( 'page' );
871 - $action = Input::get( 'action' );
872 -
873 - if ( OrderController::PAGE_SLUG === $current_page && 'edit' === $action ) {
874 - ?>
875 - <div class="tutor-admin-wrap tutor-order-details-wrapper">
876 - <div id="tutor-order-details-root">
877 - </div>
878 - </div>
879 - <?php
880 - return;
881 - }
882 -
883 - include tutor()->path . 'views/pages/ecommerce/order-list.php';
884 - }
885 -
886 - /**
887 - * Coupons view page
888 - *
889 - * @since 3.0.0
890 - *
891 - * @return void
892 - */
893 - public function coupons_view() {
894 - $action = Input::get( 'action' );
895 - if ( in_array( $action, array( 'add_new', 'edit' ) ) ) {
896 - ?>
897 - <div class="tutor-admin-wrap">
898 - <div id="tutor-coupon-root">
899 - </div>
900 - </div>
901 - <?php
902 - return;
903 - }
904 - include tutor()->path . 'views/pages/ecommerce/coupon-list.php';
905 - }
906 -
907 - /**
908 642 * Show welcome page
909 643 *
910 644 * @since 1.0.0
911 - *
912 645 * @return void
913 646 */
914 647 public function welcome_page() {
915 648 Tutor_Setup::mark_as_visited();
@@ -914,75 +647,6 @@
914 647 public function welcome_page() {
915 648 Tutor_Setup::mark_as_visited();
916 649 include tutor()->path . 'views/pages/welcome.php';
917 650 exit;
918 - }
919 -
920 - /**
921 - * Add toolbar items
922 - *
923 - * @since 1.4.6
924 - *
925 - * @param \WP_Admin_Bar $admin_bar admin bar object.
926 - *
927 - * @return mixed
928 - */
929 - public function add_toolbar_items( \WP_Admin_Bar $admin_bar ) {
930 - global $post;
931 -
932 - $course_id = Input::get( 'post', 0, Input::TYPE_INT );
933 - $course_post_type = tutor()->course_post_type;
934 -
935 - if ( $admin_bar->get_node( 'new-courses' ) ) {
936 - $args = $admin_bar->get_node( 'new-courses' );
937 - $args->href = '#';
938 - $args->meta['class'] = 'tutor-create-new-course';
939 - $admin_bar->add_node( $args );
940 - }
941 -
942 - if ( ! tutor_utils()->can_user_edit_course( get_current_user_id(), $course_id ) ) {
943 - return $admin_bar;
944 - }
945 -
946 - if (
947 - ( is_admin() && $post && $course_id && $post->post_type === $course_post_type ) ||
948 - ( ! is_admin() && is_single() && $post && $course_post_type === $post->post_type )
949 - ) {
950 -
951 - $admin_bar->add_menu(
952 - array(
953 - 'id' => 'edit',
954 - 'title' => __( 'Edit with Course Builder', 'tutor' ),
955 - 'href' => tutor_utils()->course_edit_link( $post->ID ),
956 - 'meta' => array(
957 - 'title' => __( 'Edit with Course Builder', 'tutor' ),
958 - 'target' => '_blank',
959 - ),
960 - )
961 - );
962 - }
963 -
964 - return $admin_bar;
965 - }
966 -
967 - /**
968 - * Redirect to welcome page if user is not logged in.
969 - *
970 - * @since 4.0.0
971 - *
972 - * @return void
973 - */
974 - public function redirect_to_welcome_page() {
975 - // Skip for fresh installs, during the setup wizard, or during AJAX.
976 - if ( ! get_option( 'tutor_wizard' ) || 'tutor-setup' === Input::get( 'page' ) || wp_doing_ajax() ) {
977 - return;
978 - }
979 -
980 - $tutor_new_feature = get_option( 'tutor-new-feature' );
981 - if ( version_compare( $tutor_new_feature, '4.0.0-rc.2', '>=' ) ) {
982 - return;
983 - }
984 -
985 - wp_safe_redirect( admin_url( 'admin.php?page=tutor&welcome=1' ) );
986 - update_option( 'tutor-new-feature', TUTOR_VERSION );
987 651 }
988 652 }