PluginProbe
Tutor LMS – eLearning and online course solution / 1.3.5
Tutor LMS – eLearning and online course solution v1.3.5
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
tutor / classes / Dashboard.php

Dashboard.php in Tutor LMS – eLearning and online course solution 1.3.5, at classes/Dashboard.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }