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