PluginProbe
Tutor LMS – eLearning and online course solution / 3.8.2
Tutor LMS – eLearning and online course solution v3.8.2
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 +25 -157 trunk3.8.2 View file →
@@ -9,10 +9,8 @@
9 9 */
10 10
11 11 namespace TUTOR;
12 12
13 -defined( 'ABSPATH' ) || exit;
14 -
15 13 use Tutor\Ecommerce\OrderController;
16 14 use Tutor\Helpers\HttpHelper;
17 15 use TUTOR\Input;
18 16 use Tutor\Models\CourseModel;
@@ -17,8 +15,12 @@
17 15 use TUTOR\Input;
18 16 use Tutor\Models\CourseModel;
19 17 use Tutor\Traits\JsonResponse;
20 18
19 +if ( ! defined( 'ABSPATH' ) ) {
20 + exit;
21 +}
22 +
21 23 /**
22 24 * Admin Class
23 25 *
24 26 * @since 1.0.0
@@ -29,12 +31,12 @@
29 31 /**
30 32 * Constructor
31 33 *
32 34 * @since 1.0.0
33 - *
34 35 * @return void
35 36 */
36 37 public function __construct() {
38 +
37 39 add_action( 'admin_notices', array( $this, 'show_unstable_version_admin_notice' ) );
38 40
39 41 add_action( 'admin_menu', array( $this, 'register_menu' ) );
40 42 // Force activate menu for necessary.
@@ -41,9 +43,8 @@
41 43 add_filter( 'parent_file', array( $this, 'parent_menu_active' ) );
42 44 add_filter( 'submenu_file', array( $this, 'submenu_file_active' ), 10, 2 );
43 45
44 46 add_action( 'admin_init', array( $this, 'filter_posts_for_instructors' ) );
45 - add_action( 'admin_init', array( $this, 'redirect_to_welcome_page' ) );
46 47 add_action( 'load-post.php', array( $this, 'check_if_current_users_post' ) );
47 48
48 49 add_filter( 'plugin_action_links_' . plugin_basename( TUTOR_FILE ), array( $this, 'plugin_action_links' ) );
49 50
@@ -60,121 +61,11 @@
60 61
61 62 add_action( 'admin_bar_menu', array( $this, 'add_toolbar_items' ), 100 );
62 63
63 64 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 65 }
70 66
71 67 /**
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 68 * Show unstable version notice.
178 69 *
179 70 * @since 3.0.0
180 71 *
@@ -341,8 +232,16 @@
341 232 'google_classroom' => null,
342 233 'zoom' => null,
343 234 'google_meet' => null,
344 235 'h5p' => null,
236 + 'themes' => array(
237 + 'parent_slug' => 'tutor',
238 + 'page_title' => __( 'Themes', 'tutor' ),
239 + 'menu_title' => __( 'Themes', 'tutor' ),
240 + 'capability' => 'manage_tutor',
241 + 'menu_slug' => 'tutor-themes',
242 + 'callback' => array( $this, 'tutor_themes' ),
243 + ),
345 244 'addons' => array(
346 245 'parent_slug' => 'tutor',
347 246 'page_title' => __( 'Addons', 'tutor' ),
348 247 'menu_title' => __( 'Addons', 'tutor' ),
@@ -413,8 +312,17 @@
413 312 }
414 313 }
415 314
416 315 /**
316 + * Tutor template view
317 + *
318 + * @since 3.6.0
319 + */
320 + public function tutor_themes() {
321 + include tutor()->path . 'views/template-import/templates.php';
322 + }
323 +
324 + /**
417 325 * Welcome page opt-out
418 326 *
419 327 * @since 3.0.0
420 328 */
@@ -441,8 +349,9 @@
441 349 * @return void
442 350 */
443 351 public function feature_promotion_page() {
444 352 include tutor()->path . 'views/pages/welcome.php';
353 + // include tutor()->path . 'views/pages/feature-promotion.php';
445 354 }
446 355
447 356 /**
448 357 * Show students page
@@ -447,9 +356,8 @@
447 356 /**
448 357 * Show students page
449 358 *
450 359 * @since 1.0.0
451 - *
452 360 * @return void
453 361 */
454 362 public function tutor_students() {
455 363 include tutor()->path . 'views/pages/students.php';
@@ -458,9 +366,8 @@
458 366 /**
459 367 * Show instructor page
460 368 *
461 369 * @since 1.0.0
462 - *
463 370 * @return void
464 371 */
465 372 public function tutor_instructors() {
466 373 include tutor()->path . 'views/pages/instructors.php';
@@ -469,9 +376,8 @@
469 376 /**
470 377 * Show announcements page
471 378 *
472 379 * @since 1.0.0
473 - *
474 380 * @return void
475 381 */
476 382 public function tutor_announcements() {
477 383 include tutor()->path . 'views/pages/announcements.php';
@@ -480,9 +386,8 @@
480 386 /**
481 387 * Show Q&A page
482 388 *
483 389 * @since 1.0.0
484 - *
485 390 * @return void
486 391 */
487 392 public function question_answer() {
488 393 include tutor()->path . 'views/pages/question_answer.php';
@@ -491,9 +396,8 @@
491 396 /**
492 397 * Show quiz attempts page
493 398 *
494 399 * @since 1.0.0
495 - *
496 400 * @return void
497 401 */
498 402 public function quiz_attempts() {
499 403 include tutor()->path . 'views/pages/quiz_attempts.php';
@@ -502,9 +406,8 @@
502 406 /**
503 407 * Show the withdraw requests table
504 408 *
505 409 * @since 1.2.0
506 - *
507 410 * @return void
508 411 */
509 412 public function withdraw_requests() {
510 413 include tutor()->path . 'views/pages/withdraw_requests.php';
@@ -513,9 +416,8 @@
513 416 /**
514 417 * Enable or disable addons
515 418 *
516 419 * @since 1.0.0
517 - *
518 420 * @return void
519 421 */
520 422 public function enable_disable_addons() {
521 423 include tutor()->path . 'views/pages/enable_disable_addons.php';
@@ -524,9 +426,8 @@
524 426 /**
525 427 * Tutor tools page (OLD)
526 428 *
527 429 * @since 1.0.0
528 - *
529 430 * @return void
530 431 */
531 432 public function tutor_tools_old() {
532 433 $tutor_admin_tools_page = Input::get( 'tutor_admin_tools_page' );
@@ -559,9 +460,8 @@
559 460 /**
560 461 * Show pro upgrade page
561 462 *
562 463 * @since 1.0.0
563 - *
564 464 * @return void
565 465 */
566 466 public function tutor_get_pro() {
567 467 include tutor()->path . 'views/pages/get-pro.php';
@@ -572,9 +472,8 @@
572 472 *
573 473 * @since 1.0.0
574 474 *
575 475 * @param string $parent_file parent file.
576 - *
577 476 * @return string
578 477 */
579 478 public function parent_menu_active( $parent_file ) {
580 479 $taxonomy = Input::get( 'taxonomy' );
@@ -612,9 +511,8 @@
612 511 /**
613 512 * Filter posts for instructor
614 513 *
615 514 * @since 1.0.0
616 - *
617 515 * @return void
618 516 */
619 517 public function filter_posts_for_instructors() {
620 518 if ( ! current_user_can( 'administrator' ) && current_user_can( tutor()->instructor_role ) ) {
@@ -628,9 +526,8 @@
628 526 *
629 527 * @since 1.0.0
630 528 *
631 529 * @param mixed $clauses clauses.
632 - *
633 530 * @return mixed
634 531 */
635 532 public function posts_clauses_request( $clauses ) {
636 533
@@ -660,9 +557,8 @@
660 557 /**
661 558 * Prevent unauthorised course/lesson edit page by direct URL
662 559 *
663 560 * @since 1.0.0
664 - *
665 561 * @return void
666 562 */
667 563 public function check_if_current_users_post() {
668 564 if ( current_user_can( 'administrator' ) || ! current_user_can( tutor()->instructor_role ) ) {
@@ -701,9 +597,8 @@
701 597 *
702 598 * @since 1.0.0
703 599 *
704 600 * @param string $template_path template file path.
705 - *
706 601 * @return array
707 602 */
708 603 public static function scan_template_files( $template_path = null ) {
709 604 if ( ! $template_path ) {
@@ -733,9 +628,8 @@
733 628 /**
734 629 * Get Template overridden files
735 630 *
736 631 * @since 1.0.0
737 - *
738 632 * @return array
739 633 */
740 634 public static function template_overridden_files() {
741 635 $template_files = self::scan_template_files();
@@ -762,9 +656,8 @@
762 656 *
763 657 * @since 1.0.0
764 658 *
765 659 * @param array $actions action list.
766 - *
767 660 * @return array
768 661 */
769 662 public function plugin_action_links( $actions ) {
770 663 $has_pro = tutor()->has_pro;
@@ -797,14 +690,14 @@
797 690
798 691 if ( tutor()->basename === $plugin_file ) {
799 692 $plugin_meta[] = sprintf(
800 693 '<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' ),
694 + esc_url( 'https://docs.themeum.com/tutor-lms/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ),
802 695 esc_html__( 'Documentation', 'tutor' )
803 696 );
804 697 $plugin_meta[] = sprintf(
805 698 '<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' ),
699 + esc_url( 'https://www.themeum.com/contact-us/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ),
807 700 esc_html__( 'Get Support', 'tutor' )
808 701 );
809 702 }
810 703
@@ -816,9 +709,8 @@
816 709 *
817 710 * @since 1.0.0
818 711 *
819 712 * @param string $footer_text footer text.
820 - *
821 713 * @return string
822 714 */
823 715 public function admin_footer_text( $footer_text ) {
824 716 $current_screen = get_current_screen();
@@ -851,9 +743,8 @@
851 743 /**
852 744 * Tutor Course List
853 745 *
854 746 * @since 2.0.0
855 - *
856 747 * @return void
857 748 */
858 749 public function tutor_course_list() {
859 750 include tutor()->path . 'views/pages/course-list.php';
@@ -907,9 +798,8 @@
907 798 /**
908 799 * Show welcome page
909 800 *
910 801 * @since 1.0.0
911 - *
912 802 * @return void
913 803 */
914 804 public function welcome_page() {
915 805 Tutor_Setup::mark_as_visited();
@@ -961,28 +851,6 @@
961 851 );
962 852 }
963 853
964 854 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 855 }
988 856 }