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