LLMS_Meta_Box_Engagement::get_fields()

Return an empty array because the metabox fields here are completely custom


Return Return

(array)


Top ↑

Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.engagement.php

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
public function get_fields() {
 
    $triggers = llms_get_engagement_triggers();
 
    $types = llms_get_engagement_types();
 
    $fields = array();
 
    $fields[] = array(
        'allow_null'    => false,
        'class'         => 'llms-select2',
        'desc'          => __( 'This engagement will be triggered when a student completes the selected action', 'lifterlms' ),
        'id'            => $this->prefix . 'trigger_type',
        'is_controller' => true,
        'type'          => 'select',
        'label'         => __( 'Triggering Event', 'lifterlms' ),
        'value'         => $triggers,
    );
 
    $trigger_post_fields = array(
 
        'course'           => array(
            'controller_value' => array(
                'course_completed',
                'course_enrollment',
                'course_purchased',
            ),
            'id'               => '_faux_engagement_trigger_post_course',
            'label'            => __( 'Select a Course', 'lifterlms' ),
        ),
 
        'lesson'           => array(
            'controller_value' => array( 'lesson_completed' ),
            'id'               => '_faux_engagement_trigger_post_lesson',
            'label'            => __( 'Select a Lesson', 'lifterlms' ),
        ),
 
        'llms_access_plan' => array(
            'controller_value' => array(
                'access_plan_purchased',
            ),
            'id'               => '_faux_engagement_trigger_post_access_plan',
            'label'            => __( 'Select an Access Plan', 'lifterlms' ),
        ),
 
        'llms_membership'  => array(
            'controller_value' => array(
                'membership_enrollment',
                'membership_purchased',
            ),
            'id'               => '_faux_engagement_trigger_post_membership',
            'label'            => __( 'Select a Membership', 'lifterlms' ),
        ),
 
        'llms_quiz'        => array(
            'controller_value' => array(
                'quiz_completed',
                'quiz_passed',
                'quiz_failed',
            ),
            'id'               => '_faux_engagement_trigger_post_quiz',
            'label'            => __( 'Select a Quiz', 'lifterlms' ),
        ),
 
        'section'          => array(
            'controller_value' => array( 'section_completed' ),
            'id'               => '_faux_engagement_trigger_post_section',
            'label'            => __( 'Select a Section', 'lifterlms' ),
        ),
 
    );
 
    foreach ( $trigger_post_fields as $post_type => $data ) {
 
        $data['controller_value'] = apply_filters( 'llms_engagement_controller_values_' . $post_type, $data['controller_value'] );
 
        if ( in_array( get_post_meta( $this->post->ID, $this->prefix . 'trigger_type', true ), $data['controller_value'] ) ) {
            $val = llms_make_select2_post_array( array( get_post_meta( $this->post->ID, $this->prefix . 'engagement_trigger_post', true ) ) );
        } else {
            $val = array();
        }
 
        $fields[] = array(
            'allow_null'       => false,
            'class'            => 'llms-select2-post',
            'controller'       => '#' . $this->prefix . 'trigger_type',
            'controller_value' => implode( ',', $data['controller_value'] ),
            'data_attributes'  => array(
                'allow_clear' => true,
                'placeholder' => $data['label'],
                'post-type'   => $post_type,
            ),
            'id'               => $data['id'],
            'label'            => $data['label'],
            'type'             => 'select',
            'value'            => $val,
        );
 
    }
 
    $track_options = array();
    $tracks        = get_terms(
        'course_track',
        array(
            'hide_empty' => '0',
        )
    );
    foreach ( $tracks as $track ) {
        $track_options[] = array(
            'key'   => $track->term_id,
            'title' => $track->name . ' (ID# ' . $track->term_id . ')',
        );
    }
 
    $fields[] = array(
        'allow_null'       => false,
        'class'            => 'llms-select2',
        'controller'       => '#' . $this->prefix . 'trigger_type',
        'controller_value' => implode( ',', apply_filters( 'llms_engagement_controller_values_track', array( 'course_track_completed' ) ) ),
        'data_attributes'  => array(
            'allow_clear' => true,
            'placeholder' => __( 'Select a Course Track', 'lifterlms' ),
        ),
        'id'               => '_faux_engagement_trigger_post_track',
        'label'            => __( 'Select a Course Track', 'lifterlms' ),
        'type'             => 'select',
        'selected'         => get_post_meta( $this->post->ID, $this->prefix . 'engagement_trigger_post', true ),
        'value'            => $track_options,
    );
 
    $fields[] = array(
        'allow_null'    => false,
        'class'         => 'llms-select2',
        'desc'          => __( 'Determines the type of engagement', 'lifterlms' ),
        'id'            => $this->prefix . 'engagement_type',
        'is_controller' => true,
        'label'         => __( 'Engagement Type', 'lifterlms' ),
        'type'          => 'select',
        'value'         => $types,
    );
 
    $type    = get_post_meta( $this->post->ID, $this->prefix . 'engagement_type', true );
    $default = ( ! $type ) ? 'llms_achievement' : 'llms_' . $type;
 
    $fields[] = array(
        'allow_null'      => false,
        'class'           => 'llms-select2-post',
        'data_attributes' => array(
            'allow_clear' => true,
            'placeholder' => __( 'Select an Engagement', 'lifterlms' ),
            'post-type'   => $default,
        ),
        'id'              => $this->prefix . 'engagement',
        'label'           => __( 'Select an Engagement', 'lifterlms' ),
        'type'            => 'select',
        'value'           => llms_make_select2_post_array( array( get_post_meta( $this->post->ID, $this->prefix . 'engagement', true ) ) ),
    );
 
    $fields[] = array(
        'class'   => 'input-full',
        'default' => 0,
        'desc'    => __( 'Enter the number of days to wait before triggering this engagement. Enter 0 or leave blank to trigger immediately.', 'lifterlms' ),
        'id'      => $this->prefix . 'engagement_delay',
        'label'   => __( 'Engagement Delay', 'lifterlms' ),
        'min'     => 0,
        'type'    => 'number',
    );
 
    return array(
        array(
            'title'  => __( 'Engagement Settings', 'lifterlms' ),
            'fields' => $fields,
        ),
    );
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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