course
4 years ago
course-add-edd-product-metabox.php
3 years ago
course-add-product-metabox.php
3 years ago
course-additional-data.php
4 years ago
course-contents.php
4 years ago
course-level-metabox.php
4 years ago
course-topics.php
3 years ago
instructors-metabox.php
3 years ago
lesson-attachments-metabox.php
4 years ago
lesson-metabox.php
4 years ago
product-selection.php
3 years ago
settings-tabs.php
3 years ago
user-profile-fields.php
4 years ago
video-metabox.php
3 years ago
settings-tabs.php
211 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Settings meta box template |
| 4 | * |
| 5 | * @package Tutor\Metabox |
| 6 | */ |
| 7 | |
| 8 | $args = $this->args; |
| 9 | |
| 10 | ?> |
| 11 | |
| 12 | <div id="tutor-metabox-course-settings-tabs" class="tutor-course-settings-tabs"> |
| 13 | <div class="course-settings-tabs-container"> |
| 14 | <div class="settings-tabs-navs-wrap"> |
| 15 | <ul class="settings-tabs-navs"> |
| 16 | <?php |
| 17 | $i = 0; |
| 18 | foreach ( $args as $key => $arg ) { |
| 19 | $i++; |
| 20 | |
| 21 | $active = $i === 1 ? 'active' : ''; |
| 22 | |
| 23 | $label = tutor_utils()->array_get( 'label', $arg ); |
| 24 | $icon_class = tutor_utils()->array_get( 'icon_class', $arg ); |
| 25 | $url = add_query_arg( array( 'settings_tab' => $key ) ); |
| 26 | |
| 27 | $icon = ''; |
| 28 | if ( $icon_class ) { |
| 29 | $icon = $icon_class; |
| 30 | } |
| 31 | ?> |
| 32 | <li class="<?php echo esc_attr( $active ); ?>"> |
| 33 | <a href="<?php echo esc_url( $url ); ?>" data-target="#settings-tab-<?php echo esc_attr( $key ); ?>"> |
| 34 | <i class="<?php echo esc_attr( $icon ); ?>"></i> <?php echo esc_html( $label ); ?> |
| 35 | </a> |
| 36 | </li> |
| 37 | <?php |
| 38 | } |
| 39 | ?> |
| 40 | </ul> |
| 41 | </div> |
| 42 | |
| 43 | <div class="settings-tabs-container"> |
| 44 | <?php |
| 45 | |
| 46 | $i = 0; |
| 47 | |
| 48 | foreach ( $args as $key => $tab ) { |
| 49 | $i++; |
| 50 | |
| 51 | $label = tutor_utils()->array_get( 'label', $tab ); |
| 52 | $callback = tutor_utils()->array_get( 'callback', $tab ); |
| 53 | $fields = tutor_utils()->array_get( 'fields', $tab ); |
| 54 | |
| 55 | // Set first tab as active. |
| 56 | $active = $i === 1 ? 'active' : ''; |
| 57 | $display = $i === 1 ? 'block' : 'none'; |
| 58 | ?> |
| 59 | |
| 60 | |
| 61 | <div id="settings-tab-<?php echo esc_attr( $key ); ?>" class="settings-tab-wrap <?php echo esc_attr( $active ); ?>" style="display: <?php echo esc_attr( $display ); ?>;"> |
| 62 | <?php |
| 63 | do_action( 'tutor_course/settings_tab_content/before', $key, $tab ); |
| 64 | do_action( "tutor_course/settings_tab_content/before/{$key}", $tab ); |
| 65 | |
| 66 | |
| 67 | if ( tutor_utils()->count( $fields ) ) { |
| 68 | foreach ( $fields as $field_key => $field ) { |
| 69 | $type = tutor_utils()->array_get( 'type', $field ); |
| 70 | $value = tutor_utils()->array_get( 'value', $field ); |
| 71 | |
| 72 | if ( $type == 'line_break' ) { |
| 73 | echo '<hr class="tutor-mb-32"/>'; |
| 74 | continue; |
| 75 | } |
| 76 | ?> |
| 77 | <div class="tutor-row tutor-mb-32"> |
| 78 | <?php |
| 79 | $second_class = 'tutor-col-12'; |
| 80 | $_vertical = isset( $field['is_vertical'] ) ? $field['is_vertical'] : false; |
| 81 | |
| 82 | if ( ! empty( $field['label'] ) ) { |
| 83 | $second_class = 'tutor-col-12 ' . ( $_vertical ? '' : 'tutor-col-md-7' ); |
| 84 | ?> |
| 85 | <div class="tutor-col-12 <?php echo esc_attr( $_vertical ? '' : 'tutor-col-md-5' ); ?>"> |
| 86 | <label class="tutor-course-setting-label"> |
| 87 | <?php echo esc_html( $field['label'] ); ?> |
| 88 | </label> |
| 89 | <?php if ( isset( $field['desc'] ) && 'Content Drip Type' === $field['label'] ) { ?> |
| 90 | <p class="tutor-form-feedback"> |
| 91 | <?php echo esc_html( $field['desc'] ); ?> |
| 92 | </p> |
| 93 | <?php } ?> |
| 94 | </div> |
| 95 | <?php |
| 96 | } |
| 97 | ?> |
| 98 | <div class="<?php echo esc_attr( $second_class ); ?>"> |
| 99 | <?php |
| 100 | switch ( $field['type'] ) { |
| 101 | case 'number': |
| 102 | echo '<input class="tutor-form-control" type="number" name="' . esc_attr( $field_key ) . '" value="' . esc_attr( $value ) . '" min="0">'; |
| 103 | break; |
| 104 | |
| 105 | case 'radio': |
| 106 | foreach ( $field['options'] as $value => $label ) { |
| 107 | $id_string = 'course_setting_radio_' . ( ! empty( $field['id'] ) ? $field['id'] : $value ); |
| 108 | ?> |
| 109 | <div class="tutor-my-20 tutor-align-center"> |
| 110 | <div class="tutor-form-check"> |
| 111 | <input type="radio" id="<?php echo esc_attr( $id_string ); ?>" class="tutor-form-check-input tutor-flex-shrink-0" name="<?php echo esc_attr( $field_key ); ?>" value="<?php echo esc_attr( $value ); ?>" <?php echo $value == $field['value'] ? 'checked="checked"' : ''; ?>/> |
| 112 | <label for="<?php echo esc_attr( $id_string ); ?>" class="tutor-fs-7 tutor-fw-medium tutor-fs-6"> |
| 113 | <?php echo esc_attr( $label ); ?> |
| 114 | </label> |
| 115 | </div> |
| 116 | </div> |
| 117 | <?php |
| 118 | } |
| 119 | break; |
| 120 | |
| 121 | case 'checkbox': |
| 122 | case 'toggle_switch': |
| 123 | foreach ( $field['options'] as $option ) { |
| 124 | $fragment = ( ! empty( $field['id'] ) ? $field['id'] : $field['type'] . '_' . $field_key ); |
| 125 | $id_string = 'course_setting_' . $fragment; |
| 126 | |
| 127 | if ( $field['type'] == 'checkbox' ) { |
| 128 | ?> |
| 129 | <div class="tutor-form-check tutor-mb-12"> |
| 130 | <input id="<?php echo esc_attr( $id_string ); ?>" type="checkbox" class="tutor-form-check-input" value="<?php echo isset( $option['value'] ) ? esc_attr( $option['value'] ) : ''; ?>" name="<?php echo esc_attr( $field_key ); ?>" <?php echo $option['checked'] ? 'checked="checked"' : ''; ?>/> |
| 131 | <label for="<?php echo esc_attr( $id_string ); ?>" class="tutor-fs-7 tutor-fw-medium"> |
| 132 | <?php echo esc_html( $option['label_title'] ); ?> |
| 133 | <?php |
| 134 | if ( ! empty( $option['hint'] ) ) { |
| 135 | echo '<span class="tutor-d-block tutor-fs-7">' . esc_html( $option['hint'] ) . '</span>'; |
| 136 | } |
| 137 | ?> |
| 138 | </label> |
| 139 | </div> |
| 140 | <?php |
| 141 | } elseif ( $field['type'] == 'toggle_switch' ) { |
| 142 | ?> |
| 143 | <label class="tutor-form-toggle"> |
| 144 | <input id="<?php echo esc_attr( $id_string ); ?>" type="checkbox" class="tutor-form-toggle-input" name="<?php echo esc_attr( $field_key ); ?>" <?php echo $option['checked'] ? 'checked="checked"' : ''; ?>/> |
| 145 | <span class="tutor-form-toggle-control"></span> <?php echo isset( $option['label_title'] ) ? esc_attr( $option['label_title'] ) : ''; ?> |
| 146 | </label> |
| 147 | <?php |
| 148 | |
| 149 | if ( ! empty( $option['hint'] ) ) { |
| 150 | ?> |
| 151 | <div class="tutor-fs-7 tutor-has-icon tutor-color-muted tutor-d-flex tutor-mt-12"> |
| 152 | <i class="tutor-icon-circle-info-o tutor-mt-4 tutor-mr-8"></i> |
| 153 | <?php echo esc_html( $option['hint'] ); ?> |
| 154 | </div> |
| 155 | <?php |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | break; |
| 160 | |
| 161 | case 'select': |
| 162 | ?> |
| 163 | <select class="tutor-form-select" name="<?php echo esc_attr( $field_key ); ?>" class="tutor_select2"> |
| 164 | <?php |
| 165 | if ( ! empty( $field['options'] ) ) { |
| 166 | foreach ( $field['options'] as $optionKey => $option ) { |
| 167 | ?> |
| 168 | <option value="<?php echo esc_attr( $optionKey ); ?>" <?php selected( $field['value'], $optionKey ); ?> > |
| 169 | <?php echo esc_html( $option ); ?> |
| 170 | </option> |
| 171 | <?php |
| 172 | } |
| 173 | } |
| 174 | ?> |
| 175 | </select> |
| 176 | <?php |
| 177 | break; |
| 178 | } |
| 179 | |
| 180 | if ( isset( $field['desc'] ) && 'Content Drip Type' !== $field['label'] ) { |
| 181 | ?> |
| 182 | <div class="tutor-fs-7 tutor-has-icon tutor-color-muted tutor-d-flex tutor-mt-12"> |
| 183 | <i class="tutor-icon-circle-info-o tutor-mt-4 tutor-mr-8"></i> |
| 184 | <?php echo esc_html( $field['desc'] ); ?> |
| 185 | </div> |
| 186 | <?php |
| 187 | } |
| 188 | ?> |
| 189 | </div> |
| 190 | </div> |
| 191 | <?php |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Handling Callback |
| 197 | */ |
| 198 | if ( $callback && is_callable( $callback ) ) { |
| 199 | call_user_func( $callback, $key, $tab ); |
| 200 | } |
| 201 | |
| 202 | do_action( 'tutor_course/settings_tab_content/after', $key, $tab ); |
| 203 | do_action( "tutor_course/settings_tab_content/after/{$key}", $tab ); |
| 204 | |
| 205 | echo '</div>'; |
| 206 | } |
| 207 | ?> |
| 208 | </div> |
| 209 | </div> |
| 210 | </div> |
| 211 |