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