PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 1.0.1
Tutor LMS – eLearning and online course solution v1.0.1
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 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / includes / tutor-template-functions.php
tutor / includes Last commit date
theme-compatibility 7 years ago tutor-template-functions.php 7 years ago tutor-template-hook.php 7 years ago
tutor-template-functions.php
1184 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) )
4 exit;
5
6 /**
7 * @param null $template
8 *
9 * @return bool|string
10 *
11 * Load template with override file system
12 *
13 * @since v.1.0.0
14 */
15
16 if ( ! function_exists('tutor_get_template')) {
17 function tutor_get_template( $template = null ) {
18 if ( ! $template ) {
19 return false;
20 }
21 $template = str_replace( '.', DIRECTORY_SEPARATOR, $template );
22
23 $template_location = trailingslashit( get_template_directory() ) . "tutor/{$template}.php";
24 $file_in_theme = $template_location;
25 if ( ! file_exists( $template_location ) ) {
26 $template_location = trailingslashit( tutor()->path ) . "templates/{$template}.php";
27
28 if ( ! file_exists($template_location)){
29 echo '<div class="tutor-notice-warning"> '.__(sprintf('The file you are trying to load is not exists in your theme or tutor plugins location, if you are a developer and extending tutor plugin, please create a php file at location %s ', "<code>{$file_in_theme}</code>"), 'tutor').' </div>';
30 }
31 }
32
33 return $template_location;
34 }
35 }
36
37 /**
38 * @param null $template
39 *
40 * Load template for TUTOR
41 *
42 * @since v.1.0.0
43 */
44
45 if ( ! function_exists('tutor_load_template')) {
46 function tutor_load_template( $template = null ) {
47 include tutor_get_template( $template );
48 }
49 }
50
51 if ( ! function_exists('tutor_course_loop_start')){
52 function tutor_course_loop_start($echo = true ){
53 ob_start();
54 tutor_load_template('loop.loop-start');
55 $output = apply_filters('tutor_course_loop_start', ob_get_clean());
56
57 if ( $echo ) {
58 echo $output;
59 }
60 return $output;
61 }
62 }
63
64 if ( ! function_exists('tutor_course_loop_end')) {
65 function tutor_course_loop_end( $echo = true ) {
66 ob_start();
67 tutor_load_template( 'loop.loop-end' );
68
69 $output = apply_filters( 'tutor_course_loop_end', ob_get_clean() );
70 if ( $echo ) {
71 echo $output;
72 }
73
74 return $output;
75 }
76 }
77
78 if ( ! function_exists('tutor_course_archive_pagination')) {
79 function tutor_course_archive_pagination( $echo = true ) {
80 ob_start();
81 tutor_load_template( 'loop.tutor-pagination' );
82
83 $output = apply_filters( 'tutor_course_archive_pagination', ob_get_clean() );
84 if ( $echo ) {
85 echo $output;
86 }
87
88 return $output;
89 }
90 }
91
92 function tutor_course_loop_before_content(){
93 ob_start();
94 tutor_load_template( 'loop.loop-before-content' );
95
96 $output = apply_filters( 'tutor_course_loop_before_content', ob_get_clean() );
97 echo $output;
98 }
99
100 function tutor_course_loop_after_content(){
101 ob_start();
102 tutor_load_template( 'loop.loop-after-content' );
103
104 $output = apply_filters( 'tutor_course_loop_after_content', ob_get_clean() );
105 echo $output;
106 }
107
108 if ( ! function_exists('tutor_course_loop_title')) {
109 function tutor_course_loop_title() {
110 ob_start();
111 tutor_load_template( 'loop.title' );
112 $output = apply_filters( 'tutor_course_loop_title', ob_get_clean() );
113
114 echo $output;
115 }
116 }
117
118
119 if ( ! function_exists('tutor_course_loop_header')) {
120 function tutor_course_loop_header() {
121 ob_start();
122 tutor_load_template( 'loop.header' );
123 $output = apply_filters( 'tutor_course_loop_header', ob_get_clean() );
124
125 echo $output;
126 }
127 }
128
129 if ( ! function_exists('tutor_course_loop_footer')) {
130 function tutor_course_loop_footer() {
131 ob_start();
132 tutor_load_template( 'loop.footer' );
133 $output = apply_filters( 'tutor_course_loop_footer', ob_get_clean() );
134
135 echo $output;
136 }
137 }
138
139 //tutor_course_loop_footer
140
141
142 if ( ! function_exists('tutor_course_loop_start_content_wrap')) {
143 function tutor_course_loop_start_content_wrap() {
144 ob_start();
145 tutor_load_template( 'loop.start_content_wrap' );
146 $output = apply_filters( 'tutor_course_loop_start_content_wrap', ob_get_clean() );
147
148 echo $output;
149 }
150 }
151
152 if ( ! function_exists('tutor_course_loop_end_content_wrap')) {
153 function tutor_course_loop_end_content_wrap() {
154 ob_start();
155 tutor_load_template( 'loop.end_content_wrap' );
156 $output = apply_filters( 'tutor_course_loop_end_content_wrap', ob_get_clean() );
157
158 echo $output;
159 }
160 }
161
162 if ( ! function_exists('tutor_course_loop_thumbnail')) {
163 function tutor_course_loop_thumbnail() {
164 ob_start();
165 tutor_load_template( 'loop.thumbnail' );
166 $output = apply_filters( 'tutor_course_loop_thumbnail', ob_get_clean() );
167
168 echo $output;
169 }
170 }
171
172 if( ! function_exists('tutor_course_loop_wrap_classes')) {
173 function tutor_course_loop_wrap_classes( $echo = true ) {
174 $courseID = get_the_ID();
175 $classes = apply_filters( 'tutor_course_loop_wrap_classes', array(
176 'tutor-course',
177 'tutor-course-loop',
178 'tutor-course-loop-' . $courseID,
179 ) );
180
181 $class = implode( ' ', $classes );
182 if ( $echo ) {
183 echo $class;
184 }
185
186 return $class;
187 }
188 }
189
190 if( ! function_exists('tutor_course_loop_col_classes')) {
191 function tutor_course_loop_col_classes( $echo = true ) {
192 $courseCols = tutor_utils()->get_option( 'courses_col_per_row', 4 );
193 $classes = apply_filters( 'tutor_course_loop_col_classes', array(
194 'tutor-course-col-' . $courseCols,
195 ) );
196
197 $class = implode( ' ', $classes );
198 if ( $echo ) {
199 echo $class;
200 }
201
202 return $class;
203 }
204 }
205
206
207 if ( ! function_exists('tutor_container_classes')) {
208 function tutor_container_classes( $echo = true ) {
209
210 $classes = apply_filters( 'tutor_container_classes', array(
211 'tutor-wrap tutor-courses-wrap',
212 'tutor-container'
213 ) );
214
215 $class = implode( ' ', $classes );
216
217 if ( $echo ) {
218 echo $class;
219 }
220
221 return $class;
222 }
223 }
224 if ( ! function_exists('tutor_post_class')) {
225 function tutor_post_class($default = '') {
226 $classes = apply_filters( 'tutor_post_class', array(
227 'tutor-wrap',
228 $default
229 ) );
230
231 post_class( $classes );
232 }
233 }
234
235 if ( ! function_exists('tutor_course_archive_filter_bar')) {
236 function tutor_course_archive_filter_bar() {
237 ob_start();
238 tutor_load_template( 'global.course-archive-filter-bar' );
239 $output = apply_filters( 'tutor_course_archive_filter_bar', ob_get_clean() );
240
241 echo $output;
242 }
243 }
244
245 /**
246 * Get the post thumbnail
247 */
248 if ( ! function_exists('get_tutor_course_thumbnail')) {
249 function get_tutor_course_thumbnail() {
250 $post_id = get_the_ID();
251 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
252
253 if ( $post_thumbnail_id ) {
254 $size = 'post-thumbnail';
255 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
256 $html = wp_get_attachment_image( $post_thumbnail_id, $size, false );
257 } else {
258 $placeHolderUrl = tutor()->url . 'assets/images/placeholder.jpg';
259 $html = '<img src="' . $placeHolderUrl . '" />';
260 }
261
262 echo $html;
263 }
264 }
265 /**
266 * Get the course/post thumbnail src
267 */
268 if ( ! function_exists('get_tutor_course_thumbnail_src')) {
269 function get_tutor_course_thumbnail_src() {
270 $post_id = get_the_ID();
271 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
272
273 if ( $post_thumbnail_id ) {
274 $size = 'post-thumbnail';
275 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
276 $src = wp_get_attachment_image_url( $post_thumbnail_id, $size, false );
277 } else {
278 $src = tutor()->url . 'assets/images/placeholder.jpg';
279 }
280
281 return $src;
282 }
283 }
284
285 if ( ! function_exists('tutor_course_loop_meta')) {
286 function tutor_course_loop_meta() {
287 ob_start();
288 tutor_load_template( 'loop.meta' );
289 $output = apply_filters( 'tutor_course_loop_meta', ob_get_clean() );
290
291 echo $output;
292 }
293 }
294
295 /**
296 * Get course author name in loop
297 *
298 * @since: v.1.0.0
299 */
300
301 if ( ! function_exists('tutor_course_loop_author')) {
302 function tutor_course_loop_author() {
303 ob_start();
304 tutor_load_template( 'loop.course-author' );
305 $output = apply_filters( 'tutor_course_loop_author', ob_get_clean() );
306
307 echo $output;
308 }
309 }
310
311 if ( ! function_exists('tutor_course_loop_price')) {
312 function tutor_course_loop_price() {
313 ob_start();
314
315 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
316 if ($tutor_course_sell_by){
317 tutor_load_template( 'loop.course-price-'.$tutor_course_sell_by );
318 }
319 $output = apply_filters( 'tutor_course_loop_price', ob_get_clean() );
320
321 echo $output;
322 }
323 }
324
325 if ( ! function_exists('tutor_course_loop_rating')) {
326 function tutor_course_loop_rating() {
327 ob_start();
328 tutor_load_template( 'loop.rating' );
329 $output = apply_filters( 'tutor_course_loop_rating', ob_get_clean() );
330
331 echo $output;
332 }
333 }
334
335 if ( ! function_exists('tutor_course_loop_add_to_cart')) {
336 function tutor_course_loop_add_to_cart($echo = true) {
337 ob_start();
338 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
339
340 if ($tutor_course_sell_by){
341 tutor_load_template( 'loop.add-to-cart-'.$tutor_course_sell_by );
342 }
343
344 $output = apply_filters( 'tutor_course_loop_add_to_cart_link', ob_get_clean() );
345
346 if ($echo){
347 echo $output;
348 }
349 return $output;
350 }
351 }
352
353
354
355 if ( ! function_exists('tutor_course_price')) {
356 function tutor_course_price() {
357 ob_start();
358 tutor_load_template( 'single.course.wc-price-html' );
359 $output = apply_filters( 'tutor_course_price', ob_get_clean() );
360
361 echo $output;
362 }
363 }
364
365
366 /**
367 * @param int $post_id
368 *
369 * echo the excerpt of TUTOR post type
370 *
371 * @since: v.1.0.0
372 */
373 if ( ! function_exists('tutor_the_excerpt')) {
374 function tutor_the_excerpt( $post_id = 0 ) {
375 if ( ! $post_id ) {
376 $post_id = get_the_ID();
377 }
378 echo tutor_get_the_excerpt( $post_id );
379 }
380 }
381 /**
382 * @param int $post_id
383 *
384 * @return mixed
385 *
386 * Return excerpt of TUTOR post type
387 *
388 * @since: v.1.0.0
389 */
390 if ( ! function_exists('tutor_get_the_excerpt')) {
391 function tutor_get_the_excerpt( $post_id = 0 ) {
392 if ( ! $post_id ) {
393 $post_id = get_the_ID();
394 }
395
396 $get_post = get_post($post_id);
397 return apply_filters( 'tutor_get_the_excerpt', $get_post->post_excerpt );
398 }
399 }
400
401 /**
402 * @return mixed
403 *
404 * return course author
405 *
406 * @since: v.1.0.0
407 */
408
409 if ( ! function_exists('get_tutor_course_author')) {
410 function get_tutor_course_author() {
411 global $post;
412 return apply_filters( 'get_tutor_course_author', get_the_author_meta( 'display_name', $post->post_author ) );
413 }
414 }
415
416 function get_tutor_course_author_id(){
417 global $post;
418 return $post->post_author;
419 }
420
421 /**
422 * @param int $course_id
423 *
424 * @return mixed
425 * Course benefits return array
426 *
427 * @since: v.1.0.0
428 */
429
430 if ( ! function_exists('tutor_course_benefits')) {
431 function tutor_course_benefits( $course_id = 0 ) {
432 if ( ! $course_id ) {
433 $course_id = get_the_ID();
434 }
435 $benefits = get_post_meta( $course_id, '_tutor_course_benefits', true );
436
437 $benefits_array = array();
438 if ($benefits){
439 $benefits_array = explode("\n", $benefits);
440 }
441
442 $array = array_filter(array_map('trim', $benefits_array));
443
444 return apply_filters( 'tutor_course/single/benefits', $array, $course_id );
445 }
446 }
447
448 /**
449 * @param bool $echo
450 *
451 * @return mixed
452 *
453 * Course single page benefits
454 *
455 * @since: v.1.0.0
456 */
457
458 if ( ! function_exists('tutor_course_benefits_html')) {
459 function tutor_course_benefits_html($echo = true) {
460 ob_start();
461 tutor_load_template( 'single.course.course-benefits' );
462 $output = apply_filters( 'tutor_course/single/benefits_html', ob_get_clean() );
463
464 if ($echo){
465 echo $output;
466 }
467 return $output;
468 }
469 }
470
471 /**
472 * @param bool $echo
473 *
474 * @return mixed|void
475 *
476 * Return Topics HTML
477 *
478 * @since: v.1.0.0
479 */
480 if ( ! function_exists('tutor_course_topics')) {
481 function tutor_course_topics( $echo = true ) {
482 ob_start();
483 tutor_load_template( 'single.course.course-topics' );
484 $output = apply_filters( 'tutor_course/single/topics', ob_get_clean() );
485 wp_reset_postdata();
486
487 if ( $echo ) {
488 echo $output;
489 }
490
491 return $output;
492 }
493 }
494
495 /**
496 * @param int $course_id
497 *
498 * @return mixed|void
499 *
500 * return course requirements in array
501 *
502 * @since: v.1.0.0
503 */
504 if ( ! function_exists('tutor_course_requirements')) {
505 function tutor_course_requirements( $course_id = 0 ) {
506 if ( ! $course_id ) {
507 $course_id = get_the_ID();
508 }
509 $requirements = get_post_meta( $course_id, '_tutor_course_requirements', true );
510
511 $requirements_array = array();
512 if ($requirements){
513 $requirements_array = explode("\n", $requirements);
514 }
515
516 $array = array_filter(array_map('trim', $requirements_array));
517 return apply_filters( 'tutor_course/single/requirements', $array, $course_id );
518 }
519 }
520
521 /**
522 * @param bool $echo
523 *
524 * @return mixed|void
525 *
526 * Return course requirements in course single page
527 *
528 * @since: v.1.0.0
529 */
530 if ( ! function_exists('tutor_course_requirements_html')) {
531 function tutor_course_requirements_html($echo = true) {
532 ob_start();
533 tutor_load_template( 'single.course.course-requirements' );
534 $output = apply_filters( 'tutor_course/single/requirements_html', ob_get_clean() );
535
536 if ($echo){
537 echo $output;
538 }
539 return $output;
540 }
541 }
542
543
544 /**
545 * @param int $course_id
546 *
547 * @return mixed|void
548 *
549 * Return target audience in course single page
550 *
551 * @since: v.1.0.0
552 */
553 if ( ! function_exists('tutor_course_target_audience')) {
554 function tutor_course_target_audience( $course_id = 0 ) {
555 if ( ! $course_id ) {
556 $course_id = get_the_ID();
557 }
558 $target_audience = get_post_meta( $course_id, '_tutor_course_target_audience', true );
559
560 $target_audience_array = array();
561 if ($target_audience){
562 $target_audience_array = explode("\n", $target_audience);
563 }
564
565 $array = array_filter(array_map('trim', $target_audience_array));
566 return apply_filters( 'tutor_course/single/target_audience', $array, $course_id );
567 }
568 }
569
570 /**
571 * @param bool $echo
572 *
573 * @return mixed|void
574 *
575 * Return target audience in course single page
576 *
577 * @since: v.1.0.0
578 */
579 if ( ! function_exists('tutor_course_target_audience_html')) {
580 function tutor_course_target_audience_html($echo = true) {
581 ob_start();
582 tutor_load_template( 'single.course.course-target-audience' );
583 $output = apply_filters( 'tutor_course/single/audience_html', ob_get_clean() );
584
585 if ($echo){
586 echo $output;
587 }
588 return $output;
589 }
590 }
591
592
593 if ( ! function_exists('tutor_course_material_includes')) {
594 function tutor_course_material_includes( $course_id = 0 ) {
595 if ( ! $course_id ) {
596 $course_id = get_the_ID();
597 }
598 $target_audience = get_post_meta( $course_id, '_tutor_course_material_includes', true );
599
600 $target_audience_array = array();
601 if ($target_audience){
602 $target_audience_array = explode("\n", $target_audience);
603 }
604
605 $array = array_filter(array_map('trim', $target_audience_array));
606 return apply_filters( 'tutor_course/single/material_includes', $array, $course_id );
607 }
608 }
609
610 if ( ! function_exists('tutor_course_material_includes_html')) {
611 function tutor_course_material_includes_html($echo = true) {
612 ob_start();
613 tutor_load_template( 'single.course.material-includes' );
614 $output = apply_filters( 'tutor_course/single/material_includes', ob_get_clean() );
615
616 if ($echo){
617 echo $output;
618 }
619 return $output;
620 }
621 }
622
623 //tutor_course_material_includes_html
624
625
626 if ( ! function_exists('tutor_course_instructors_html')) {
627 function tutor_course_instructors_html($echo = true) {
628 $display_course_instructors = tutor_utils()->get_option('display_course_instructors');
629 if ( ! $display_course_instructors){
630 return null;
631 }
632
633 ob_start();
634 tutor_load_template( 'single.course.instructors' );
635 $output = apply_filters( 'tutor_course/single/instructors_html', ob_get_clean() );
636
637 if ($echo){
638 echo $output;
639 }
640 return $output;
641 }
642 }
643
644 if ( ! function_exists('tutor_course_target_reviews_html')) {
645 function tutor_course_target_reviews_html($echo = true) {
646 ob_start();
647 tutor_load_template( 'single.course.reviews' );
648 $output = apply_filters( 'tutor_course/single/reviews_html', ob_get_clean() );
649
650 if ($echo){
651 echo $output;
652 }
653 return $output;
654 }
655 }
656
657 if ( ! function_exists('tutor_course_target_review_form_html')) {
658 function tutor_course_target_review_form_html($echo = true) {
659 ob_start();
660 tutor_load_template( 'single.course.review-form' );
661 $output = apply_filters( 'tutor_course/single/reviews_form', ob_get_clean() );
662
663 if ($echo){
664 echo $output;
665 }
666
667 return $output;
668
669 }
670 }
671
672 /**
673 * @param bool $echo
674 *
675 * @return mixed
676 *
677 * Course single page main content / description
678 *
679 * @since: v.1.0.0
680 */
681 if ( ! function_exists('tutor_course_content')) {
682 function tutor_course_content( $echo = true ) {
683 ob_start();
684 tutor_load_template( 'single.course.course-content' );
685 $output = apply_filters( 'tutor_course/single/content', ob_get_clean() );
686
687 if ( $echo ) {
688 echo $output;
689 }
690
691 return $output;
692 }
693 }
694
695 /**
696 * Course single page lead info
697 *
698 * @since: v.1.0.0
699 */
700 if ( ! function_exists('tutor_course_lead_info')) {
701 function tutor_course_lead_info( $echo = true ) {
702 ob_start();
703
704 $course_id = get_the_ID();
705 $course_post_type = tutor()->course_post_type;
706 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
707
708 if ($queryCourse->have_posts()){
709 while ($queryCourse->have_posts()){
710 $queryCourse->the_post();
711 tutor_load_template( 'single.course.lead-info' );
712 }
713 wp_reset_postdata();
714 }
715
716 $output = apply_filters( 'tutor_course/single/lead_info', ob_get_clean() );
717
718 if ( $echo ) {
719 echo $output;
720 }
721 return $output;
722 }
723 }
724
725 /**
726 * @param bool $echo
727 *
728 * @return mixed|void
729 */
730
731 if ( ! function_exists('tutor_course_enrolled_lead_info')) {
732 function tutor_course_enrolled_lead_info( $echo = true ) {
733 ob_start();
734
735 $course_id = get_the_ID();
736 $course_post_type = tutor()->course_post_type;
737 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
738
739 if ( $queryCourse->have_posts() ) {
740 while ( $queryCourse->have_posts() ) {
741 $queryCourse->the_post();
742 tutor_load_template( 'single.course.enrolled.lead-info' );
743 }
744 wp_reset_postdata();
745 }
746
747 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
748
749 if ( $echo ) {
750 echo $output;
751 }
752
753 return $output;
754 }
755 }
756
757 if ( ! function_exists('tutor_lesson_lead_info')) {
758 function tutor_lesson_lead_info( $lesson_id = 0, $echo = true ) {
759 if ( ! $lesson_id ) {
760 $lesson_id = get_the_ID();
761 }
762
763 ob_start();
764 $course_id = tutor_utils()->get_course_id_by_lesson( $lesson_id );
765 $course_post_type = tutor()->course_post_type;
766 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
767
768 if ( $queryCourse->have_posts() ) {
769 while ( $queryCourse->have_posts() ) {
770 $queryCourse->the_post();
771 tutor_load_template( 'single.course.enrolled.lead-info' );
772 }
773 wp_reset_postdata();
774 }
775 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
776
777 if ( $echo ) {
778 echo $output;
779 }
780
781 return $output;
782
783 }
784 }
785 /**
786 * @param bool $echo
787 *
788 * @return mixed
789 *
790 * Return enroll box in single course
791 *
792 * @since: v.1.0.0
793 */
794
795 if ( ! function_exists('tutor_course_enroll_box')) {
796 function tutor_course_enroll_box( $echo = true ) {
797 $isLoggedIn = is_user_logged_in();
798 $enrolled = tutor_utils()->is_enrolled();
799
800 ob_start();
801
802 if ( $enrolled ) {
803 tutor_load_template( 'single.course.course-enrolled-box' );
804 $output = apply_filters( 'tutor_course/single/enrolled', ob_get_clean() );
805 } else {
806 tutor_load_template( 'single.course.course-enroll-box' );
807 $output = apply_filters( 'tutor_course/single/enroll', ob_get_clean() );
808 }
809
810 if ( $echo ) {
811 echo $output;
812 }
813
814 return $output;
815 }
816 }
817
818 function tutor_single_course_add_to_cart($echo = true){
819 ob_start();
820
821 $isLoggedIn = is_user_logged_in();
822
823 if ($isLoggedIn) {
824 tutor_load_template( 'single.course.add-to-cart' );
825 $output = apply_filters( 'tutor_course/single/add-to-cart', ob_get_clean() );
826
827 }else{
828 tutor_load_template( 'single.course.login' );
829 $output = apply_filters( 'tutor_course/global/login', ob_get_clean() );
830 }
831
832 if ( $echo ) {
833 echo $output;
834 }
835
836 return $output;
837 }
838
839 if ( ! function_exists('tutor_course_enrolled_nav')) {
840 function tutor_course_enrolled_nav($echo = true) {
841 $course_post_type = tutor()->course_post_type;
842 $lesson_post_type = tutor()->lesson_post_type;
843
844 ob_start();
845 global $post;
846
847 if ( ! empty($post->post_type) && $post->post_type === $course_post_type){
848 tutor_load_template( 'single.course.enrolled.nav' );
849 }elseif(! empty($post->post_type) && $post->post_type === $lesson_post_type){
850 $lesson_id = get_the_ID();
851 $course_id = tutor_utils()->get_course_id_by_lesson($lesson_id);
852
853 $course_post_type = tutor()->course_post_type;
854 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
855
856 if ($queryCourse->have_posts()){
857 while ($queryCourse->have_posts()){
858 $queryCourse->the_post();
859 tutor_load_template( 'single.course.enrolled.nav' );
860 }
861 wp_reset_postdata();
862 }
863 }
864 $output = apply_filters( 'tutor_course/single/enrolled/nav', ob_get_clean() );
865
866 if ( $echo ) {
867 echo $output;
868 }
869 return $output;
870 }
871 }
872
873 if ( ! function_exists('tutor_course_video')){
874 function tutor_course_video($echo = true){
875 ob_start();
876 tutor_load_template( 'single.video.video' );
877 $output = apply_filters( 'tutor_course/single/video', ob_get_clean() );
878
879 if ( $echo ) {
880 echo $output;
881 }
882 return $output;
883 }
884 }
885
886 if ( ! function_exists('tutor_lesson_video')){
887 function tutor_lesson_video($echo = true){
888 ob_start();
889 tutor_load_template( 'single.video.video' );
890 $output = apply_filters( 'tutor_lesson/single/video', ob_get_clean() );
891
892 if ( $echo ) {
893 echo $output;
894 }
895 return $output;
896 }
897 }
898
899 /**
900 *
901 * Get all lessons attachments
902 *
903 * @param bool $echo
904 *
905 * @return mixed
906 *
907 * @since v.1.0.0
908 */
909 if ( ! function_exists('get_tutor_posts_attachments')){
910 function get_tutor_posts_attachments($echo = true){
911 ob_start();
912 tutor_load_template( 'global.attachments' );
913 $output = apply_filters( 'tutor_lesson/single/attachments', ob_get_clean() );
914
915 if ( $echo ) {
916 echo $output;
917 }
918 return $output;
919 }
920 }
921
922 /**
923 * @param bool $echo
924 *
925 * @return mixed
926 *
927 * Get the lessons with topics
928 *
929 * @since v.1.0.0
930 */
931 if ( ! function_exists('tutor_lessons_sidebar')) {
932 function tutor_lessons_sidebar( $echo = true ) {
933 ob_start();
934 tutor_load_template( 'single.lesson.lesson_sidebar' );
935 $output = apply_filters( 'tutor_lesson/single/lesson_sidebar', ob_get_clean() );
936
937 if ( $echo ) {
938 echo $output;
939 }
940
941 return $output;
942 }
943 }
944
945 /**
946 * @param bool $echo
947 *
948 * @return mixed
949 *
950 * Render Lesson Main Content
951 * @since v.1.0.0
952 */
953 if ( ! function_exists('tutor_lesson_content')) {
954 function tutor_lesson_content( $echo = true ) {
955 ob_start();
956 tutor_load_template( 'single.lesson.content' );
957 $output = apply_filters( 'tutor_lesson/single/content', ob_get_clean() );
958
959 if ( $echo ) {
960 echo $output;
961 }
962
963 return $output;
964 }
965 }
966
967 if ( ! function_exists('tutor_lesson_mark_complete_html')) {
968 function tutor_lesson_mark_complete_html( $echo = true ) {
969 ob_start();
970 tutor_load_template( 'single.lesson.complete_form' );
971 $output = apply_filters( 'tutor_lesson/single/complete_form', ob_get_clean() );
972
973 if ( $echo ) {
974 echo $output;
975 }
976
977 return $output;
978 }
979 }
980
981 if ( ! function_exists('tutor_course_mark_complete_html')) {
982 function tutor_course_mark_complete_html( $echo = true ) {
983 ob_start();
984 tutor_load_template( 'single.course.complete_form' );
985 $output = apply_filters( 'tutor_course/single/complete_form', ob_get_clean() );
986
987 if ( $echo ) {
988 echo $output;
989 }
990
991 return $output;
992 }
993 }
994
995
996 /**
997 * @param bool $echo
998 *
999 * @return mixed
1000 *
1001 * @show progress bar about course complete
1002 *
1003 * @since v.1.0.0
1004 */
1005
1006 if ( ! function_exists('tutor_course_completing_progress_bar')) {
1007 function tutor_course_completing_progress_bar( $echo = true ) {
1008 ob_start();
1009 tutor_load_template( 'single.course.enrolled.completing-progress' );
1010 $output = apply_filters( 'tutor_course/single/completing-progress-bar', ob_get_clean() );
1011
1012 if ( $echo ) {
1013 echo $output;
1014 }
1015
1016 return $output;
1017 }
1018 }
1019
1020 function tutor_course_question_and_answer($echo = true){
1021 ob_start();
1022 tutor_load_template( 'single.course.enrolled.question_and_answer' );
1023 $output = apply_filters( 'tutor_course/single/question_and_answer', ob_get_clean() );
1024
1025 if ( $echo ) {
1026 echo $output;
1027 }
1028
1029 return $output;
1030 }
1031
1032
1033 function tutor_course_announcements($echo = true){
1034 ob_start();
1035 tutor_load_template( 'single.course.enrolled.announcements' );
1036 $output = apply_filters( 'tutor_course/single/announcements', ob_get_clean() );
1037
1038 if ( $echo ) {
1039 echo $output;
1040 }
1041
1042 return $output;
1043 }
1044
1045 function tutor_single_quiz_top($echo = true){
1046 ob_start();
1047 tutor_load_template( 'single.quiz.top' );
1048 $output = apply_filters( 'tutor_single_quiz/top', ob_get_clean() );
1049
1050 if ( $echo ) {
1051 echo $output;
1052 }
1053 return $output;
1054 }
1055
1056 function tutor_single_quiz_body($echo = true){
1057 ob_start();
1058 tutor_load_template( 'single.quiz.body' );
1059 $output = apply_filters( 'tutor_single_quiz/body', ob_get_clean() );
1060
1061 if ( $echo ) {
1062 echo $output;
1063 }
1064 return $output;
1065 }
1066
1067 function tutor_single_quiz_no_course_belongs($echo = true){
1068 ob_start();
1069 tutor_load_template( 'single.quiz.no_course_belongs' );
1070 $output = apply_filters( 'tutor_single_quiz/no_course_belongs', ob_get_clean() );
1071
1072 if ( $echo ) {
1073 echo $output;
1074 }
1075 return $output;
1076 }
1077
1078 function single_quiz_contents($echo = true){
1079
1080 ob_start();
1081 tutor_load_template( 'single.quiz.single_quiz_contents' );
1082 $output = apply_filters( 'tutor_single_quiz/single_quiz_contents', ob_get_clean() );
1083
1084 if ( $echo ) {
1085 echo $output;
1086 }
1087 return $output;
1088 }
1089
1090 function get_tutor_course_level($course_id = 0){
1091 if ( ! $course_id){
1092 $course_id = get_the_ID();
1093 }
1094 if ( ! $course_id){
1095 return '';
1096 }
1097
1098 $course_level = get_post_meta($course_id, '_tutor_course_level', true);
1099
1100 if ($course_level){
1101 return tutor_utils()->course_levels($course_level);
1102 }
1103 return false;
1104 }
1105
1106 if ( ! function_exists('get_tutor_course_duration_context')) {
1107 function get_tutor_course_duration_context( $course_id = 0 ) {
1108 if ( ! $course_id ) {
1109 $course_id = get_the_ID();
1110 }
1111 if ( ! $course_id ) {
1112 return '';
1113 }
1114 $duration = get_post_meta( $course_id, '_course_duration', true );
1115 $durationHours = tutor_utils()->avalue_dot( 'hours', $duration );
1116 $durationMinutes = tutor_utils()->avalue_dot( 'minutes', $duration );
1117 $durationSeconds = tutor_utils()->avalue_dot( 'seconds', $duration );
1118
1119 if ( $duration ) {
1120 $output = '';
1121 if ( $durationHours > 0 ) {
1122 $output .= $durationHours . "h ";
1123 }
1124
1125 if ( $durationMinutes > 0 ) {
1126 $output .= $durationMinutes . "m ";
1127 }
1128
1129 if ( $durationSeconds > 0 ) {
1130 $output .= $durationSeconds ."s ";
1131 }
1132
1133 return $output;
1134 }
1135
1136 return false;
1137 }
1138 }
1139 if ( ! function_exists('get_tutor_course_categories')){
1140 function get_tutor_course_categories($course_id = 0){
1141 if ( ! $course_id ) {
1142 $course_id = get_the_ID();
1143 }
1144 $terms = get_the_terms( $course_id, 'course-category' );
1145
1146 return $terms;
1147 }
1148 }
1149 if ( ! function_exists('get_tutor_course_tags')){
1150 function get_tutor_course_tags($course_id = 0){
1151 if ( ! $course_id ) {
1152 $course_id = get_the_ID();
1153 }
1154 $terms = get_the_terms( $course_id, 'course-tag' );
1155
1156 return $terms;
1157 }
1158 }
1159
1160 if ( ! function_exists('tutor_course_tags_html')) {
1161 function tutor_course_tags_html( $echo = true ) {
1162 ob_start();
1163 tutor_load_template( 'single.course.tags' );
1164 $output = apply_filters( 'tutor_course/single/tags_html', ob_get_clean() );
1165
1166 if ( $echo ) {
1167 echo $output;
1168 }
1169
1170 return $output;
1171 }
1172 }
1173
1174 function tutor_lesson_sidebar_question_and_answer($echo = true){
1175 ob_start();
1176 tutor_load_template( 'single.lesson.sidebar_question_and_answer' );
1177 $output = apply_filters( 'tutor_lesson/single/sidebar_question_and_answer', ob_get_clean() );
1178
1179 if ( $echo ) {
1180 echo $output;
1181 }
1182
1183 return $output;
1184 }