LLMS_Shortcode_Course_Author

LLMS_Shortcode_Course_Author


Source Source

File: includes/shortcodes/class.llms.shortcode.course.author.php

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
class LLMS_Shortcode_Course_Author extends LLMS_Shortcode_Course_Element {
 
    /**
     * Shortcode tag
     *
     * @var string
     */
    public $tag = 'lifterlms_course_author';
 
    /**
     * Get default shortcode attributes.
     *
     * Retrieves an array of default attributes which are automatically merged
     * with the user submitted attributes and passed to $this->get_output()
     *
     * @since 3.6.0
     *
     * @return array
     */
    protected function get_default_attributes() {
        return array(
            'avatar_size' => 48,
            'bio'         => 'yes',
            'course_id'   => get_the_ID(),
        );
    }
 
    /**
     * Retrieve the author ID of the course
     *
     * Lessons and Quizzes cascade up
     *
     * @since 3.11.1
     *
     * @return int|null
     */
    private function get_author_id() {
 
        $post = llms_get_post( $this->get_attribute( 'course_id' ) );
        if ( ! $post ) {
            return null;
        }
        if ( in_array( $post, array( 'lesson', 'quiz' ) ) ) {
            $course = llms_get_post_parent_course( $post->get( 'id' ) );
            if ( ! $course ) {
                return null;
            }
        }
        return $post->get( 'author' );
 
    }
 
    /**
     * Call the template function for the course element
     *
     * @since 3.6.0
     * @since 3.11.1
     *
     * @return void
     */
    protected function template_function() {
 
        echo '<div class="llms-meta-info">';
        echo llms_get_author(
            array(
                'avatar_size' => $this->get_attribute( 'avatar_size' ),
                'bio'         => ( 'yes' === $this->get_attribute( 'bio' ) ) ? true : false,
                'user_id'     => $this->get_author_id(),
            )
        );
        echo '</div><!-- .llms-meta-info -->';
 
    }
 
}


Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
3.6.0
3.11.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.