PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 1.3.1
Tutor LMS – eLearning and online course solution v1.3.1
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-general-functions.php 7 years ago tutor-template-functions.php 7 years ago tutor-template-hook.php 7 years ago
tutor-template-functions.php
1304 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 * @param array $variables
41 *
42 * Load template for TUTOR
43 *
44 * @since v.1.0.0
45 *
46 * @updated v.1.1.2
47 */
48
49 if ( ! function_exists('tutor_load_template')) {
50 function tutor_load_template( $template = null, $variables = array() ) {
51 $variables = (array) $variables;
52 extract($variables);
53
54 include tutor_get_template( $template );
55 }
56 }
57
58 if ( ! function_exists('tutor_course_loop_start')){
59 function tutor_course_loop_start($echo = true ){
60 ob_start();
61 tutor_load_template('loop.loop-start');
62 $output = apply_filters('tutor_course_loop_start', ob_get_clean());
63
64 if ( $echo ) {
65 echo $output;
66 }
67 return $output;
68 }
69 }
70
71 if ( ! function_exists('tutor_course_loop_end')) {
72 function tutor_course_loop_end( $echo = true ) {
73 ob_start();
74 tutor_load_template( 'loop.loop-end' );
75
76 $output = apply_filters( 'tutor_course_loop_end', ob_get_clean() );
77 if ( $echo ) {
78 echo $output;
79 }
80
81 return $output;
82 }
83 }
84
85 if ( ! function_exists('tutor_course_archive_pagination')) {
86 function tutor_course_archive_pagination( $echo = true ) {
87 ob_start();
88 tutor_load_template( 'loop.tutor-pagination' );
89
90 $output = apply_filters( 'tutor_course_archive_pagination', ob_get_clean() );
91 if ( $echo ) {
92 echo $output;
93 }
94
95 return $output;
96 }
97 }
98
99 function tutor_course_loop_before_content(){
100 ob_start();
101 tutor_load_template( 'loop.loop-before-content' );
102
103 $output = apply_filters( 'tutor_course_loop_before_content', ob_get_clean() );
104 echo $output;
105 }
106
107 function tutor_course_loop_after_content(){
108 ob_start();
109 tutor_load_template( 'loop.loop-after-content' );
110
111 $output = apply_filters( 'tutor_course_loop_after_content', ob_get_clean() );
112 echo $output;
113 }
114
115 if ( ! function_exists('tutor_course_loop_title')) {
116 function tutor_course_loop_title() {
117 ob_start();
118 tutor_load_template( 'loop.title' );
119 $output = apply_filters( 'tutor_course_loop_title', ob_get_clean() );
120
121 echo $output;
122 }
123 }
124
125
126 if ( ! function_exists('tutor_course_loop_header')) {
127 function tutor_course_loop_header() {
128 ob_start();
129 tutor_load_template( 'loop.header' );
130 $output = apply_filters( 'tutor_course_loop_header', ob_get_clean() );
131
132 echo $output;
133 }
134 }
135
136 if ( ! function_exists('tutor_course_loop_footer')) {
137 function tutor_course_loop_footer() {
138 ob_start();
139 tutor_load_template( 'loop.footer' );
140 $output = apply_filters( 'tutor_course_loop_footer', ob_get_clean() );
141
142 echo $output;
143 }
144 }
145
146 //tutor_course_loop_footer
147
148
149 if ( ! function_exists('tutor_course_loop_start_content_wrap')) {
150 function tutor_course_loop_start_content_wrap() {
151 ob_start();
152 tutor_load_template( 'loop.start_content_wrap' );
153 $output = apply_filters( 'tutor_course_loop_start_content_wrap', ob_get_clean() );
154
155 echo $output;
156 }
157 }
158
159 if ( ! function_exists('tutor_course_loop_end_content_wrap')) {
160 function tutor_course_loop_end_content_wrap() {
161 ob_start();
162 tutor_load_template( 'loop.end_content_wrap' );
163 $output = apply_filters( 'tutor_course_loop_end_content_wrap', ob_get_clean() );
164
165 echo $output;
166 }
167 }
168
169 if ( ! function_exists('tutor_course_loop_thumbnail')) {
170 function tutor_course_loop_thumbnail($echo = true) {
171 ob_start();
172 tutor_load_template( 'loop.thumbnail' );
173 $output = apply_filters( 'tutor_course_loop_thumbnail', ob_get_clean() );
174
175 if ($echo){
176 echo $output;
177 }else{
178 return $output;
179 }
180 }
181 }
182
183 if( ! function_exists('tutor_course_loop_wrap_classes')) {
184 function tutor_course_loop_wrap_classes( $echo = true ) {
185 $courseID = get_the_ID();
186 $classes = apply_filters( 'tutor_course_loop_wrap_classes', array(
187 'tutor-course',
188 'tutor-course-loop',
189 'tutor-course-loop-' . $courseID,
190 ) );
191
192 $class = implode( ' ', $classes );
193 if ( $echo ) {
194 echo $class;
195 }
196
197 return $class;
198 }
199 }
200
201 if( ! function_exists('tutor_course_loop_col_classes')) {
202 function tutor_course_loop_col_classes( $echo = true ) {
203 $courseCols = tutor_utils()->get_option( 'courses_col_per_row', 4 );
204 $classes = apply_filters( 'tutor_course_loop_col_classes', array(
205 'tutor-course-col-' . $courseCols,
206 ) );
207
208 $class = implode( ' ', $classes );
209 if ( $echo ) {
210 echo $class;
211 }
212
213 return $class;
214 }
215 }
216
217
218 if ( ! function_exists('tutor_container_classes')) {
219 function tutor_container_classes( $echo = true ) {
220
221 $classes = apply_filters( 'tutor_container_classes', array(
222 'tutor-wrap tutor-courses-wrap',
223 'tutor-container'
224 ) );
225
226 $class = implode( ' ', $classes );
227
228 if ( $echo ) {
229 echo $class;
230 }
231
232 return $class;
233 }
234 }
235 if ( ! function_exists('tutor_post_class')) {
236 function tutor_post_class($default = '') {
237 $classes = apply_filters( 'tutor_post_class', array(
238 'tutor-wrap',
239 $default
240 ) );
241
242 post_class( $classes );
243 }
244 }
245
246 if ( ! function_exists('tutor_course_archive_filter_bar')) {
247 function tutor_course_archive_filter_bar() {
248 ob_start();
249 tutor_load_template( 'global.course-archive-filter-bar' );
250 $output = apply_filters( 'tutor_course_archive_filter_bar', ob_get_clean() );
251
252 echo $output;
253 }
254 }
255
256 /**
257 *
258 * Get classes for widget loop single course wrap
259 *
260 * @param bool $echo
261 *
262 * @return string
263 *
264 * @since v.1.3.1
265 */
266 if( ! function_exists('tutor_widget_course_loop_classes')) {
267 function tutor_widget_course_loop_classes( $echo = true ) {
268
269 $classes = apply_filters( 'tutor_widget_course_loop_classes', array(
270 'tutor-widget-course-loop',
271 'tutor-widget-course',
272 'tutor-widget-course-'.get_the_ID(),
273 ) );
274
275 $class = implode( ' ', $classes );
276 if ( $echo ) {
277 echo $class;
278 }
279
280 return $class;
281 }
282 }
283
284 /**
285 * Get the post thumbnail
286 */
287 if ( ! function_exists('get_tutor_course_thumbnail')) {
288 function get_tutor_course_thumbnail($size = 'post-thumbnail', $url = false) {
289 $post_id = get_the_ID();
290 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
291
292 if ( $post_thumbnail_id ) {
293 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
294 if ($url){
295 return wp_get_attachment_image_url($post_thumbnail_id, $size);
296 }
297
298 $html = wp_get_attachment_image( $post_thumbnail_id, $size, false );
299 } else {
300 $placeHolderUrl = tutor()->url . 'assets/images/placeholder.jpg';
301 if ($url){
302 return $placeHolderUrl;
303 }
304 $html = sprintf('<img alt="%s" src="' . $placeHolderUrl . '" />', __('Placeholder', 'tutor'));
305 }
306
307 echo $html;
308 }
309 }
310 /**
311 * Get the course/post thumbnail src
312 */
313 if ( ! function_exists('get_tutor_course_thumbnail_src')) {
314 function get_tutor_course_thumbnail_src($size = 'post-thumbnail') {
315 $post_id = get_the_ID();
316 $post_thumbnail_id = (int) get_post_thumbnail_id( $post_id );
317
318 if ( $post_thumbnail_id ) {
319 $size = apply_filters( 'post_thumbnail_size', $size, $post_id );
320 $src = wp_get_attachment_image_url( $post_thumbnail_id, $size, false );
321 } else {
322 $src = tutor()->url . 'assets/images/placeholder.jpg';
323 }
324
325 return $src;
326 }
327 }
328
329 if ( ! function_exists('tutor_course_loop_meta')) {
330 function tutor_course_loop_meta() {
331 ob_start();
332 tutor_load_template( 'loop.meta' );
333 $output = apply_filters( 'tutor_course_loop_meta', ob_get_clean() );
334
335 echo $output;
336 }
337 }
338
339 /**
340 * Get course author name in loop
341 *
342 * @since: v.1.0.0
343 */
344
345 if ( ! function_exists('tutor_course_loop_author')) {
346 function tutor_course_loop_author() {
347 ob_start();
348 tutor_load_template( 'loop.course-author' );
349 $output = apply_filters( 'tutor_course_loop_author', ob_get_clean() );
350
351 echo $output;
352 }
353 }
354
355 /**
356 * Get formatted price with cart form
357 */
358
359 if ( ! function_exists('tutor_course_loop_price')) {
360 function tutor_course_loop_price() {
361 ob_start();
362
363 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
364 if ($tutor_course_sell_by){
365 tutor_load_template( 'loop.course-price-'.$tutor_course_sell_by );
366 }else{
367 tutor_load_template( 'loop.course-price' );
368 }
369 $output = apply_filters( 'tutor_course_loop_price', ob_get_clean() );
370
371 echo $output;
372 }
373 }
374
375 /**
376 * Get Course rating
377 */
378 if ( ! function_exists('tutor_course_loop_rating')) {
379 function tutor_course_loop_rating() {
380 ob_start();
381 tutor_load_template( 'loop.rating' );
382 $output = apply_filters( 'tutor_course_loop_rating', ob_get_clean() );
383
384 echo $output;
385 }
386 }
387
388 /**
389 * @param bool $echo
390 *
391 * @return mixed|void
392 *
393 * Get add to cart form
394 */
395
396 if ( ! function_exists('tutor_course_loop_add_to_cart')) {
397 function tutor_course_loop_add_to_cart($echo = true) {
398 ob_start();
399 $tutor_course_sell_by = apply_filters('tutor_course_sell_by', null);
400
401 if ($tutor_course_sell_by){
402 tutor_load_template( 'loop.add-to-cart-'.$tutor_course_sell_by );
403 }
404
405 $output = apply_filters( 'tutor_course_loop_add_to_cart_link', ob_get_clean() );
406
407 if ($echo){
408 echo $output;
409 }
410 return $output;
411 }
412 }
413
414 if ( ! function_exists('tutor_course_price')) {
415 function tutor_course_price() {
416 ob_start();
417 tutor_load_template( 'single.course.wc-price-html' );
418 $output = apply_filters( 'tutor_course_price', ob_get_clean() );
419
420 echo $output;
421 }
422 }
423
424 /**
425 * @param int $post_id
426 *
427 * echo the excerpt of TUTOR post type
428 *
429 * @since: v.1.0.0
430 */
431 if ( ! function_exists('tutor_the_excerpt')) {
432 function tutor_the_excerpt( $post_id = 0 ) {
433 if ( ! $post_id ) {
434 $post_id = get_the_ID();
435 }
436 echo tutor_get_the_excerpt( $post_id );
437 }
438 }
439 /**
440 * @param int $post_id
441 *
442 * @return mixed
443 *
444 * Return excerpt of TUTOR post type
445 *
446 * @since: v.1.0.0
447 */
448 if ( ! function_exists('tutor_get_the_excerpt')) {
449 function tutor_get_the_excerpt( $post_id = 0 ) {
450 if ( ! $post_id ) {
451 $post_id = get_the_ID();
452 }
453
454 $get_post = get_post($post_id);
455 return apply_filters( 'tutor_get_the_excerpt', $get_post->post_excerpt );
456 }
457 }
458
459 /**
460 * @return mixed
461 *
462 * return course author
463 *
464 * @since: v.1.0.0
465 */
466
467 if ( ! function_exists('get_tutor_course_author')) {
468 function get_tutor_course_author() {
469 global $post;
470 return apply_filters( 'get_tutor_course_author', get_the_author_meta( 'display_name', $post->post_author ) );
471 }
472 }
473
474 function get_tutor_course_author_id(){
475 global $post;
476 return $post->post_author;
477 }
478
479 /**
480 * @param int $course_id
481 *
482 * @return mixed
483 * Course benefits return array
484 *
485 * @since: v.1.0.0
486 */
487
488 if ( ! function_exists('tutor_course_benefits')) {
489 function tutor_course_benefits( $course_id = 0 ) {
490 if ( ! $course_id ) {
491 $course_id = get_the_ID();
492 }
493 $benefits = get_post_meta( $course_id, '_tutor_course_benefits', true );
494
495 $benefits_array = array();
496 if ($benefits){
497 $benefits_array = explode("\n", $benefits);
498 }
499
500 $array = array_filter(array_map('trim', $benefits_array));
501
502 return apply_filters( 'tutor_course/single/benefits', $array, $course_id );
503 }
504 }
505
506 /**
507 * @param bool $echo
508 *
509 * @return mixed
510 *
511 * Course single page benefits
512 *
513 * @since: v.1.0.0
514 */
515
516 if ( ! function_exists('tutor_course_benefits_html')) {
517 function tutor_course_benefits_html($echo = true) {
518 ob_start();
519 tutor_load_template( 'single.course.course-benefits' );
520 $output = apply_filters( 'tutor_course/single/benefits_html', ob_get_clean() );
521
522 if ($echo){
523 echo $output;
524 }
525 return $output;
526 }
527 }
528
529 /**
530 * @param bool $echo
531 *
532 * @return mixed|void
533 *
534 * Return Topics HTML
535 *
536 * @since: v.1.0.0
537 */
538 if ( ! function_exists('tutor_course_topics')) {
539 function tutor_course_topics( $echo = true ) {
540 ob_start();
541 tutor_load_template( 'single.course.course-topics' );
542 $output = apply_filters( 'tutor_course/single/topics', ob_get_clean() );
543 wp_reset_postdata();
544
545 if ( $echo ) {
546 echo $output;
547 }
548
549 return $output;
550 }
551 }
552
553 /**
554 * @param int $course_id
555 *
556 * @return mixed|void
557 *
558 * return course requirements in array
559 *
560 * @since: v.1.0.0
561 */
562 if ( ! function_exists('tutor_course_requirements')) {
563 function tutor_course_requirements( $course_id = 0 ) {
564 if ( ! $course_id ) {
565 $course_id = get_the_ID();
566 }
567 $requirements = get_post_meta( $course_id, '_tutor_course_requirements', true );
568
569 $requirements_array = array();
570 if ($requirements){
571 $requirements_array = explode("\n", $requirements);
572 }
573
574 $array = array_filter(array_map('trim', $requirements_array));
575 return apply_filters( 'tutor_course/single/requirements', $array, $course_id );
576 }
577 }
578
579 /**
580 * @param bool $echo
581 *
582 * @return mixed|void
583 *
584 * Return course requirements in course single page
585 *
586 * @since: v.1.0.0
587 */
588 if ( ! function_exists('tutor_course_requirements_html')) {
589 function tutor_course_requirements_html($echo = true) {
590 ob_start();
591 tutor_load_template( 'single.course.course-requirements' );
592 $output = apply_filters( 'tutor_course/single/requirements_html', ob_get_clean() );
593
594 if ($echo){
595 echo $output;
596 }
597 return $output;
598 }
599 }
600
601
602 /**
603 * @param int $course_id
604 *
605 * @return mixed|void
606 *
607 * Return target audience in course single page
608 *
609 * @since: v.1.0.0
610 */
611 if ( ! function_exists('tutor_course_target_audience')) {
612 function tutor_course_target_audience( $course_id = 0 ) {
613 if ( ! $course_id ) {
614 $course_id = get_the_ID();
615 }
616 $target_audience = get_post_meta( $course_id, '_tutor_course_target_audience', true );
617
618 $target_audience_array = array();
619 if ($target_audience){
620 $target_audience_array = explode("\n", $target_audience);
621 }
622
623 $array = array_filter(array_map('trim', $target_audience_array));
624 return apply_filters( 'tutor_course/single/target_audience', $array, $course_id );
625 }
626 }
627
628 /**
629 * @param bool $echo
630 *
631 * @return mixed|void
632 *
633 * Return target audience in course single page
634 *
635 * @since: v.1.0.0
636 */
637 if ( ! function_exists('tutor_course_target_audience_html')) {
638 function tutor_course_target_audience_html($echo = true) {
639 ob_start();
640 tutor_load_template( 'single.course.course-target-audience' );
641 $output = apply_filters( 'tutor_course/single/audience_html', ob_get_clean() );
642
643 if ($echo){
644 echo $output;
645 }
646 return $output;
647 }
648 }
649
650
651 if ( ! function_exists('tutor_course_material_includes')) {
652 function tutor_course_material_includes( $course_id = 0 ) {
653 if ( ! $course_id ) {
654 $course_id = get_the_ID();
655 }
656 $target_audience = get_post_meta( $course_id, '_tutor_course_material_includes', true );
657
658 $target_audience_array = array();
659 if ($target_audience){
660 $target_audience_array = explode("\n", $target_audience);
661 }
662
663 $array = array_filter(array_map('trim', $target_audience_array));
664 return apply_filters( 'tutor_course/single/material_includes', $array, $course_id );
665 }
666 }
667
668 if ( ! function_exists('tutor_course_material_includes_html')) {
669 function tutor_course_material_includes_html($echo = true) {
670 ob_start();
671 tutor_load_template( 'single.course.material-includes' );
672 $output = apply_filters( 'tutor_course/single/material_includes', ob_get_clean() );
673
674 if ($echo){
675 echo $output;
676 }
677 return $output;
678 }
679 }
680
681 //tutor_course_material_includes_html
682
683
684 if ( ! function_exists('tutor_course_instructors_html')) {
685 function tutor_course_instructors_html($echo = true) {
686 $display_course_instructors = tutor_utils()->get_option('display_course_instructors');
687 if ( ! $display_course_instructors){
688 return null;
689 }
690
691 ob_start();
692 tutor_load_template( 'single.course.instructors' );
693 $output = apply_filters( 'tutor_course/single/instructors_html', ob_get_clean() );
694
695 if ($echo){
696 echo $output;
697 }
698 return $output;
699 }
700 }
701
702 if ( ! function_exists('tutor_course_target_reviews_html')) {
703 function tutor_course_target_reviews_html($echo = true) {
704 ob_start();
705 tutor_load_template( 'single.course.reviews' );
706 $output = apply_filters( 'tutor_course/single/reviews_html', ob_get_clean() );
707
708 if ($echo){
709 echo $output;
710 }
711 return $output;
712 }
713 }
714
715 if ( ! function_exists('tutor_course_target_review_form_html')) {
716 function tutor_course_target_review_form_html($echo = true) {
717 ob_start();
718 tutor_load_template( 'single.course.review-form' );
719 $output = apply_filters( 'tutor_course/single/reviews_form', ob_get_clean() );
720
721 if ($echo){
722 echo $output;
723 }
724
725 return $output;
726
727 }
728 }
729
730 /**
731 * @param bool $echo
732 *
733 * @return mixed
734 *
735 * Course single page main content / description
736 *
737 * @since: v.1.0.0
738 */
739 if ( ! function_exists('tutor_course_content')) {
740 function tutor_course_content( $echo = true ) {
741 ob_start();
742 tutor_load_template( 'single.course.course-content' );
743 $output = apply_filters( 'tutor_course/single/content', ob_get_clean() );
744
745 if ( $echo ) {
746 echo $output;
747 }
748
749 return $output;
750 }
751 }
752
753 /**
754 * Course single page lead info
755 *
756 * @since: v.1.0.0
757 */
758 if ( ! function_exists('tutor_course_lead_info')) {
759 function tutor_course_lead_info( $echo = true ) {
760 ob_start();
761
762 $course_id = get_the_ID();
763 $course_post_type = tutor()->course_post_type;
764 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
765
766 if ($queryCourse->have_posts()){
767 while ($queryCourse->have_posts()){
768 $queryCourse->the_post();
769 tutor_load_template( 'single.course.lead-info' );
770 }
771 wp_reset_postdata();
772 }
773
774 $output = apply_filters( 'tutor_course/single/lead_info', ob_get_clean() );
775
776 if ( $echo ) {
777 echo $output;
778 }
779 return $output;
780 }
781 }
782
783 /**
784 * @param bool $echo
785 *
786 * @return mixed|void
787 */
788
789 if ( ! function_exists('tutor_course_enrolled_lead_info')) {
790 function tutor_course_enrolled_lead_info( $echo = true ) {
791 ob_start();
792
793 $course_id = get_the_ID();
794 $course_post_type = tutor()->course_post_type;
795 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
796
797 if ( $queryCourse->have_posts() ) {
798 while ( $queryCourse->have_posts() ) {
799 $queryCourse->the_post();
800 tutor_load_template( 'single.course.enrolled.lead-info' );
801 }
802 wp_reset_postdata();
803 }
804
805 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
806
807 if ( $echo ) {
808 echo $output;
809 }
810
811 return $output;
812 }
813 }
814
815 if ( ! function_exists('tutor_lesson_lead_info')) {
816 function tutor_lesson_lead_info( $lesson_id = 0, $echo = true ) {
817 if ( ! $lesson_id ) {
818 $lesson_id = get_the_ID();
819 }
820
821 ob_start();
822 $course_id = tutor_utils()->get_course_id_by_lesson( $lesson_id );
823 $course_post_type = tutor()->course_post_type;
824 $queryCourse = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type ) );
825
826 if ( $queryCourse->have_posts() ) {
827 while ( $queryCourse->have_posts() ) {
828 $queryCourse->the_post();
829 tutor_load_template( 'single.course.enrolled.lead-info' );
830 }
831 wp_reset_postdata();
832 }
833 $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() );
834
835 if ( $echo ) {
836 echo $output;
837 }
838
839 return $output;
840
841 }
842 }
843 /**
844 * @param bool $echo
845 *
846 * @return mixed
847 *
848 * Return enroll box in single course
849 *
850 * @since: v.1.0.0
851 */
852
853 if ( ! function_exists('tutor_course_enroll_box')) {
854 function tutor_course_enroll_box( $echo = true ) {
855 $isLoggedIn = is_user_logged_in();
856 $enrolled = tutor_utils()->is_enrolled();
857
858 ob_start();
859
860 if ( $enrolled ) {
861 tutor_load_template( 'single.course.course-enrolled-box' );
862 $output = apply_filters( 'tutor_course/single/enrolled', ob_get_clean() );
863 } else {
864 tutor_load_template( 'single.course.course-enroll-box' );
865 $output = apply_filters( 'tutor_course/single/enroll', ob_get_clean() );
866 }
867
868 if ( $echo ) {
869 echo $output;
870 }
871
872 return $output;
873 }
874 }
875
876 /**
877 * @param bool $echo
878 *
879 * @return string
880 *
881 * Get Only add to cart form
882 */
883
884 function tutor_single_course_add_to_cart($echo = true){
885 ob_start();
886
887 $isLoggedIn = is_user_logged_in();
888 $output = '';
889
890 tutor_load_template( 'single.course.add-to-cart' );
891 $output .= apply_filters( 'tutor_course/single/add-to-cart', ob_get_clean() );
892
893 if ( ! $isLoggedIn){
894 ob_start();
895 tutor_load_template( 'single.course.login' );
896 $login_form = apply_filters( 'tutor_course/global/login', ob_get_clean() );
897
898 $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>";
899 }
900
901 if ( $echo ) {
902 echo $output;
903 }
904
905 return $output;
906 }
907
908 if ( ! function_exists('tutor_course_enrolled_nav')) {
909 function tutor_course_enrolled_nav($echo = true) {
910 $course_post_type = tutor()->course_post_type;
911 $lesson_post_type = tutor()->lesson_post_type;
912
913 ob_start();
914 global $post;
915
916 if ( ! empty($post->post_type) && $post->post_type === $course_post_type){
917 tutor_load_template( 'single.course.enrolled.nav' );
918 }elseif(! empty($post->post_type) && $post->post_type === $lesson_post_type){
919 $lesson_id = get_the_ID();
920 $course_id = tutor_utils()->get_course_id_by_lesson($lesson_id);
921
922 $course_post_type = tutor()->course_post_type;
923 $queryCourse = new WP_Query(array('p' => $course_id, 'post_type' => $course_post_type));
924
925 if ($queryCourse->have_posts()){
926 while ($queryCourse->have_posts()){
927 $queryCourse->the_post();
928 tutor_load_template( 'single.course.enrolled.nav' );
929 }
930 wp_reset_postdata();
931 }
932 }
933 $output = apply_filters( 'tutor_course/single/enrolled/nav', ob_get_clean() );
934
935 if ( $echo ) {
936 echo $output;
937 }
938 return $output;
939 }
940 }
941
942 if ( ! function_exists('tutor_course_video')){
943 function tutor_course_video($echo = true){
944 ob_start();
945 tutor_load_template( 'single.video.video' );
946 $output = apply_filters( 'tutor_course/single/video', ob_get_clean() );
947
948 if ( $echo ) {
949 echo $output;
950 }
951 return $output;
952 }
953 }
954
955 if ( ! function_exists('tutor_lesson_video')){
956 function tutor_lesson_video($echo = true){
957 ob_start();
958 tutor_load_template( 'single.video.video' );
959 $output = apply_filters( 'tutor_lesson/single/video', ob_get_clean() );
960
961 if ( $echo ) {
962 echo $output;
963 }
964 return $output;
965 }
966 }
967
968 /**
969 *
970 * Get all lessons attachments
971 *
972 * @param bool $echo
973 *
974 * @return mixed
975 *
976 * @since v.1.0.0
977 */
978 if ( ! function_exists('get_tutor_posts_attachments')){
979 function get_tutor_posts_attachments($echo = true){
980 ob_start();
981 tutor_load_template( 'global.attachments' );
982 $output = apply_filters( 'tutor_lesson/single/attachments', ob_get_clean() );
983
984 if ( $echo ) {
985 echo $output;
986 }
987 return $output;
988 }
989 }
990
991 /**
992 * @param bool $echo
993 *
994 * @return mixed
995 *
996 * Get the lessons with topics
997 *
998 * @since v.1.0.0
999 */
1000 if ( ! function_exists('tutor_lessons_sidebar')) {
1001 function tutor_lessons_sidebar( $echo = true ) {
1002 ob_start();
1003 tutor_load_template( 'single.lesson.lesson_sidebar' );
1004 $output = apply_filters( 'tutor_lesson/single/lesson_sidebar', ob_get_clean() );
1005
1006 if ( $echo ) {
1007 echo $output;
1008 }
1009
1010 return $output;
1011 }
1012 }
1013
1014 /**
1015 * @param bool $echo
1016 *
1017 * @return mixed
1018 *
1019 * Render Lesson Main Content
1020 * @since v.1.0.0
1021 */
1022 if ( ! function_exists('tutor_lesson_content')) {
1023 function tutor_lesson_content( $echo = true ) {
1024 ob_start();
1025 tutor_load_template( 'single.lesson.content' );
1026 $output = apply_filters( 'tutor_lesson/single/content', ob_get_clean() );
1027
1028 if ( $echo ) {
1029 echo $output;
1030 }
1031
1032 return $output;
1033 }
1034 }
1035
1036 if ( ! function_exists('tutor_lesson_mark_complete_html')) {
1037 function tutor_lesson_mark_complete_html( $echo = true ) {
1038 ob_start();
1039 tutor_load_template( 'single.lesson.complete_form' );
1040 $output = apply_filters( 'tutor_lesson/single/complete_form', ob_get_clean() );
1041
1042 if ( $echo ) {
1043 echo $output;
1044 }
1045
1046 return $output;
1047 }
1048 }
1049
1050 if ( ! function_exists('tutor_course_mark_complete_html')) {
1051 function tutor_course_mark_complete_html( $echo = true ) {
1052 ob_start();
1053 tutor_load_template( 'single.course.complete_form' );
1054 $output = apply_filters( 'tutor_course/single/complete_form', ob_get_clean() );
1055
1056 if ( $echo ) {
1057 echo $output;
1058 }
1059
1060 return $output;
1061 }
1062 }
1063
1064
1065 /**
1066 * @param bool $echo
1067 *
1068 * @return mixed
1069 *
1070 * @show progress bar about course complete
1071 *
1072 * @since v.1.0.0
1073 */
1074
1075 if ( ! function_exists('tutor_course_completing_progress_bar')) {
1076 function tutor_course_completing_progress_bar( $echo = true ) {
1077 ob_start();
1078 tutor_load_template( 'single.course.enrolled.completing-progress' );
1079 $output = apply_filters( 'tutor_course/single/completing-progress-bar', ob_get_clean() );
1080
1081 if ( $echo ) {
1082 echo $output;
1083 }
1084
1085 return $output;
1086 }
1087 }
1088
1089 function tutor_course_question_and_answer($echo = true){
1090 ob_start();
1091 tutor_load_template( 'single.course.enrolled.question_and_answer' );
1092 $output = apply_filters( 'tutor_course/single/question_and_answer', ob_get_clean() );
1093
1094 if ( $echo ) {
1095 echo $output;
1096 }
1097
1098 return $output;
1099 }
1100
1101
1102 function tutor_course_announcements($echo = true){
1103 ob_start();
1104 tutor_load_template( 'single.course.enrolled.announcements' );
1105 $output = apply_filters( 'tutor_course/single/announcements', ob_get_clean() );
1106
1107 if ( $echo ) {
1108 echo $output;
1109 }
1110
1111 return $output;
1112 }
1113
1114 function tutor_single_quiz_top($echo = true){
1115 ob_start();
1116 tutor_load_template( 'single.quiz.top' );
1117 $output = apply_filters( 'tutor_single_quiz/top', ob_get_clean() );
1118
1119 if ( $echo ) {
1120 echo $output;
1121 }
1122 return $output;
1123 }
1124
1125 function tutor_single_quiz_body($echo = true){
1126 ob_start();
1127 tutor_load_template( 'single.quiz.body' );
1128 $output = apply_filters( 'tutor_single_quiz/body', ob_get_clean() );
1129
1130 if ( $echo ) {
1131 echo $output;
1132 }
1133 return $output;
1134 }
1135
1136 function tutor_single_quiz_no_course_belongs($echo = true){
1137 ob_start();
1138 tutor_load_template( 'single.quiz.no_course_belongs' );
1139 $output = apply_filters( 'tutor_single_quiz/no_course_belongs', ob_get_clean() );
1140
1141 if ( $echo ) {
1142 echo $output;
1143 }
1144 return $output;
1145 }
1146
1147 function single_quiz_contents($echo = true){
1148
1149 ob_start();
1150 tutor_load_template( 'single.quiz.single_quiz_contents' );
1151 $output = apply_filters( 'tutor_single_quiz/single_quiz_contents', ob_get_clean() );
1152
1153 if ( $echo ) {
1154 echo $output;
1155 }
1156 return $output;
1157 }
1158
1159 function get_tutor_course_level($course_id = 0){
1160 if ( ! $course_id){
1161 $course_id = get_the_ID();
1162 }
1163 if ( ! $course_id){
1164 return '';
1165 }
1166
1167 $course_level = get_post_meta($course_id, '_tutor_course_level', true);
1168
1169 if ($course_level){
1170 return tutor_utils()->course_levels($course_level);
1171 }
1172 return false;
1173 }
1174
1175 if ( ! function_exists('get_tutor_course_duration_context')) {
1176 function get_tutor_course_duration_context( $course_id = 0 ) {
1177 if ( ! $course_id ) {
1178 $course_id = get_the_ID();
1179 }
1180 if ( ! $course_id ) {
1181 return '';
1182 }
1183 $duration = get_post_meta( $course_id, '_course_duration', true );
1184 $durationHours = tutor_utils()->avalue_dot( 'hours', $duration );
1185 $durationMinutes = tutor_utils()->avalue_dot( 'minutes', $duration );
1186 $durationSeconds = tutor_utils()->avalue_dot( 'seconds', $duration );
1187
1188 if ( $duration ) {
1189 $output = '';
1190 if ( $durationHours > 0 ) {
1191 $output .= $durationHours . "h ";
1192 }
1193
1194 if ( $durationMinutes > 0 ) {
1195 $output .= $durationMinutes . "m ";
1196 }
1197
1198 if ( $durationSeconds > 0 ) {
1199 $output .= $durationSeconds ."s ";
1200 }
1201
1202 return $output;
1203 }
1204
1205 return false;
1206 }
1207 }
1208 if ( ! function_exists('get_tutor_course_categories')){
1209 function get_tutor_course_categories($course_id = 0){
1210 if ( ! $course_id ) {
1211 $course_id = get_the_ID();
1212 }
1213 $terms = get_the_terms( $course_id, 'course-category' );
1214
1215 return $terms;
1216 }
1217 }
1218
1219 /**
1220 * @param int $course_id
1221 *
1222 * @return array|false|WP_Error
1223 *
1224 * Get course tags
1225 */
1226
1227 if ( ! function_exists('get_tutor_course_tags')){
1228 function get_tutor_course_tags($course_id = 0){
1229 if ( ! $course_id ) {
1230 $course_id = get_the_ID();
1231 }
1232 $terms = get_the_terms( $course_id, 'course-tag' );
1233
1234 return $terms;
1235 }
1236 }
1237
1238 /**
1239 * @param bool $echo
1240 *
1241 * @return mixed|void
1242 *
1243 * Template for course tags html
1244 */
1245
1246 if ( ! function_exists('tutor_course_tags_html')) {
1247 function tutor_course_tags_html( $echo = true ) {
1248 ob_start();
1249 tutor_load_template( 'single.course.tags' );
1250 $output = apply_filters( 'tutor_course/single/tags_html', ob_get_clean() );
1251
1252 if ( $echo ) {
1253 echo $output;
1254 }
1255
1256 return $output;
1257 }
1258 }
1259
1260 /**
1261 * @param bool $echo
1262 *
1263 * @return mixed
1264 *
1265 * Get Q&A in lesson sidebar
1266 */
1267
1268 if ( ! function_exists('tutor_lesson_sidebar_question_and_answer')) {
1269 function tutor_lesson_sidebar_question_and_answer( $echo = true ) {
1270 ob_start();
1271 tutor_load_template( 'single.lesson.sidebar_question_and_answer' );
1272 $output = apply_filters( 'tutor_lesson/single/sidebar_question_and_answer', ob_get_clean() );
1273
1274 if ( $echo ) {
1275 echo $output;
1276 }
1277
1278 return $output;
1279 }
1280 }
1281
1282 /**
1283 * @param bool $echo
1284 *
1285 * @return mixed|void
1286 *
1287 * Get Social Share button to share on social media
1288 */
1289
1290 if ( ! function_exists('tutor_social_share')) {
1291 function tutor_social_share( $echo = true ) {
1292 ob_start();
1293 tutor_load_template( 'single.course.social_share' );
1294 $output = apply_filters( 'tutor_course/single/social_share', ob_get_clean() );
1295
1296 if ( $echo ) {
1297 echo $output;
1298 }
1299
1300 return $output;
1301 }
1302 }
1303
1304