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