Addons.php
6 years ago
Admin.php
6 years ago
Ajax.php
6 years ago
Assets.php
6 years ago
Course.php
6 years ago
Course_Settings_Tabs.php
6 years ago
Course_Widget.php
6 years ago
Dashboard.php
6 years ago
Email.php
6 years ago
FormHandler.php
6 years ago
Frontend.php
6 years ago
Gutenberg.php
6 years ago
Instructor.php
6 years ago
Instructors_List.php
6 years ago
Lesson.php
6 years ago
Options.php
6 years ago
Post_types.php
6 years ago
Q_and_A.php
6 years ago
Question_Answers_List.php
6 years ago
Quiz.php
6 years ago
Quiz_Attempts_List.php
6 years ago
RestAPI.php
6 years ago
Rewrite_Rules.php
6 years ago
Shortcode.php
6 years ago
Student.php
6 years ago
Students_List.php
6 years ago
Taxonomies.php
6 years ago
Template.php
6 years ago
Theme_Compatibility.php
6 years ago
Tools.php
6 years ago
Tutor.php
6 years ago
TutorEDD.php
6 years ago
Tutor_Base.php
6 years ago
Tutor_List_Table.php
6 years ago
Tutor_Setup.php
6 years ago
Upgrader.php
6 years ago
User.php
6 years ago
Utils.php
6 years ago
Video_Stream.php
6 years ago
Withdraw.php
6 years ago
Withdraw_Requests_List.php
6 years ago
WooCommerce.php
6 years ago
Dashboard.php
70 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 | |
| 24 | /** |
| 25 | * @param $template |
| 26 | * @param $variables |
| 27 | */ |
| 28 | public function tutor_load_template_before($template, $variables){ |
| 29 | global $wp_query; |
| 30 | |
| 31 | $tutor_dashboard_page = tutor_utils()->array_get('query_vars.tutor_dashboard_page', $wp_query); |
| 32 | if ($tutor_dashboard_page === 'create-course') { |
| 33 | global $post; |
| 34 | wp_reset_query(); |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Get course which currently in edit, or insert new course |
| 39 | */ |
| 40 | $course_ID = (int) sanitize_text_field(tutor_utils()->array_get('course_ID', $_GET)); |
| 41 | |
| 42 | if ($course_ID){ |
| 43 | $post_id = $course_ID; |
| 44 | }else{ |
| 45 | $post_type = tutor()->course_post_type; |
| 46 | $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft', 'tutor' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
| 47 | } |
| 48 | |
| 49 | $post = get_post( $post_id ); |
| 50 | setup_postdata( $post ); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | public function tutor_load_template_after(){ |
| 55 | global $wp_query; |
| 56 | |
| 57 | $tutor_dashboard_page = tutor_utils()->array_get('query_vars.tutor_dashboard_page', $wp_query); |
| 58 | if ($tutor_dashboard_page === 'create-course'){ |
| 59 | wp_reset_query(); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | public function should_tutor_load_template($bool, $template){ |
| 64 | if ($template === 'dashboard.create-course' && ! tutor()->has_pro){ |
| 65 | return false; |
| 66 | } |
| 67 | return $bool; |
| 68 | } |
| 69 | |
| 70 | } |