PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 1.1.0
Tutor LMS – eLearning and online course solution v1.1.0
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 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
1215 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($url = false) {
250 $post_id = get_the_ID();
251 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
252
253 if ( $post_thumbnail_id ) {
254
255 $size = 'post-thumbnail';
256 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
257 if ($url){
258 return wp_get_attachment_image_url($post_thumbnail_id, $size);
259 }
260
261 $html = wp_get_attachment_image( $post_thumbnail_id, $size, false );
262 } else {
263 $placeHolderUrl = tutor()->url . 'assets/images/placeholder.jpg';
264 if ($url){
265 return $placeHolderUrl;
266 }
267 $html = '<img src="' . $placeHolderUrl . '" />';
268 }
269
270 echo $html;
271 }
272 }
273 /**
274 * Get the course/post thumbnail src
275 */
276 if ( ! function_exists('get_tutor_course_thumbnail_src')) {
277 function get_tutor_course_thumbnail_src() {
278 $post_id = get_the_ID();
279 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
280
281 if ( $post_thumbnail_id ) {
282 $size = 'post-thumbnail';
283 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
284 $src = wp_get_attachment_image_url( $post_thumbnail_id, $size, false );
285 } else {
286 $src = tutor()->url . 'assets/images/placeholder.jpg';
287 }
288
289 return $src;
290 }
291 }
292
293 if ( ! function_exists('tutor_course_loop_meta')) {
294 function tutor_course_loop_meta() {
295 ob_start();
296 tutor_load_template( 'loop.meta' );
297 $output = apply_filters( 'tutor_course_loop_meta', ob_get_clean() );
298
299 echo $output;
300 }
301 }
302
303 /**
304 * Get course author name in loop
305 *
306 * @since: v.1.0.0
307 */
308
309 if ( ! function_exists('tutor_course_loop_author')) {
310 function tutor_course_loop_author() {
311 ob_start();
312 tutor_load_template( 'loop.course-author' );
313 $output = apply_filters( 'tutor_course_loop_author', ob_get_clean() );
314
315 echo $output;
316 }
317 }
318
319 if ( ! function_exists('tutor_course_loop_price')) {
320 function tutor_course_loop_price() {
321 ob_start();
322
323 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
324 if ($tutor_course_sell_by){
325 tutor_load_template( 'loop.course-price-'.$tutor_course_sell_by );
326 }else{
327 tutor_load_template( 'loop.course-price' );
328 }
329 $output = apply_filters( 'tutor_course_loop_price', ob_get_clean() );
330
331 echo $output;
332 }
333 }
334
335 if ( ! function_exists('tutor_course_loop_rating')) {
336 function tutor_course_loop_rating() {
337 ob_start();
338 tutor_load_template( 'loop.rating' );
339 $output = apply_filters( 'tutor_course_loop_rating', ob_get_clean() );
340
341 echo $output;
342 }
343 }
344
345 if ( ! function_exists('tutor_course_loop_add_to_cart')) {
346 function tutor_course_loop_add_to_cart($echo = true) {
347 ob_start();
348 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
349
350 if ($tutor_course_sell_by){
351 tutor_load_template( 'loop.add-to-cart-'.$tutor_course_sell_by );
352 }
353
354 $output = apply_filters( 'tutor_course_loop_add_to_cart_link', ob_get_clean() );
355
356 if ($echo){
357 echo $output;
358 }
359 return $output;
360 }
361 }
362
363
364
365 if ( ! function_exists('tutor_course_price')) {
366 function tutor_course_price() {
367 ob_start();
368 tutor_load_template( 'single.course.wc-price-html' );
369 $output = apply_filters( 'tutor_course_price', ob_get_clean() );
370
371 echo $output;
372 }
373 }
374
375
376 /**
377 * @param int $post_id
378 *
379 * echo the excerpt of TUTOR post type
380 *
381 * @since: v.1.0.0
382 */
383 if ( ! function_exists('tutor_the_excerpt')) {
384 function tutor_the_excerpt( $post_id = 0 ) {
385 if ( ! $post_id ) {
386 $post_id = get_the_ID();
387 }
388 echo tutor_get_the_excerpt( $post_id );
389 }
390 }
391 /**
392 * @param int $post_id
393 *
394 * @return mixed
395 *
396 * Return excerpt of TUTOR post type
397 *
398 * @since: v.1.0.0
399 */
400 if ( ! function_exists('tutor_get_the_excerpt')) {
401 function tutor_get_the_excerpt( $post_id = 0 ) {
402 if ( ! $post_id ) {
403 $post_id = get_the_ID();
404 }
405
406 $get_post = get_post($post_id);
407 return apply_filters( 'tutor_get_the_excerpt', $get_post->post_excerpt );
408 }
409 }
410
411 /**
412 * @return mixed
413 *
414 * return course author
415 *
416 * @since: v.1.0.0
417 */
418
419 if ( ! function_exists('get_tutor_course_author')) {
420 function get_tutor_course_author() {
421 global $post;
422 return apply_filters( 'get_tutor_course_author', get_the_author_meta( 'display_name', $post->post_author ) );
423 }
424 }
425
426 function get_tutor_course_author_id(){
427 global $post;
428 return $post->post_author;
429 }
430
431 /**
432 * @param int $course_id
433 *
434 * @return mixed
435 * Course benefits return array
436 *
437 * @since: v.1.0.0
438 */
439
440 if ( ! function_exists('tutor_course_benefits')) {
441 function tutor_course_benefits( $course_id = 0 ) {
442 if ( ! $course_id ) {
443 $course_id = get_the_ID();
444 }
445 $benefits = get_post_meta( $course_id, '_tutor_course_benefits', true );
446
447 $benefits_array = array();
448 if ($benefits){
449 $benefits_array = explode("\n", $benefits);
450 }
451
452 $array = array_filter(array_map('trim', $benefits_array));
453
454 return apply_filters( 'tutor_course/single/benefits', $array, $course_id );
455 }
456 }
457
458 /**
459 * @param bool $echo
460 *
461 * @return mixed
462 *
463 * Course single page benefits
464 *
465 * @since: v.1.0.0
466 */
467
468 if ( ! function_exists('tutor_course_benefits_html')) {
469 function tutor_course_benefits_html($echo = true) {
470 ob_start();
471 tutor_load_template( 'single.course.course-benefits' );
472 $output = apply_filters( 'tutor_course/single/benefits_html', ob_get_clean() );
473
474 if ($echo){
475 echo $output;
476 }
477 return $output;
478 }
479 }
480
481 /**
482 * @param bool $echo
483 *
484 * @return mixed|void
485 *
486 * Return Topics HTML
487 *
488 * @since: v.1.0.0
489 */
490 if ( ! function_exists('tutor_course_topics')) {
491 function tutor_course_topics( $echo = true ) {
492 ob_start();
493 tutor_load_template( 'single.course.course-topics' );
494 $output = apply_filters( 'tutor_course/single/topics', ob_get_clean() );
495 wp_reset_postdata();
496
497 if ( $echo ) {
498 echo $output;
499 }
500
501 return $output;
502 }
503 }
504
505 /**
506 * @param int $course_id
507 *
508 * @return mixed|void
509 *
510 * return course requirements in array
511 *
512 * @since: v.1.0.0
513 */
514 if ( ! function_exists('tutor_course_requirements')) {
515 function tutor_course_requirements( $course_id = 0 ) {
516 if ( ! $course_id ) {
517 $course_id = get_the_ID();
518 }
519 $requirements = get_post_meta( $course_id, '_tutor_course_requirements', true );
520
521 $requirements_array = array();
522 if ($requirements){
523 $requirements_array = explode("\n", $requirements);
524 }
525
526 $array = array_filter(array_map('trim', $requirements_array));
527 return apply_filters( 'tutor_course/single/requirements', $array, $course_id );
528 }
529 }
530
531 /**
532 * @param bool $echo
533 *
534 * @return mixed|void
535 *
536 * Return course requirements in course single page
537 *
538 * @since: v.1.0.0
539 */
540 if ( ! function_exists('tutor_course_requirements_html')) {
541 function tutor_course_requirements_html($echo = true) {
542 ob_start();
543 tutor_load_template( 'single.course.course-requirements' );
544 $output = apply_filters( 'tutor_course/single/requirements_html', ob_get_clean() );
545
546 if ($echo){
547 echo $output;
548 }
549 return $output;
550 }
551 }
552
553
554 /**
555 * @param int $course_id
556 *
557 * @return mixed|void
558 *
559 * Return target audience in course single page
560 *
561 * @since: v.1.0.0
562 */
563 if ( ! function_exists('tutor_course_target_audience')) {
564 function tutor_course_target_audience( $course_id = 0 ) {
565 if ( ! $course_id ) {
566 $course_id = get_the_ID();
567 }
568 $target_audience = get_post_meta( $course_id, '_tutor_course_target_audience', true );
569
570 $target_audience_array = array();
571 if ($target_audience){
572 $target_audience_array = explode("\n", $target_audience);
573 }
574
575 $array = array_filter(array_map('trim', $target_audience_array));
576 return apply_filters( 'tutor_course/single/target_audience', $array, $course_id );
577 }
578 }
579
580 /**
581 * @param bool $echo
582 *
583 * @return mixed|void
584 *
585 * Return target audience in course single page
586 *
587 * @since: v.1.0.0
588 */
589 if ( ! function_exists('tutor_course_target_audience_html')) {
590 function tutor_course_target_audience_html($echo = true) {
591 ob_start();
592 tutor_load_template( 'single.course.course-target-audience' );
593 $output = apply_filters( 'tutor_course/single/audience_html', ob_get_clean() );
594
595 if ($echo){
596 echo $output;
597 }
598 return $output;
599 }
600 }
601
602
603 if ( ! function_exists('tutor_course_material_includes')) {
604 function tutor_course_material_includes( $course_id = 0 ) {
605 if ( ! $course_id ) {
606 $course_id = get_the_ID();
607 }
608 $target_audience = get_post_meta( $course_id, '_tutor_course_material_includes', true );
609
610 $target_audience_array = array();
611 if ($target_audience){
612 $target_audience_array = explode("\n", $target_audience);
613 }
614
615 $array = array_filter(array_map('trim', $target_audience_array));
616 return apply_filters( 'tutor_course/single/material_includes', $array, $course_id );
617 }
618 }
619
620 if ( ! function_exists('tutor_course_material_includes_html')) {
621 function tutor_course_material_includes_html($echo = true) {
622 ob_start();
623 tutor_load_template( 'single.course.material-includes' );
624 $output = apply_filters( 'tutor_course/single/material_includes', ob_get_clean() );
625
626 if ($echo){
627 echo $output;
628 }
629 return $output;
630 }
631 }
632
633 //tutor_course_material_includes_html
634
635
636 if ( ! function_exists('tutor_course_instructors_html')) {
637 function tutor_course_instructors_html($echo = true) {
638 $display_course_instructors = tutor_utils()->get_option('display_course_instructors');
639 if ( ! $display_course_instructors){
640 return null;
641 }
642
643 ob_start();
644 tutor_load_template( 'single.course.instructors' );
645 $output = apply_filters( 'tutor_course/single/instructors_html', ob_get_clean() );
646
647 if ($echo){
648 echo $output;
649 }
650 return $output;
651 }
652 }
653
654 if ( ! function_exists('tutor_course_target_reviews_html')) {
655 function tutor_course_target_reviews_html($echo = true) {
656 ob_start();
657 tutor_load_template( 'single.course.reviews' );
658 $output = apply_filters( 'tutor_course/single/reviews_html', ob_get_clean() );
659
660 if ($echo){
661 echo $output;
662 }
663 return $output;
664 }
665 }
666
667 if ( ! function_exists('tutor_course_target_review_form_html')) {
668 function tutor_course_target_review_form_html($echo = true) {
669 ob_start();
670 tutor_load_template( 'single.course.review-form' );
671 $output = apply_filters( 'tutor_course/single/reviews_form', ob_get_clean() );
672
673 if ($echo){
674 echo $output;
675 }
676
677 return $output;
678
679 }
680 }
681
682 /**
683 * @param bool $echo
684 *
685 * @return mixed
686 *
687 * Course single page main content / description
688 *
689 * @since: v.1.0.0
690 */
691 if ( ! function_exists('tutor_course_content')) {
692 function tutor_course_content( $echo = true ) {
693 ob_start();
694 tutor_load_template( 'single.course.course-content' );
695 $output = apply_filters( 'tutor_course/single/content', ob_get_clean() );
696
697 if ( $echo ) {
698 echo $output;
699 }
700
701 return $output;
702 }
703 }
704
705 /**
706 * Course single page lead info
707 *
708 * @since: v.1.0.0
709 */
710 if ( ! function_exists('tutor_course_lead_info')) {
711 function tutor_course_lead_info( $echo = true ) {
712 ob_start();
713
714 $course_id = get_the_ID();
715 $course_post_type = tutor()->course_post_type;
716 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
717
718 if ($queryCourse->have_posts()){
719 while ($queryCourse->have_posts()){
720 $queryCourse->the_post();
721 tutor_load_template( 'single.course.lead-info' );
722 }
723 wp_reset_postdata();
724 }
725
726 $output = apply_filters( 'tutor_course/single/lead_info', ob_get_clean() );
727
728 if ( $echo ) {
729 echo $output;
730 }
731 return $output;
732 }
733 }
734
735 /**
736 * @param bool $echo
737 *
738 * @return mixed|void
739 */
740
741 if ( ! function_exists('tutor_course_enrolled_lead_info')) {
742 function tutor_course_enrolled_lead_info( $echo = true ) {
743 ob_start();
744
745 $course_id = get_the_ID();
746 $course_post_type = tutor()->course_post_type;
747 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
748
749 if ( $queryCourse->have_posts() ) {
750 while ( $queryCourse->have_posts() ) {
751 $queryCourse->the_post();
752 tutor_load_template( 'single.course.enrolled.lead-info' );
753 }
754 wp_reset_postdata();
755 }
756
757 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
758
759 if ( $echo ) {
760 echo $output;
761 }
762
763 return $output;
764 }
765 }
766
767 if ( ! function_exists('tutor_lesson_lead_info')) {
768 function tutor_lesson_lead_info( $lesson_id = 0, $echo = true ) {
769 if ( ! $lesson_id ) {
770 $lesson_id = get_the_ID();
771 }
772
773 ob_start();
774 $course_id = tutor_utils()->get_course_id_by_lesson( $lesson_id );
775 $course_post_type = tutor()->course_post_type;
776 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
777
778 if ( $queryCourse->have_posts() ) {
779 while ( $queryCourse->have_posts() ) {
780 $queryCourse->the_post();
781 tutor_load_template( 'single.course.enrolled.lead-info' );
782 }
783 wp_reset_postdata();
784 }
785 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
786
787 if ( $echo ) {
788 echo $output;
789 }
790
791 return $output;
792
793 }
794 }
795 /**
796 * @param bool $echo
797 *
798 * @return mixed
799 *
800 * Return enroll box in single course
801 *
802 * @since: v.1.0.0
803 */
804
805 if ( ! function_exists('tutor_course_enroll_box')) {
806 function tutor_course_enroll_box( $echo = true ) {
807 $isLoggedIn = is_user_logged_in();
808 $enrolled = tutor_utils()->is_enrolled();
809
810 ob_start();
811
812 if ( $enrolled ) {
813 tutor_load_template( 'single.course.course-enrolled-box' );
814 $output = apply_filters( 'tutor_course/single/enrolled', ob_get_clean() );
815 } else {
816 tutor_load_template( 'single.course.course-enroll-box' );
817 $output = apply_filters( 'tutor_course/single/enroll', ob_get_clean() );
818 }
819
820 if ( $echo ) {
821 echo $output;
822 }
823
824 return $output;
825 }
826 }
827
828 function tutor_single_course_add_to_cart($echo = true){
829 ob_start();
830
831 $isLoggedIn = is_user_logged_in();
832 $output = '';
833
834 tutor_load_template( 'single.course.add-to-cart' );
835 $output .= apply_filters( 'tutor_course/single/add-to-cart', ob_get_clean() );
836
837 if ( ! $isLoggedIn){
838 ob_start();
839 tutor_load_template( 'single.course.login' );
840 $login_form = apply_filters( 'tutor_course/global/login', ob_get_clean() );
841
842 $output .= "<div class='tutor-cart-box-login-form' style='display: none;'><div class='tutor-cart-box-login-form-inner'><button class='tutor-popup-form-close tutor-icon-line-cross'></button>{$login_form}</div></div>";
843 }
844
845 if ( $echo ) {
846 echo $output;
847 }
848
849 return $output;
850 }
851
852 if ( ! function_exists('tutor_course_enrolled_nav')) {
853 function tutor_course_enrolled_nav($echo = true) {
854 $course_post_type = tutor()->course_post_type;
855 $lesson_post_type = tutor()->lesson_post_type;
856
857 ob_start();
858 global $post;
859
860 if ( ! empty($post->post_type) && $post->post_type === $course_post_type){
861 tutor_load_template( 'single.course.enrolled.nav' );
862 }elseif(! empty($post->post_type) && $post->post_type === $lesson_post_type){
863 $lesson_id = get_the_ID();
864 $course_id = tutor_utils()->get_course_id_by_lesson($lesson_id);
865
866 $course_post_type = tutor()->course_post_type;
867 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
868
869 if ($queryCourse->have_posts()){
870 while ($queryCourse->have_posts()){
871 $queryCourse->the_post();
872 tutor_load_template( 'single.course.enrolled.nav' );
873 }
874 wp_reset_postdata();
875 }
876 }
877 $output = apply_filters( 'tutor_course/single/enrolled/nav', ob_get_clean() );
878
879 if ( $echo ) {
880 echo $output;
881 }
882 return $output;
883 }
884 }
885
886 if ( ! function_exists('tutor_course_video')){
887 function tutor_course_video($echo = true){
888 ob_start();
889 tutor_load_template( 'single.video.video' );
890 $output = apply_filters( 'tutor_course/single/video', ob_get_clean() );
891
892 if ( $echo ) {
893 echo $output;
894 }
895 return $output;
896 }
897 }
898
899 if ( ! function_exists('tutor_lesson_video')){
900 function tutor_lesson_video($echo = true){
901 ob_start();
902 tutor_load_template( 'single.video.video' );
903 $output = apply_filters( 'tutor_lesson/single/video', ob_get_clean() );
904
905 if ( $echo ) {
906 echo $output;
907 }
908 return $output;
909 }
910 }
911
912 /**
913 *
914 * Get all lessons attachments
915 *
916 * @param bool $echo
917 *
918 * @return mixed
919 *
920 * @since v.1.0.0
921 */
922 if ( ! function_exists('get_tutor_posts_attachments')){
923 function get_tutor_posts_attachments($echo = true){
924 ob_start();
925 tutor_load_template( 'global.attachments' );
926 $output = apply_filters( 'tutor_lesson/single/attachments', ob_get_clean() );
927
928 if ( $echo ) {
929 echo $output;
930 }
931 return $output;
932 }
933 }
934
935 /**
936 * @param bool $echo
937 *
938 * @return mixed
939 *
940 * Get the lessons with topics
941 *
942 * @since v.1.0.0
943 */
944 if ( ! function_exists('tutor_lessons_sidebar')) {
945 function tutor_lessons_sidebar( $echo = true ) {
946 ob_start();
947 tutor_load_template( 'single.lesson.lesson_sidebar' );
948 $output = apply_filters( 'tutor_lesson/single/lesson_sidebar', ob_get_clean() );
949
950 if ( $echo ) {
951 echo $output;
952 }
953
954 return $output;
955 }
956 }
957
958 /**
959 * @param bool $echo
960 *
961 * @return mixed
962 *
963 * Render Lesson Main Content
964 * @since v.1.0.0
965 */
966 if ( ! function_exists('tutor_lesson_content')) {
967 function tutor_lesson_content( $echo = true ) {
968 ob_start();
969 tutor_load_template( 'single.lesson.content' );
970 $output = apply_filters( 'tutor_lesson/single/content', ob_get_clean() );
971
972 if ( $echo ) {
973 echo $output;
974 }
975
976 return $output;
977 }
978 }
979
980 if ( ! function_exists('tutor_lesson_mark_complete_html')) {
981 function tutor_lesson_mark_complete_html( $echo = true ) {
982 ob_start();
983 tutor_load_template( 'single.lesson.complete_form' );
984 $output = apply_filters( 'tutor_lesson/single/complete_form', ob_get_clean() );
985
986 if ( $echo ) {
987 echo $output;
988 }
989
990 return $output;
991 }
992 }
993
994 if ( ! function_exists('tutor_course_mark_complete_html')) {
995 function tutor_course_mark_complete_html( $echo = true ) {
996 ob_start();
997 tutor_load_template( 'single.course.complete_form' );
998 $output = apply_filters( 'tutor_course/single/complete_form', ob_get_clean() );
999
1000 if ( $echo ) {
1001 echo $output;
1002 }
1003
1004 return $output;
1005 }
1006 }
1007
1008
1009 /**
1010 * @param bool $echo
1011 *
1012 * @return mixed
1013 *
1014 * @show progress bar about course complete
1015 *
1016 * @since v.1.0.0
1017 */
1018
1019 if ( ! function_exists('tutor_course_completing_progress_bar')) {
1020 function tutor_course_completing_progress_bar( $echo = true ) {
1021 ob_start();
1022 tutor_load_template( 'single.course.enrolled.completing-progress' );
1023 $output = apply_filters( 'tutor_course/single/completing-progress-bar', ob_get_clean() );
1024
1025 if ( $echo ) {
1026 echo $output;
1027 }
1028
1029 return $output;
1030 }
1031 }
1032
1033 function tutor_course_question_and_answer($echo = true){
1034 ob_start();
1035 tutor_load_template( 'single.course.enrolled.question_and_answer' );
1036 $output = apply_filters( 'tutor_course/single/question_and_answer', ob_get_clean() );
1037
1038 if ( $echo ) {
1039 echo $output;
1040 }
1041
1042 return $output;
1043 }
1044
1045
1046 function tutor_course_announcements($echo = true){
1047 ob_start();
1048 tutor_load_template( 'single.course.enrolled.announcements' );
1049 $output = apply_filters( 'tutor_course/single/announcements', ob_get_clean() );
1050
1051 if ( $echo ) {
1052 echo $output;
1053 }
1054
1055 return $output;
1056 }
1057
1058 function tutor_single_quiz_top($echo = true){
1059 ob_start();
1060 tutor_load_template( 'single.quiz.top' );
1061 $output = apply_filters( 'tutor_single_quiz/top', ob_get_clean() );
1062
1063 if ( $echo ) {
1064 echo $output;
1065 }
1066 return $output;
1067 }
1068
1069 function tutor_single_quiz_body($echo = true){
1070 ob_start();
1071 tutor_load_template( 'single.quiz.body' );
1072 $output = apply_filters( 'tutor_single_quiz/body', ob_get_clean() );
1073
1074 if ( $echo ) {
1075 echo $output;
1076 }
1077 return $output;
1078 }
1079
1080 function tutor_single_quiz_no_course_belongs($echo = true){
1081 ob_start();
1082 tutor_load_template( 'single.quiz.no_course_belongs' );
1083 $output = apply_filters( 'tutor_single_quiz/no_course_belongs', ob_get_clean() );
1084
1085 if ( $echo ) {
1086 echo $output;
1087 }
1088 return $output;
1089 }
1090
1091 function single_quiz_contents($echo = true){
1092
1093 ob_start();
1094 tutor_load_template( 'single.quiz.single_quiz_contents' );
1095 $output = apply_filters( 'tutor_single_quiz/single_quiz_contents', ob_get_clean() );
1096
1097 if ( $echo ) {
1098 echo $output;
1099 }
1100 return $output;
1101 }
1102
1103 function get_tutor_course_level($course_id = 0){
1104 if ( ! $course_id){
1105 $course_id = get_the_ID();
1106 }
1107 if ( ! $course_id){
1108 return '';
1109 }
1110
1111 $course_level = get_post_meta($course_id, '_tutor_course_level', true);
1112
1113 if ($course_level){
1114 return tutor_utils()->course_levels($course_level);
1115 }
1116 return false;
1117 }
1118
1119 if ( ! function_exists('get_tutor_course_duration_context')) {
1120 function get_tutor_course_duration_context( $course_id = 0 ) {
1121 if ( ! $course_id ) {
1122 $course_id = get_the_ID();
1123 }
1124 if ( ! $course_id ) {
1125 return '';
1126 }
1127 $duration = get_post_meta( $course_id, '_course_duration', true );
1128 $durationHours = tutor_utils()->avalue_dot( 'hours', $duration );
1129 $durationMinutes = tutor_utils()->avalue_dot( 'minutes', $duration );
1130 $durationSeconds = tutor_utils()->avalue_dot( 'seconds', $duration );
1131
1132 if ( $duration ) {
1133 $output = '';
1134 if ( $durationHours > 0 ) {
1135 $output .= $durationHours . "h ";
1136 }
1137
1138 if ( $durationMinutes > 0 ) {
1139 $output .= $durationMinutes . "m ";
1140 }
1141
1142 if ( $durationSeconds > 0 ) {
1143 $output .= $durationSeconds ."s ";
1144 }
1145
1146 return $output;
1147 }
1148
1149 return false;
1150 }
1151 }
1152 if ( ! function_exists('get_tutor_course_categories')){
1153 function get_tutor_course_categories($course_id = 0){
1154 if ( ! $course_id ) {
1155 $course_id = get_the_ID();
1156 }
1157 $terms = get_the_terms( $course_id, 'course-category' );
1158
1159 return $terms;
1160 }
1161 }
1162 if ( ! function_exists('get_tutor_course_tags')){
1163 function get_tutor_course_tags($course_id = 0){
1164 if ( ! $course_id ) {
1165 $course_id = get_the_ID();
1166 }
1167 $terms = get_the_terms( $course_id, 'course-tag' );
1168
1169 return $terms;
1170 }
1171 }
1172
1173 if ( ! function_exists('tutor_course_tags_html')) {
1174 function tutor_course_tags_html( $echo = true ) {
1175 ob_start();
1176 tutor_load_template( 'single.course.tags' );
1177 $output = apply_filters( 'tutor_course/single/tags_html', ob_get_clean() );
1178
1179 if ( $echo ) {
1180 echo $output;
1181 }
1182
1183 return $output;
1184 }
1185 }
1186
1187 if ( ! function_exists('tutor_lesson_sidebar_question_and_answer')) {
1188 function tutor_lesson_sidebar_question_and_answer( $echo = true ) {
1189 ob_start();
1190 tutor_load_template( 'single.lesson.sidebar_question_and_answer' );
1191 $output = apply_filters( 'tutor_lesson/single/sidebar_question_and_answer', ob_get_clean() );
1192
1193 if ( $echo ) {
1194 echo $output;
1195 }
1196
1197 return $output;
1198 }
1199 }
1200
1201 if ( ! function_exists('tutor_social_share')) {
1202 function tutor_social_share( $echo = true ) {
1203 ob_start();
1204 tutor_load_template( 'single.course.social_share' );
1205 $output = apply_filters( 'tutor_course/single/social_share', ob_get_clean() );
1206
1207 if ( $echo ) {
1208 echo $output;
1209 }
1210
1211 return $output;
1212 }
1213 }
1214
1215