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