LLMS_Meta_Box_Engagement::get_fields()
Return an empty array because the metabox fields here are completely custom
Return Return
(array)
Source Source
File: includes/admin/post-types/meta-boxes/class.llms.meta.box.engagement.php
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, ), ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |