Addons.php
4 years ago
Admin.php
4 years ago
Ajax.php
4 years ago
Assets.php
4 years ago
Course.php
4 years ago
Course_Filter.php
4 years ago
Course_Settings_Tabs.php
5 years ago
Course_Widget.php
5 years ago
Custom_Validation.php
5 years ago
Dashboard.php
5 years ago
Email.php
5 years ago
FormHandler.php
5 years ago
Frontend.php
5 years ago
Gutenberg.php
4 years ago
Instructor.php
4 years ago
Instructors_List.php
4 years ago
Lesson.php
4 years ago
Options.php
4 years ago
Post_types.php
4 years ago
Private_Course_Access.php
5 years ago
Q_and_A.php
5 years ago
Question_Answers_List.php
4 years ago
Quiz.php
4 years ago
Quiz_Attempts_List.php
4 years ago
RestAPI.php
5 years ago
Rewrite_Rules.php
5 years ago
Shortcode.php
4 years ago
Student.php
5 years ago
Students_List.php
4 years ago
Taxonomies.php
5 years ago
Template.php
4 years ago
Theme_Compatibility.php
5 years ago
Tools.php
5 years ago
Tutor.php
4 years ago
TutorEDD.php
5 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
4 years ago
Tutor_Setup.php
4 years ago
Upgrader.php
5 years ago
User.php
4 years ago
Utils.php
4 years ago
Video_Stream.php
5 years ago
Withdraw.php
5 years ago
Withdraw_Requests_List.php
4 years ago
WooCommerce.php
4 years ago
Dashboard.php
91 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Dashboard class |
| 4 | * |
| 5 | * @author: themeum |
| 6 | * @author_uri: https://themeum.com |
| 7 | * @package Tutor |
| 8 | * @since v.1.3.4 |
| 9 | */ |
| 10 | |
| 11 | namespace TUTOR; |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) |
| 14 | exit; |
| 15 | |
| 16 | class Dashboard { |
| 17 | |
| 18 | public function __construct() { |
| 19 | add_action('tutor_load_template_before', array($this, 'tutor_load_template_before'), 10, 2); |
| 20 | add_action('tutor_load_template_after', array($this, 'tutor_load_template_after'), 10, 2); |
| 21 | add_filter('should_tutor_load_template', array($this, 'should_tutor_load_template'), 10, 2); |
| 22 | |
| 23 | add_action('tutor_dashboard/notification_area', array($this, 'profile_completion_notification'), 10, 2); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @param $template |
| 28 | * @param $variables |
| 29 | */ |
| 30 | public function tutor_load_template_before($template, $variables){ |
| 31 | global $wp_query; |
| 32 | |
| 33 | $tutor_dashboard_page = tutor_utils()->array_get('query_vars.tutor_dashboard_page', $wp_query); |
| 34 | if ($tutor_dashboard_page === 'create-course') { |
| 35 | global $post; |
| 36 | wp_reset_query(); |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Get course which currently in edit, or insert new course |
| 41 | */ |
| 42 | $course_ID = (int) sanitize_text_field(tutor_utils()->array_get('course_ID', $_GET)); |
| 43 | |
| 44 | if ($course_ID){ |
| 45 | $post_id = $course_ID; |
| 46 | }else{ |
| 47 | $post_type = tutor()->course_post_type; |
| 48 | $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft', 'tutor' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
| 49 | } |
| 50 | |
| 51 | $post = get_post( $post_id ); |
| 52 | setup_postdata( $post ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public function tutor_load_template_after(){ |
| 57 | global $wp_query; |
| 58 | |
| 59 | $tutor_dashboard_page = tutor_utils()->array_get('query_vars.tutor_dashboard_page', $wp_query); |
| 60 | if ($tutor_dashboard_page === 'create-course'){ |
| 61 | wp_reset_query(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | public function should_tutor_load_template($bool, $template){ |
| 66 | if ($template === 'dashboard.create-course' && ! tutor()->has_pro){ |
| 67 | return false; |
| 68 | } |
| 69 | return $bool; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * Display completion notification |
| 75 | * |
| 76 | * @return string |
| 77 | * |
| 78 | * @since v.1.6.6 |
| 79 | */ |
| 80 | public function profile_completion_notification() { |
| 81 | $output = ''; |
| 82 | $enable_profile_completion = tutils()->get_option('enable_profile_completion'); |
| 83 | if ($enable_profile_completion) { |
| 84 | ob_start(); |
| 85 | tutor_load_template('dashboard.notifications.profile-completion'); |
| 86 | $output = apply_filters('tutor_profile_completion_notification_html', ob_get_clean()); |
| 87 | } |
| 88 | |
| 89 | echo $output; |
| 90 | } |
| 91 | } |