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