| @@ -14,10 +14,11 @@ | ||
| 14 | 14 | class Shortcode { |
| 15 | 15 | |
| 16 | 16 | public function __construct() { |
| 17 | 17 | add_shortcode('tutor_student_registration_form', array($this, 'student_registration_form')); |
| 18 | - add_shortcode('tutor_student_dashboard', array($this, 'tutor_student_dashboard')); | |
| 18 | + add_shortcode('tutor_dashboard', array($this, 'tutor_dashboard')); | |
| 19 | 19 | add_shortcode('tutor_instructor_registration_form', array($this, 'instructor_registration_form')); |
| 20 | + add_shortcode('tutor_course', array($this, 'tutor_course')); | |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * @return mixed |
| @@ -28,11 +29,11 @@ | ||
| 28 | 29 | */ |
| 29 | 30 | public function student_registration_form(){ |
| 30 | 31 | ob_start(); |
| 31 | 32 | if (is_user_logged_in()){ |
| 32 | - tutor_load_template( 'dashboard.student.logged-in' ); | |
| 33 | + tutor_load_template( 'dashboard.logged-in' ); | |
| 33 | 34 | }else{ |
| 34 | - tutor_load_template( 'dashboard.student.registration' ); | |
| 35 | + tutor_load_template( 'dashboard.registration' ); | |
| 35 | 36 | } |
| 36 | 37 | return apply_filters( 'tutor/student/register', ob_get_clean() ); |
| 37 | 38 | } |
| 38 | 39 | |
| @@ -42,16 +43,16 @@ | ||
| 42 | 43 | * Tutor Dashboard for students |
| 43 | 44 | * |
| 44 | 45 | * @since v.1.0.0 |
| 45 | 46 | */ |
| 46 | - public function tutor_student_dashboard(){ | |
| 47 | + public function tutor_dashboard(){ | |
| 47 | 48 | ob_start(); |
| 48 | 49 | if (is_user_logged_in()){ |
| 49 | - tutor_load_template( 'dashboard.student.index' ); | |
| 50 | + tutor_load_template( 'dashboard.index' ); | |
| 50 | 51 | }else{ |
| 51 | 52 | tutor_load_template( 'global.login' ); |
| 52 | 53 | } |
| 53 | - return apply_filters( 'tutor_dashboard/student/index', ob_get_clean() ); | |
| 54 | + return apply_filters( 'tutor_dashboard/index', ob_get_clean() ); | |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | /** |
| 57 | 58 | * @return mixed |
| @@ -68,6 +69,64 @@ | ||
| 68 | 69 | tutor_load_template( 'dashboard.instructor.registration' ); |
| 69 | 70 | } |
| 70 | 71 | return apply_filters( 'tutor_dashboard/student/index', ob_get_clean() ); |
| 71 | 72 | } |
| 73 | + | |
| 74 | + /** | |
| 75 | + * @param $atts | |
| 76 | + * | |
| 77 | + * @return string | |
| 78 | + * | |
| 79 | + * Shortcode for getting course | |
| 80 | + */ | |
| 81 | + public function tutor_course($atts){ | |
| 82 | + $course_post_type = tutor()->course_post_type; | |
| 83 | + | |
| 84 | + $a = shortcode_atts( array( | |
| 85 | + 'post_type' => $course_post_type, | |
| 86 | + 'post_status' => 'publish', | |
| 87 | + | |
| 88 | + 'id' => '', | |
| 89 | + 'exclude_ids' => '', | |
| 90 | + 'category' => '', | |
| 91 | + | |
| 92 | + 'orderby' => 'ID', | |
| 93 | + 'order' => 'DESC', | |
| 94 | + 'count' => '6', | |
| 95 | + ), $atts ); | |
| 96 | + | |
| 97 | + if ( ! empty($a['id'])){ | |
| 98 | + $ids = (array) explode(',', $a['id']); | |
| 99 | + $a['post__in'] = $ids; | |
| 100 | + } | |
| 101 | + | |
| 102 | + if ( ! empty($a['exclude_ids'])){ | |
| 103 | + $exclude_ids = (array) explode(',', $a['exclude_ids']); | |
| 104 | + $a['post__not_in'] = $exclude_ids; | |
| 105 | + } | |
| 106 | + if ( ! empty($a['category'])){ | |
| 107 | + $category = (array) explode(',', $a['category']); | |
| 108 | + | |
| 109 | + $a['tax_query'] = array( | |
| 110 | + array( | |
| 111 | + 'taxonomy' => 'course-category', | |
| 112 | + 'field' => 'term_id', | |
| 113 | + 'terms' => $category, | |
| 114 | + 'operator' => 'IN', | |
| 115 | + ), | |
| 116 | + ); | |
| 117 | + } | |
| 118 | + $a['posts_per_page'] = (int) $a['count']; | |
| 119 | + | |
| 120 | + wp_reset_query(); | |
| 121 | + query_posts($a); | |
| 122 | + ob_start(); | |
| 123 | + tutor_load_template('shortcode.tutor-course'); | |
| 124 | + $output = ob_get_clean(); | |
| 125 | + wp_reset_query(); | |
| 126 | + | |
| 127 | + return $output; | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 72 | 131 | |
| 73 | 132 | } |