LLMS_Notification_View_Section_Complete

Notification View: Section Complete


Source Source

File: includes/notifications/views/class.llms.notification.view.section.complete.php

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
class LLMS_Notification_View_Section_Complete extends LLMS_Abstract_Notification_View {
 
    /**
     * Settings for basic notifications
     *
     * @var  array
     */
    protected $basic_options = array(
        /**
         * Time in milliseconds to show a notification
         * before automatically dismissing it
         */
        'auto_dismiss' => 10000,
        /**
         * Enables manual dismissal of notifications
         */
        'dismissible'  => true,
    );
 
    /**
     * Notification Trigger ID
     *
     * @var  [type]
     */
    public $trigger_id = 'section_complete';
 
    /**
     * Setup body content for output
     *
     * @return   string
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_body() {
        if ( 'email' === $this->notification->get( 'type' ) ) {
            return sprintf( __( 'Congratulations! %1$s completed %2$s', 'lifterlms' ), '{{STUDENT_NAME}}', '{{SECTION_TITLE}}' );
        }
        return sprintf( __( 'Congratulations! You finished %s', 'lifterlms' ), '{{SECTION_TITLE}}' );
    }
 
    /**
     * Setup footer content for output
     *
     * @return   string
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_footer() {
        return '';
    }
 
    /**
     * Setup notification icon for output
     *
     * @return   string
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_icon() {
        return $this->get_icon_default( 'positive' );
    }
 
    /**
     * Setup merge codes that can be used with the notification
     *
     * @return   array
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_merge_codes() {
        return array(
            '{{COURSE_PROGRESS}}' => __( 'Course Progress Bar', 'lifterlms' ),
            '{{COURSE_TITLE}}'    => __( 'Course Title', 'lifterlms' ),
            '{{SECTION_TITLE}}'   => __( 'Section Title', 'lifterlms' ),
            '{{STUDENT_NAME}}'    => __( 'Student Name', 'lifterlms' ),
        );
    }
 
    /**
     * Replace merge codes with actual values
     *
     * @param    string $code  the merge code to ge merged data for
     * @return   string
     * @since    3.8.0
     * @version  3.10.1
     */
    protected function set_merge_data( $code ) {
 
        switch ( $code ) {
 
            case '{{COURSE_PROGRESS}}':
                $progress = $this->user->get_progress( $this->post->get( 'parent_course' ), 'course' );
                $code     = lifterlms_course_progress_bar( $progress, false, false, false );
                break;
 
            case '{{COURSE_TITLE}}':
                $course = $this->post->get_course();
                if ( $course ) {
                    $code = $course->get( 'title' );
                } else {
                    $code = '';
                }
                break;
 
            case '{{SECTION_TITLE}}':
                $code = $this->post->get( 'title' );
                break;
 
            case '{{STUDENT_NAME}}':
                $code = $this->is_for_self() ? __( 'you', 'lifterlms' ) : $this->user->get_name();
                break;
 
        }
 
        return $code;
 
    }
 
    /**
     * Setup notification subject for output
     *
     * @return   string
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_subject() {
        return sprintf( __( 'Congratulations! %1$s completed %2$s', 'lifterlms' ), '{{STUDENT_NAME}}', '{{SECTION_TITLE}}' );
    }
 
    /**
     * Setup notification title for output
     *
     * @return   string
     * @since    3.8.0
     * @version  3.8.0
     */
    protected function set_title() {
        return sprintf( __( '%s Completed a Section', 'lifterlms' ), '{{STUDENT_NAME}}' );
    }
 
}


Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0
3.10.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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