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
4 years ago
Course_Widget.php
4 years ago
Custom_Validation.php
5 years ago
Dashboard.php
4 years ago
Email.php
5 years ago
FormHandler.php
4 years ago
Frontend.php
5 years ago
Gutenberg.php
4 years ago
Instructor.php
5 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
4 years ago
Rewrite_Rules.php
4 years ago
Shortcode.php
4 years ago
Student.php
4 years ago
Students_List.php
4 years ago
Taxonomies.php
4 years ago
Template.php
4 years ago
Theme_Compatibility.php
5 years ago
Tools.php
4 years ago
Tutor.php
4 years ago
TutorEDD.php
4 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
4 years ago
Tutor_Setup.php
4 years ago
Upgrader.php
4 years ago
User.php
4 years ago
Utils.php
4 years ago
Video_Stream.php
4 years ago
Withdraw.php
4 years ago
Withdraw_Requests_List.php
4 years ago
WooCommerce.php
4 years ago
Dashboard.php
98 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 | |
| 17 | class Dashboard { |
| 18 | |
| 19 | public function __construct() { |
| 20 | add_action( 'tutor_load_template_before', array( $this, 'tutor_load_template_before' ), 10, 2 ); |
| 21 | add_action( 'tutor_load_template_after', array( $this, 'tutor_load_template_after' ), 10, 2 ); |
| 22 | add_filter( 'should_tutor_load_template', array( $this, 'should_tutor_load_template' ), 10, 2 ); |
| 23 | |
| 24 | add_action( 'tutor_dashboard/notification_area', array( $this, 'profile_completion_notification' ), 10, 2 ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @param $template |
| 29 | * @param $variables |
| 30 | */ |
| 31 | public function tutor_load_template_before( $template, $variables ) { |
| 32 | global $wp_query; |
| 33 | |
| 34 | $tutor_dashboard_page = tutor_utils()->array_get( 'query_vars.tutor_dashboard_page', $wp_query ); |
| 35 | if ( $tutor_dashboard_page === 'create-course' ) { |
| 36 | global $post; |
| 37 | wp_reset_query(); |
| 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( |
| 49 | array( |
| 50 | 'post_title' => __( 'Auto Draft', 'tutor' ), |
| 51 | 'post_type' => $post_type, |
| 52 | 'post_status' => 'draft', |
| 53 | ) |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | $post = get_post( $post_id ); |
| 58 | setup_postdata( $post ); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | public function tutor_load_template_after() { |
| 63 | global $wp_query; |
| 64 | |
| 65 | $tutor_dashboard_page = tutor_utils()->array_get( 'query_vars.tutor_dashboard_page', $wp_query ); |
| 66 | if ( $tutor_dashboard_page === 'create-course' ) { |
| 67 | wp_reset_query(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | public function should_tutor_load_template( $bool, $template ) { |
| 72 | if ( $template === 'dashboard.create-course' && ! tutor()->has_pro ) { |
| 73 | return false; |
| 74 | } |
| 75 | return $bool; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /** |
| 80 | * Display completion notification |
| 81 | * |
| 82 | * @return string |
| 83 | * |
| 84 | * @since v.1.6.6 |
| 85 | */ |
| 86 | public function profile_completion_notification() { |
| 87 | $output = ''; |
| 88 | $enable_profile_completion = tutils()->get_option( 'enable_profile_completion' ); |
| 89 | if ( $enable_profile_completion ) { |
| 90 | ob_start(); |
| 91 | tutor_load_template( 'dashboard.notifications.profile-completion' ); |
| 92 | $output = apply_filters( 'tutor_profile_completion_notification_html', ob_get_clean() ); |
| 93 | } |
| 94 | |
| 95 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 96 | } |
| 97 | } |
| 98 |