Addons.php
5 years ago
Admin.php
5 years ago
Ajax.php
5 years ago
Assets.php
5 years ago
Course.php
5 years ago
Course_Settings_Tabs.php
5 years ago
Course_Widget.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
5 years ago
Instructor.php
5 years ago
Instructors_List.php
5 years ago
Lesson.php
5 years ago
Options.php
5 years ago
Post_types.php
5 years ago
Q_and_A.php
5 years ago
Question_Answers_List.php
5 years ago
Quiz.php
5 years ago
Quiz_Attempts_List.php
5 years ago
RestAPI.php
5 years ago
Rewrite_Rules.php
5 years ago
Shortcode.php
5 years ago
Student.php
5 years ago
Students_List.php
5 years ago
Taxonomies.php
5 years ago
Template.php
5 years ago
Theme_Compatibility.php
5 years ago
Tools.php
5 years ago
Tutor.php
5 years ago
TutorEDD.php
5 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
5 years ago
Tutor_Setup.php
5 years ago
Upgrader.php
5 years ago
User.php
5 years ago
Utils.php
5 years ago
Video_Stream.php
5 years ago
Withdraw.php
5 years ago
Withdraw_Requests_List.php
5 years ago
WooCommerce.php
5 years ago
Shortcode.php
141 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Shortcode |
| 4 | * @package TUTOR |
| 5 | * |
| 6 | * @since v.1.0.0 |
| 7 | */ |
| 8 | |
| 9 | namespace TUTOR; |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) |
| 12 | exit; |
| 13 | |
| 14 | class Shortcode { |
| 15 | |
| 16 | public function __construct() { |
| 17 | add_shortcode('tutor_student_registration_form', array($this, 'student_registration_form')); |
| 18 | add_shortcode('tutor_dashboard', array($this, 'tutor_dashboard')); |
| 19 | add_shortcode('tutor_instructor_registration_form', array($this, 'instructor_registration_form')); |
| 20 | add_shortcode('tutor_course', array($this, 'tutor_course')); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @return mixed |
| 25 | * |
| 26 | * Instructor Registration Shortcode |
| 27 | * |
| 28 | * @since v.1.0.0 |
| 29 | */ |
| 30 | public function student_registration_form(){ |
| 31 | ob_start(); |
| 32 | if (is_user_logged_in()){ |
| 33 | tutor_load_template( 'dashboard.logged-in' ); |
| 34 | }else{ |
| 35 | tutor_load_template( 'dashboard.registration' ); |
| 36 | } |
| 37 | return apply_filters( 'tutor/student/register', ob_get_clean() ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return mixed |
| 42 | * |
| 43 | * Tutor Dashboard for students |
| 44 | * |
| 45 | * @since v.1.0.0 |
| 46 | */ |
| 47 | public function tutor_dashboard(){ |
| 48 | global $wp_query; |
| 49 | |
| 50 | ob_start(); |
| 51 | if (is_user_logged_in()){ |
| 52 | /** |
| 53 | * Added isset() Condition to avoid infinite loop since v.1.5.4 |
| 54 | * This has cause error by others plugin, Such AS SEO |
| 55 | */ |
| 56 | |
| 57 | if ( ! isset($wp_query->query_vars['tutor_dashboard_page'])){ |
| 58 | tutor_load_template( 'dashboard.index' ); |
| 59 | } |
| 60 | }else{ |
| 61 | tutor_load_template( 'global.login' ); |
| 62 | } |
| 63 | return apply_filters( 'tutor_dashboard/index', ob_get_clean() ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @return mixed |
| 68 | * |
| 69 | * Instructor Registration Shortcode |
| 70 | * |
| 71 | * @since v.1.0.0 |
| 72 | */ |
| 73 | public function instructor_registration_form(){ |
| 74 | ob_start(); |
| 75 | if (is_user_logged_in()){ |
| 76 | tutor_load_template( 'dashboard.instructor.logged-in' ); |
| 77 | }else{ |
| 78 | tutor_load_template( 'dashboard.instructor.registration' ); |
| 79 | } |
| 80 | return apply_filters( 'tutor_dashboard/student/index', ob_get_clean() ); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @param $atts |
| 85 | * |
| 86 | * @return string |
| 87 | * |
| 88 | * Shortcode for getting course |
| 89 | */ |
| 90 | public function tutor_course($atts){ |
| 91 | $course_post_type = tutor()->course_post_type; |
| 92 | |
| 93 | $a = shortcode_atts( array( |
| 94 | 'post_type' => $course_post_type, |
| 95 | 'post_status' => 'publish', |
| 96 | |
| 97 | 'id' => '', |
| 98 | 'exclude_ids' => '', |
| 99 | 'category' => '', |
| 100 | |
| 101 | 'orderby' => 'ID', |
| 102 | 'order' => 'DESC', |
| 103 | 'count' => '6', |
| 104 | ), $atts ); |
| 105 | |
| 106 | if ( ! empty($a['id'])){ |
| 107 | $ids = (array) explode(',', $a['id']); |
| 108 | $a['post__in'] = $ids; |
| 109 | } |
| 110 | |
| 111 | if ( ! empty($a['exclude_ids'])){ |
| 112 | $exclude_ids = (array) explode(',', $a['exclude_ids']); |
| 113 | $a['post__not_in'] = $exclude_ids; |
| 114 | } |
| 115 | if ( ! empty($a['category'])){ |
| 116 | $category = (array) explode(',', $a['category']); |
| 117 | |
| 118 | $a['tax_query'] = array( |
| 119 | array( |
| 120 | 'taxonomy' => 'course-category', |
| 121 | 'field' => 'term_id', |
| 122 | 'terms' => $category, |
| 123 | 'operator' => 'IN', |
| 124 | ), |
| 125 | ); |
| 126 | } |
| 127 | $a['posts_per_page'] = (int) $a['count']; |
| 128 | |
| 129 | wp_reset_query(); |
| 130 | query_posts($a); |
| 131 | ob_start(); |
| 132 | tutor_load_template('shortcode.tutor-course'); |
| 133 | $output = ob_get_clean(); |
| 134 | wp_reset_query(); |
| 135 | |
| 136 | return $output; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | |
| 141 | } |