/
llms.template.functions.php
1192 lines (941 loc) · 26 KB
/
llms.template.functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Front end template functions
*
* @package LifterLMS/Functions/Templates
*
* @since 1.0.0
* @version 7.5.0
*/
defined( 'ABSPATH' ) || exit;
require 'functions/llms-functions-content.php';
require 'functions/llms-functions-conditional-tags.php';
require 'functions/llms-functions-templates-courses.php';
require 'functions/llms-functions-templates-memberships.php';
require 'functions/llms-functions-templates-shared.php';
require 'functions/llms-functions-template-view-order.php';
require 'functions/llms.functions.templates.achievements.php';
require 'functions/llms.functions.templates.certificates.php';
require 'functions/llms.functions.templates.dashboard.php';
require 'functions/llms.functions.templates.dashboard.widgets.php';
require 'functions/llms.functions.templates.loop.php';
require 'functions/llms.functions.templates.pricing.table.php';
require 'functions/llms.functions.templates.privacy.php';
require 'functions/llms.functions.templates.quizzes.php';
/**
* Output email body content
*
* @return void
* @since 3.8.0
* @version 3.8.0
*/
if ( ! function_exists( 'llms_email_body' ) ) {
function llms_email_body( $content = '' ) {
echo apply_filters( 'the_content', $content );
}
}
/**
* Output email footer template
*
* @return void
* @since 3.8.0
* @version 3.8.0
*/
if ( ! function_exists( 'llms_email_footer' ) ) {
function llms_email_footer() {
llms_get_template( 'emails/footer.php' );
}
}
/**
* Output email header template with optional heading
*
* @param string $heading optional heading text to output above the main content
* @return void
* @since 3.8.0
* @version 3.8.0
*/
if ( ! function_exists( 'llms_email_header' ) ) {
function llms_email_header( $heading = '' ) {
llms_get_template(
'emails/header.php',
array(
'email_heading' => $heading,
)
);
}
}
/**
* Template Redirect
*
* @return void
*/
function llms_template_redirect() {
global $wp_query, $wp;
// When default permalinks are enabled, redirect shop page to post type archive url.
if ( ! empty( $_GET['page_id'] ) && get_option( 'permalink_structure' ) == '' && llms_get_page_id( 'shop' ) == $_GET['page_id'] ) {
wp_safe_redirect( get_post_type_archive_link( 'course' ) );
exit;
}
// When default permalinks are enabled, redirect memberships page to post type archive url.
if ( ! empty( $_GET['page_id'] ) && get_option( 'permalink_structure' ) == '' && llms_get_page_id( 'memberships' ) == $_GET['page_id'] ) {
wp_safe_redirect( get_post_type_archive_link( 'llms_membership' ) );
exit;
}
}
add_action( 'template_redirect', 'llms_template_redirect' );
/**
* Title Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_title' ) ) {
function lifterlms_template_single_title() {
llms_get_template( 'course/title.php' );
}
}
/**
* Short Description Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_short_description' ) ) {
function lifterlms_template_single_short_description() {
llms_get_template( 'course/short-description.php' );
}
}
/**
* Course Content Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_course_content' ) ) {
function lifterlms_template_single_course_content() {
global $post;
$page_restricted = llms_page_restricted( $post->ID );
if ( $page_restricted['is_restricted'] ) {
llms_get_template( 'course/short-description.php' );
} else {
llms_get_template( 'course/full-description.php' );
}
}
}
/**
* Course Full Description Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_full_description' ) ) {
function lifterlms_template_single_full_description() {
llms_get_template( 'lesson/full-description.php' );
}
}
/**
* Membership Featured Image Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_membership_full_description' ) ) {
function lifterlms_template_single_membership_full_description() {
llms_get_template( 'membership/full-description.php' );
}
}
/**
* Add a course progress bar with a continue button
*
* @return void
* @since 3.0.1
* @version 3.0.1
*/
if ( ! function_exists( 'lifterlms_template_single_course_progress' ) ) {
function lifterlms_template_single_course_progress() {
llms_get_template( 'course/progress.php' );
}
}
/**
* Open the course meta information wrapper
*
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_meta_wrapper_start' ) ) {
function lifterlms_template_single_meta_wrapper_start() {
llms_get_template( 'course/meta-wrapper-start.php' );
}
}
/**
* Close the course meta information wrapper
*
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_meta_wrapper_end' ) ) {
function lifterlms_template_single_meta_wrapper_end() {
llms_get_template( 'course/meta-wrapper-end.php' );
}
}
/**
* Course Estimated Length Template
* replaced 'lifterlms_template_single_lesson_length()' which was misnamed as being related to a lesson
* when it was actually related to a course
*
* @return void
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_length' ) ) {
function lifterlms_template_single_length() {
llms_get_template( 'course/length.php' );
}
}
/**
* Display a list of course categories
*
* @return void
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_course_categories' ) ) {
function lifterlms_template_single_course_categories() {
llms_get_template( 'course/categories.php' );
}
}
/**
* Display a list of course tags
*
* @return void
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_course_tags' ) ) {
function lifterlms_template_single_course_tags() {
llms_get_template( 'course/tags.php' );
}
}
/**
* Display a list of course tracks
*
* @return void
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_course_tracks' ) ) {
function lifterlms_template_single_course_tracks() {
llms_get_template( 'course/tracks.php' );
}
}
/**
* Display a list of course tags
*
* @return void
* @since 3.0.0
* @version 3.0.0
*/
if ( ! function_exists( 'lifterlms_template_single_course_tags' ) ) {
function lifterlms_template_single_course_tags() {
llms_get_template( 'course/tags.php' );
}
}
/**
* Course Video Embed Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_video' ) ) {
function lifterlms_template_single_video() {
llms_get_template( 'course/video.php' );
}
}
/**
* Lesson Video Embed Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_lesson_video' ) ) {
function lifterlms_template_single_lesson_video() {
llms_get_template( 'lesson/video.php' );
}
}
/**
* Course Audio Embed Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_audio' ) ) {
function lifterlms_template_single_audio() {
llms_get_template( 'course/audio.php' );
}
}
/**
* Lesson Audio Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_lesson_audio' ) ) {
function lifterlms_template_single_lesson_audio() {
llms_get_template( 'lesson/audio.php' );
}
}
/**
* Course Difficulty Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_difficulty' ) ) {
function lifterlms_template_single_difficulty() {
llms_get_template( 'course/difficulty.php' );
}
}
/**
* Course Difficulty Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_prerequisites' ) ) {
function lifterlms_template_single_prerequisites() {
global $post;
llms_get_template(
'course/prerequisites.php',
array(
'course' => new LLMS_Course( $post ),
)
);
}
}
/**
* Course Syllabus Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_syllabus' ) ) {
function lifterlms_template_single_syllabus() {
llms_get_template( 'course/syllabus.php' );
}
}
/**
* Parent Course Link Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_parent_course' ) ) {
function lifterlms_template_single_parent_course() {
llms_get_template( 'course/parent-course.php' );
}
}
if ( ! function_exists( 'llms_template_favorite' ) ) {
/**
* Favorite Lesson Template Include.
*
* @since 7.5.0
*
* @param int $object_id WP Post ID of the object to mark/unmark as favorite.
* @param string $object_type The object type, currently only 'lesson'.
* @return void
*/
function llms_template_favorite( $object_id = null, $object_type = 'lesson' ) {
llms()->assets->enqueue_script( 'llms-favorites' );
llms_get_template(
'course/favorite.php',
array(
'object_id' => $object_id,
'object_type' => $object_type,
)
);
}
}
if ( ! function_exists( 'llms_template_syllabus_favorite_lesson_preview' ) ) {
/**
* Favorite Lesson Template Include when displayed in the syllabus lesson preview.
*
* @since 7.5.0
*
* @return void
*/
function llms_template_syllabus_favorite_lesson_preview( $lesson ) {
if ( 'course' === get_post_type( get_the_ID() ) ) {
llms_template_favorite( $lesson->get( 'id' ) );
}
}
}
/**
* Complete Lesson Link Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_complete_lesson_link' ) ) {
function lifterlms_template_complete_lesson_link() {
llms_get_template( 'course/complete-lesson-link.php' );
}
}
/**
* Lesson Navigation Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_lesson_navigation' ) ) {
function lifterlms_template_lesson_navigation() {
llms_get_template( 'course/lesson-navigation.php' );
}
}
/**
* Membership Title Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_membership_title' ) ) {
function lifterlms_template_single_membership_title() {
llms_get_template( 'membership/title.php' );
}
}
if ( ! function_exists( 'lifterlms_get_content' ) ) {
function lifterlms_get_content( $args ) {
llms_get_template( 'content-single-question.php', $args );
}
}
/**
* When the_post is called, put course data into a global.
*
* @param mixed $post
* @return LLMS_Course
*/
function llms_setup_course_data( $post ) {
if ( ! is_admin() ) {
if ( $post && 'course' === $post->post_type ) {
unset( $GLOBALS['course'] );
if ( is_int( $post ) ) {
$post = get_post( $post );
}
if ( empty( $post->post_type ) ) {
return;
}
$GLOBALS['course'] = new LLMS_Course( $post );
return $GLOBALS['course'];
}
}
}
add_action( 'the_post', 'llms_setup_course_data' );
/**
* When the_post is called, put lesson data into a global.
*
* @param mixed $post
* @return LLMS_Course
*/
function llms_setup_lesson_data( $post ) {
if ( ! is_admin() ) {
if ( 'lesson' == $post->post_type ) {
unset( $GLOBALS['lesson'] );
if ( is_int( $post ) ) {
$post = get_post( $post ); }
if ( empty( $post->post_type ) ) {
return; }
$courseid = get_post_meta( $post->ID, '_llms_parent_course' );
if ( isset( $courseid ) ) {
$parent_course = get_post( $courseid );
}
$GLOBALS['lesson'] = get_lesson( $post );
llms_setup_course_data( $parent_course );
return $GLOBALS['lesson'];
}
}
}
add_action( 'the_post', 'llms_setup_lesson_data' );
/**
* Returns post array of data for sections associated with a course
*
* @param array
* @return array
*/
function get_section_data( $sections ) {
global $post;
$html = '';
$args = array(
'post_type' => 'section',
'post_status' => 'publish',
'nopaging' => true,
);
$sections_query = get_posts( $args );
$array = array();
foreach ( $sections as $key => $value ) :
foreach ( $sections_query as $section ) :
if ( $value == $section->ID ) {
$array[ $section->ID ] = $section;
}
endforeach;
endforeach;
return $array;
}
/**
* Returns post array of data for lessons associated with a course
*
* @param array
* @return array
*/
function get_lesson_data( $lessons ) {
global $post;
$html = '';
$args = array(
'post_type' => 'lesson',
'post_status' => 'publish',
'nopaging' => true,
);
$lessons_query = get_posts( $args );
$array = array();
foreach ( $lessons as $key => $value ) :
foreach ( $lessons_query as $lesson ) :
if ( $value == $lesson->ID ) {
$array[ $value ] = $lesson;
}
endforeach;
endforeach;
return $array;
}
/**
* Get Page Title
*
* @param boolean $echo [echo string?]
* @return string $page_title [page title]
*/
if ( ! function_exists( 'lifterlms_page_title' ) ) {
function lifterlms_page_title( $echo = true ) {
$page_title = '';
if ( is_search() ) {
$page_title = sprintf( __( 'Search Results: “%s”', 'lifterlms' ), get_search_query() );
if ( get_query_var( 'paged' ) ) {
$page_title .= sprintf( __( ' – Page %s', 'lifterlms' ), get_query_var( 'paged' ) );
}
} elseif ( is_tax() ) {
$page_title = single_term_title( '', false );
} elseif ( is_post_type_archive( 'course' ) ) {
$page_title = get_the_title( llms_get_page_id( 'courses' ) );
} elseif ( is_post_type_archive( 'llms_membership' ) ) {
$page_title = get_the_title( llms_get_page_id( 'memberships' ) );
}
$page_title = apply_filters( 'lifterlms_page_title', $page_title );
if ( $echo ) {
echo $page_title;
} else {
return $page_title;
}
}
}
/**
* Outputs the html for a progress bar
*
* @param int $progress percent completion
* @param string $link permalink to link the button to, if false will output a span with no href
* @param bool $button output a button with the link
* @param bool $echo true will echo content, false will return it
* @return void|string
* @since 1.0.0
* @version 3.24.0
*/
if ( ! function_exists( 'lifterlms_course_progress_bar' ) ) {
function lifterlms_course_progress_bar( $progress, $link = false, $button = true, $echo = true ) {
$progress = round( $progress, 2 );
$tag = ( $link ) ? 'a' : 'span';
$href = ( $link ) ? ' href=" ' . $link . ' "' : '';
$html = llms_get_progress_bar_html( $progress );
if ( $button ) {
$html .= '<' . $tag . ' class="llms-button-primary llms-purchase-button"' . $href . '>' . __( 'Continue', 'lifterlms' ) . '(' . $progress . '%)</' . $tag . '>';
}
if ( $echo ) {
echo $html;
} else {
return $html;
}
}
}
function llms_get_progress_bar_html( $percentage ) {
$percentage = sprintf( '%s%%', $percentage );
$html = '<div class="llms-progress">
<div class="progress__indicator">' . $percentage . '</div>
<div class="llms-progress-bar">
<div class="progress-bar-complete" data-progress="' . $percentage . '" style="width:' . $percentage . '"></div>
</div></div>';
return $html;
}
/**
* Output a course continue button linking to the incomplete lesson for a given student.
*
* If the course is complete "Course Complete" is displayed.
*
* @since 3.11.1
* @since 3.15.0 Unknown.
* @since 7.1.0 Remove check on student existence, now included in the enrollment check.
*
* @param int $post_id WP Post ID for a course, lesson, or quiz.
* @param LLMS_Student $student Instance of an LLMS_Student, defaults to current student.
* @param int $progress Current progress of the student through the course.
* @return void
*/
if ( ! function_exists( 'lifterlms_course_continue_button' ) ) {
function lifterlms_course_continue_button( $post_id = null, $student = null, $progress = null ) {
if ( ! $post_id ) {
$post_id = get_the_ID();
if ( ! $post_id ) {
return '';
}
}
$course = llms_get_post( $post_id );
if ( ! $course || ! is_a( $course, 'LLMS_Post_Model' ) ) {
return '';
}
if ( in_array( $course->get( 'type' ), array( 'lesson', 'quiz' ) ) ) {
$course = llms_get_post_parent_course( $course->get( 'id' ) );
if ( ! $course ) {
return '';
}
}
if ( ! $student ) {
$student = llms_get_student();
}
if ( ! $student || ! llms_is_user_enrolled( $student->get_id(), $course->get( 'id' ) ) ) {
return '';
}
if ( is_null( $progress ) ) {
$progress = $student->get_progress( $course->get( 'id' ), 'course' );
}
if ( 100 == $progress ) {
echo '<p class="llms-course-complete-text">' . apply_filters( 'llms_course_continue_button_complete_text', __( 'Course Complete', 'lifterlms' ), $course ) . '</p>';
} else {
$lesson = apply_filters( 'llms_course_continue_button_next_lesson', $student->get_next_lesson( $course->get( 'id' ) ), $course, $student );
if ( $lesson ) { ?>
<a class="llms-button-primary llms-course-continue-button" href="<?php echo get_permalink( $lesson ); ?>">
<?php if ( 0 == $progress ) : ?>
<?php _e( 'Get Started', 'lifterlms' ); ?>
<?php else : ?>
<?php _e( 'Continue', 'lifterlms' ); ?>
<?php endif; ?>
</a>
<?php
}
}
}
}
/**
* Course Thumbnail Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_get_course_thumbnail' ) ) {
function lifterlms_get_course_thumbnail() {
global $post;
if ( has_post_thumbnail() ) {
return lifterlms_get_featured_image( $post->ID );
} elseif ( llms_placeholder_img_src() ) {
return llms_placeholder_img( 'full' );
}
}
}
/**
* Featured Image Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_get_featured_image' ) ) {
function lifterlms_get_featured_image( $post_id ) {
if ( has_post_thumbnail( $post_id ) ) {
return llms_featured_img( $post_id, 'full' );
} elseif ( llms_placeholder_img_src() ) {
return llms_placeholder_img();
}
}
}
/**
* Get the placeholder image URL for courses
*
* @access public
* @return string
*/
function llms_placeholder_img_src() {
return apply_filters( 'lifterlms_placeholder_img_src', llms()->plugin_url() . '/assets/images/placeholder.png' );
}
/**
* Get the placeholder image
*
* @access public
* @return string
*/
function llms_placeholder_img( $size = 'full' ) {
return apply_filters( 'lifterlms_placeholder_img', '<img src="' . llms_placeholder_img_src() . '" alt="placeholder" class="llms-placeholder llms-featured-image wp-post-image" />' );
}
/**
* Get the featured image.
*
* @since unknown
* @since 7.1.2 Fix bug when the featured image file is not available.
*
* @access public
*
* @param int|WP_Post $post_id Post ID or WP_Post object.
* @param string|int[] $size Accepts any registered image size name, or an array of width and height values in pixels (in that order).
* @return string
*/
function llms_featured_img( $post_id, $size ) {
$img = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size );
$html = '';
if ( isset( $img[0] ) ) {
$html = '<img src="' . $img[0] . '" alt="' . get_the_title( $post_id ) . '" class="llms-featured-image wp-post-image">';
}
/**
* Filters the featured image of a given LifterLMS post.
*
* @since unknown
* @since 7.1.2 Added `$post_id` parameter.
*
* @param string $html HTML img element or empty string if the post has no thumbnail.
* @param int|WP_Post $post_id Post ID or WP_Post object.
*/
return apply_filters( 'lifterlms_featured_img', $html, $post_id );
}
/**
* Retrieve author name, avatar, and bio
*
* @param array $args arguments
* @return string
* @since 3.0.0
* @version 3.13.0
*/
function llms_get_author( $args = array() ) {
$args = wp_parse_args(
$args,
array(
'avatar' => true,
'avatar_size' => 96,
'bio' => false,
'label' => '',
'user_id' => get_the_author_meta( 'ID' ),
)
);
$name = get_the_author_meta( 'display_name', $args['user_id'] );
if ( $args['avatar'] ) {
$img = get_avatar( $args['user_id'], $args['avatar_size'], apply_filters( 'lifterlms_author_avatar_placeholder', '' ), $name );
} else {
$img = '';
}
$img = apply_filters( 'llms_get_author_image', $img );
$desc = '';
if ( $args['bio'] ) {
$desc = get_the_author_meta( 'description', $args['user_id'] );
}
ob_start();
?>
<div class="llms-author">
<?php echo $img; ?>
<span class="llms-author-info name"><?php echo $name; ?></span>
<?php if ( $args['label'] ) : ?>
<span class="llms-author-info label"><?php echo $args['label']; ?></span>
<?php endif; ?>
<?php if ( $desc ) : ?>
<p class="llms-author-info bio"><?php echo $desc; ?></p>
<?php endif; ?>
</div>
<?php
$html = ob_get_clean();
return apply_filters( 'llms_get_author', $html );
}
/**
* Global Content Wrapper Start Template
*
* @return [type] [description]
*/
if ( ! function_exists( 'lifterlms_output_content_wrapper' ) ) {
function lifterlms_output_content_wrapper() {
llms_get_template( 'global/wrapper-start.php' );
}
}
/**
* Global Content Wrapper End Template
*
* @return [type] [description]
*/
if ( ! function_exists( 'lifterlms_output_content_wrapper_end' ) ) {
function lifterlms_output_content_wrapper_end() {
llms_get_template( 'global/wrapper-end.php' );
}
}
/**
* Sidebar Template
*
* @return [type] [description]
*/
if ( ! function_exists( 'lifterlms_get_sidebar' ) ) {
function lifterlms_get_sidebar() {
llms_get_template( 'global/sidebar.php' );
}
}
/**
* Get the link to the edit account details page
*
* @return string
*/
function llms_person_edit_account_url() {
$edit_account_url = llms_get_endpoint_url( 'edit-account', '', get_permalink( llms_get_page_id( 'myaccount' ) ) );
return apply_filters( 'lifterlms_person_edit_account_url', $edit_account_url );
}
/**
* Get the link to the redeem voucher page
*
* @return string
*/
function llms_person_redeem_voucher_url() {
$url = llms_get_endpoint_url( 'redeem-voucher', '', get_permalink( llms_get_page_id( 'myaccount' ) ) );
return apply_filters( 'lifterlms_person_redeem_voucher_url', $url );
}
/**
* Get the link to the My Courses endpoint
*
* @return string
*
* @since 3.0.0
*/
function llms_person_my_courses_url() {