PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.0.0
Tutor LMS – eLearning and online course solution v2.0.0
4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Tutor_Setup.php
tutor / classes Last commit date
Addons.php 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Announcements.php 4 years ago Assets.php 4 years ago Backend_Page_Trait.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_List.php 4 years ago Course_Settings_Tabs.php 4 years ago Course_Widget.php 4 years ago Custom_Validation.php 5 years ago Dashboard.php 4 years ago FormHandler.php 4 years ago Frontend.php 4 years ago Gutenberg.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options_V2.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 4 years ago Q_and_A.php 4 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 4 years ago Reviews.php 4 years ago Rewrite_Rules.php 4 years ago Shortcode.php 4 years ago Student.php 4 years ago Students_List.php 4 years ago Taxonomies.php 4 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 4 years ago Tools_V2.php 4 years ago Tutor.php 4 years ago TutorEDD.php 4 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 4 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 4 years ago Withdraw.php 4 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
Tutor_Setup.php
847 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8
9 class Tutor_Setup {
10
11 public function __construct() {
12 add_action( 'admin_menu', array( $this, 'admin_menus' ) );
13 add_action( 'admin_init', array( $this, 'setup_wizard' ) );
14 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
15 add_action( 'wp_ajax_setup_action', array( $this, 'tutor_setup_action' ) );
16 add_filter( 'tutor_wizard_attributes', array( $this, 'tutor_setup_attributes_callback' ) );
17 }
18
19 function tutor_setup_attributes_callback( $attr ) {
20 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
21 $final_arr = array();
22 $data_arr = $this->tutor_setup_attributes();
23 foreach ( $data_arr as $key => $section ) {
24 foreach ( $section['attr'] as $k => $val ) {
25 $final_arr[ $k ] = isset( $options[ $k ] ) ? $options[ $k ] : '';
26 }
27 }
28 return $final_arr;
29 }
30
31
32 public function tutor_setup_action() {
33 tutor_utils()->checking_nonce();
34
35 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
36 if ( ! isset( $_POST['action'] ) || $_POST['action'] != 'setup_action' || ! current_user_can( 'manage_options' ) ) {
37 return;
38 }
39
40 // General Settings
41 $change_data = apply_filters( 'tutor_wizard_attributes', array() );
42 foreach ( $change_data as $key => $value ) {
43 if ( isset( $_POST[ $key ] ) ) {
44 if ( $_POST[ $key ] != $change_data[ $key ] ) {
45 if ( $_POST[ $key ] == '' ) {
46 unset( $options[ $key ] );
47 } else {
48 $options[ $key ] = tutor_sanitize_data( $_POST[ $key ] );
49 }
50 }
51 $options_preset[ $key ] = tutor_sanitize_data( $_POST[ $key ] );
52 } else {
53 unset( $options[ $key ] );
54 }
55 }
56
57 // die(pr($options_preset));
58
59 update_option( 'tutor_default_option', $options_preset );
60
61 update_option( 'tutor_option', $options );
62
63 // Payment Settings
64 $payments = (array) maybe_unserialize( get_option( 'tutor_withdraw_options' ) );
65 $payments_data = array( 'bank_transfer_withdraw', 'echeck_withdraw', 'paypal_withdraw' );
66 foreach ( $payments_data as $key ) {
67 if ( isset( $_POST[ $key ] ) ) {
68 $payments[ $key ]['enabled'] = 1;
69 } else {
70 if ( $key == 'bank_transfer_withdraw' ) {
71 unset( $payments[ $key ]['enabled'] );
72 } else {
73 unset( $payments[ $key ] );
74 }
75 }
76 }
77 update_option( 'tutor_withdraw_options', $payments );
78
79 // Add wizard flug
80 // update_option('tutor_wizard', 'active');
81
82 wp_send_json_success( array( 'status' => 'success' ) );
83 }
84
85
86 public function admin_menus() {
87 add_dashboard_page( '', '', 'manage_options', 'tutor-setup', '' );
88 }
89
90 public function setup_wizard() {
91 if ( isset( $_GET['page'] ) ) {
92 if ( $_GET['page'] == 'tutor-setup' ) {
93 $this->tutor_setup_wizard_header();
94 $this->tutor_setup_wizard_boarding();
95 $this->tutor_setup_wizard_type();
96 $this->tutor_setup_wizard_settings();
97 $this->tutor_setup_wizard_footer();
98 exit;
99 }
100 }
101 }
102
103 public function tutor_setup_generator() {
104
105 $i = 1;
106 $html = '';
107 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
108 $payments = (array) maybe_unserialize( get_option( 'tutor_withdraw_options' ) );
109 $field_arr = $this->tutor_setup_attributes();
110
111 $down_desc_fields = array( 'rows', 'slider', 'text', 'radio', 'dropdown', 'range', 'payments' );
112 $full_width_fields = array( 'rows', 'slider', 'radio', 'range', 'payments', 'dropdown' );
113
114 foreach ( $field_arr as $key_parent => $field_parent ) {
115 // pr($key_parent);
116 $html .= '<li class="' . ( $i == 1 ? 'active' : '' ) . '">';
117 $html .= '<div class="tutor-setup-content-heading heading">';
118 $html .= '<div class="setup-section-title tutor-text-medium-h6 tutor-color-text-primary">' . $field_parent['lable'] . '</div>';
119 $html .= '<div class="step-info">';
120 $html .= '<span class="tutor-text-regular-caption tutor-color-text-hints">' . __( 'Step', 'tutor' ) . ':</span> <strong class="tutor-color-text-primary">' . $i . '/' . count( $field_arr ) . ' </strong>';
121 $html .= '</div>';
122 $html .= '<div class="tutor-reset-section tutor-text-btn-small tutor-color-text-subsued tutor-d-flex tutor-align-items-center">' . __( 'Reset Default', 'tutor' ) . '</div>';
123 $html .= '</div>';
124 $html .= '<div class="tutor-setup-content-heading body">';
125
126 foreach ( $field_parent['attr'] as $key => $field ) {
127 if ( ! isset( $field['lable'] ) ) {
128 continue; }
129
130 // Generate data attributes if necessary
131 $data_attr = '';
132 if ( isset( $field['data'] ) && is_array( $field['data'] ) ) {
133 foreach ( $field['data'] as $data_key => $data_value ) {
134 $data_attr .= ' data-' . $data_key . '="' . $data_value . '" ';
135 }
136 }
137
138 $html .= '<div class="tutor-setting' . ( in_array( $field['type'], $full_width_fields ) ? ' course-setting-wrapper' : '' ) . ' ' . ( isset( $field['class'] ) ? $field['class'] : '' ) . '">';
139 $html .= isset( $field['lable'] ) ? '<div class="tutor-text-regular-body tutor-color-text-primary ______">' . $field['lable'] : '';
140 // $html .= isset( $field['tooltip'] ) ? '<span id="tooltip-btn" class="tooltip-btn" data-tooltip="'.$field['tooltip'].'"><span></span></span>' : '';
141 $html .= isset( $field['tooltip'] ) ? '<span class="tooltip-wrap tooltip-icon"><span class="tooltip-txt tooltip-right">' . $field['tooltip'] . '</span></span>' : '';
142 $html .= isset( $field['lable'] ) ? '</div>' : '';
143
144 if ( ! in_array( $field['type'], $down_desc_fields ) ) {
145 $html .= isset( $field['desc'] ) ? '<div class="content tutor-text-regular-small tutor-color-text-subsued">' . $field['desc'] . '</div>' : '';
146 }
147
148 $html .= '<div class="settings">';
149
150 switch ( $field['type'] ) {
151
152 case 'switch':
153 $html .= '<label for="' . $key . '" class="switch-label input-switch-label">';
154 $html .= '<span class="label-off">' . __( 'OFF', 'tutor' ) . '</span>';
155 $html .= '<div class="switchbox-wrapper">';
156 $html .= '<input ' . $data_attr . ' id="' . $key . '" class="input-switchbox" type="checkbox" name="' . $key . '" value="on" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '/>';
157 $html .= '<span class="switchbox-icon"></span>';
158 $html .= '</div>';
159 $html .= '<span class="label-on">' . __( 'ON', 'tutor' ) . '</span>';
160 $html .= '</label>';
161 break;
162
163 case 'text':
164 $html .= '<input type="text" name="' . $key . '" class="lesson-permalink" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '" />';
165 break;
166
167 case 'rows':
168 $html .= '<div class="content">';
169 $html .= '<div class="course-per-row">';
170 $html .= '<div class="wrapper">';
171 $html .= '<label for="' . $key . '1">';
172 $html .= '<input type="radio" value="1" name="' . $key . '" class="course" id="' . $key . '1" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 1 ? 'checked' : '' ) . '>';
173 $html .= '<span class="span"><span>1</span></span>';
174 $html .= '</label>';
175 $html .= '</div>';
176 $html .= '<div class="wrapper">';
177 $html .= '<label for="' . $key . '2">';
178 $html .= '<input type="radio" value="2" name="' . $key . '" class="course" id="' . $key . '2" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 2 ? 'checked' : '' ) . '>';
179 $html .= '<span class="span"><span>2</span><span>2</span></span>';
180 $html .= '</label>';
181 $html .= '</div>';
182 $html .= '<div class="wrapper">';
183 $html .= '<label for="' . $key . '3">';
184 $html .= '<input type="radio" value="3" name="' . $key . '" class="course" id="' . $key . '3" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 3 ? 'checked' : '' ) . '>';
185 $html .= '<span class="span"><span>3</span><span>3</span><span>3</span></span>';
186 $html .= '</label>';
187 $html .= '</div>';
188 $html .= '<div class="wrapper">';
189 $html .= '<label for="' . $key . '4">';
190 $html .= '<input type="radio" value="4" name="' . $key . '" class="course" id="' . $key . '4" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 4 ? 'checked' : '' ) . '>';
191 $html .= '<span class="span"><span>4</span><span>4</span><span>4</span><span>4</span></span>';
192 $html .= '</label>';
193 $html .= '</div>';
194 $html .= '</div>';
195 $html .= '</div>';
196 break;
197
198 case 'radio':
199 if ( isset( $field['options'] ) ) {
200 foreach ( $field['options'] as $k => $val ) {
201 $html .= '<label for="' . $key . $k . '" class="time-expires"><input type="radio" id="' . $key . $k . '" name="' . $key . '" value="' . $k . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $k ? 'checked' : '' ) . ' /> ' . '<span class="radio-icon"></span>';
202 $html .= $val . '</label>';
203 }
204 }
205 break;
206
207 case 'slider':
208 $available_times = array(
209 'seconds' => __( 'seconds', 'tutor' ),
210 'minutes' => __( 'minutes', 'tutor' ),
211 'hours' => __( 'hours', 'tutor' ),
212 'days' => __( 'days', 'tutor' ),
213 'weeks' => __( 'weeks', 'tutor' ),
214 );
215 $html .= '<div class="limit-slider">';
216 if ( isset( $field['time'] ) ) {
217 $html .= '<input type="range" name="' . $key . '[value]" min="' . ( isset( $field['min'] ) ? $field['min'] : 0 ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 60 ) . '" step="1" value="' . ( isset( $options[ $key ]['value'] ) ? $options[ $key ]['value'] : '' ) . '" class="range-input"/>';
218 $html .= '<input type="hidden" name="' . $key . '[time]" value="' . ( isset( $options[ $key ]['time'] ) ? $options[ $key ]['time'] : __( 'minutes', 'tutor' ) ) . '" class="range-input"/>';
219 $html .= '<span class=""><span class="range-value">' . ( isset( $options[ $key ]['value'] ) ? $options[ $key ]['value'] : '' ) . '</span>';
220 $html .= isset( $options[ $key ]['time'] ) ? $available_times[ $options[ $key ]['time'] ] : '';
221 $html .= '</span>';
222 } else {
223 $html .= '<input type="range" name="' . $key . '" min="' . ( isset( $field['min'] ) ? $field['min'] : '' ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 30 ) . '" step="1" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '" class="range-input"/>';
224 $html .= ' <strong class="range-value">' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '</strong>';
225 }
226 $html .= '</div>';
227 break;
228
229 case 'dropdown':
230 $html .= '<div class="grade-calculation"><div class="select-box"><div class="options-container">';
231 $selected_data = '';
232 if ( isset( $field['options'] ) ) {
233 foreach ( $field['options'] as $val ) {
234 $html .= '<div class="option">';
235 $html .= '<input type="radio" class="radio" id="' . $val['value'] . '" name="' . $key . '" value="' . $val['value'] . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $val['value'] ? 'checked' : '' ) . ' />';
236 $html .= '<label for="' . $val['value'] . '">';
237 $html .= '<h3>' . $val['title'] . '</h3>';
238 $html .= '<h5>' . $val['desc'] . '</h5>';
239 $html .= '</label>';
240 $html .= '</div>';
241
242 if ( isset( $options[ $key ] ) && $options[ $key ] == $val['value'] ) {
243 $selected_data .= '<div class="selected">';
244 $selected_data .= '<h3>' . $val['title'] . '</h3>';
245 $selected_data .= '<h5>' . $val['desc'] . '</h5>';
246 $selected_data .= '</div>';
247 }
248 }
249 }
250 $html .= '</div>';
251 $html .= $selected_data ? $selected_data : '<div class="selected"><h3>' . $field['options'][0]['title'] . '</h3><h5>' . $field['options'][0]['desc'] . '</h5></div>';
252 $html .= '</div></div>';
253 break;
254
255 case 'payments':
256 $html .= '<div class="checkbox-wrapper column-3">';
257 $available_withdraw_methods = get_tutor_all_withdrawal_methods();
258 if ( ! empty( $available_withdraw_methods ) ) {
259 foreach ( $available_withdraw_methods as $key => $value ) {
260 $html .= '<div class="payment-setting">';
261 $html .= '<label for="' . $key . '" class="label">';
262 $html .= '<div>';
263 $html .= '<input type="checkbox" name="' . $key . '" id="' . $key . '" class="checkbox payment" ' . ( isset( $payments[ $key ]['enabled'] ) && $payments[ $key ]['enabled'] ? 'checked' : '' ) . ' />';
264 $html .= '<span class="check-icon round"></span>';
265 $html .= '</div>';
266 $html .= '<div>';
267 $html .= '<img src="' . $value['image'] . '" alt="' . $value['method_name'] . '">';
268 $html .= '<h4>' . $value['method_name'] . '</h4>';
269 $html .= '</div>';
270 $html .= '</label>';
271 $html .= '</div>';
272 }
273 }
274 $html .= '</div>';
275 break;
276
277 case 'range':
278 $earning_instructor = isset( $options['earning_instructor_commission'] ) ? $options['earning_instructor_commission'] : 80;
279 $earning_admin = isset( $options['earning_admin_commission'] ) ? $options['earning_admin_commission'] : 20;
280 $html .= '<div class="limit-slider column-1">';
281 $html .= '<div class="limit-slider-has-parent">';
282 $html .= '<input type="range" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-input double-range-slider" name=""/>';
283 $html .= '</div>';
284 $html .= '<div class="commision-data">';
285 $html .= '<div class="data">';
286 $html .= '<h4 class="range-value-1">' . $earning_instructor . '%</h4>';
287 $html .= '<h5>' . __( 'Instructor', 'tutor' ) . '</h5>';
288 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-value-data-1 range-input" name="earning_instructor_commission"/>';
289 $html .= '</div>';
290 $html .= '<div class="data">';
291 $html .= '<h4 class="range-value-2">' . $earning_admin . '%</h4>';
292 $html .= '<h5>' . __( 'Admin / Owner', 'tutor' ) . '</h5>';
293 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_admin . '" class="range-value-data-2 range-input" name="earning_admin_commission"/>';
294 $html .= '</div>';
295 $html .= '</div>';
296 $html .= '</div> ';
297 break;
298
299 case 'checkbox':
300 $html .= '<div class="checkbox-wrapper column-2">';
301 if ( isset( $field['options'] ) ) {
302 foreach ( $field['options'] as $k => $val ) {
303 $html .= '<div class="email-notification">';
304 $html .= '<label for="' . $key . $k . '" class="label">';
305 $html .= '<div>';
306 $html .= '<input type="checkbox" value="' . $k . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $k ? 'checked' : '' ) . ' name="' . $key . '" id="' . $key . $k . '" class="checkbox" />';
307 $html .= '<span class="check-icon square"></span>';
308 $html .= '</div>';
309 $html .= '<div>';
310 $html .= '<h4>' . $val . '</h4>';
311 $html .= '</div>';
312 $html .= '</label>';
313 $html .= '</div>';
314 }
315 }
316 $html .= '</div>';
317 break;
318
319 case 'attempt':
320 $html .= '<div class="tutor-setting course-setting-wrapper">';
321
322 $html .= '<input type="hidden" name="quiz_attempts_allowed" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : 'off' ) . '">';
323
324 $html .= '<div class="content">';
325 $html .= '<div class="course-per-page attempts-allowed">';
326 $html .= '<div class="wrapper">';
327 $html .= '<label for="attempts-allowed-1">';
328 $html .= '<input type="radio" value="single" name="attempts-allowed" class="course-p" id="attempts-allowed-1" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '>';
329 $html .= '<span class="radio-icon"></span>';
330 $html .= '<span class="label-text label-text-2">';
331 $html .= '<input type="number" value="' . $options[ $key ] . '" name="attempts-allowed-number" class="attempts tutor-form-number-verify" id="attempts-allowed-1" min="' . ( isset( $field['min'] ) ? $field['min'] : 0 ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 30 ) . '">';
332 $html .= '</span>';
333 $html .= '</label>';
334 $html .= '</div>';
335 $html .= '<div class="wrapper tutor-unlimited-value">';
336 $html .= '<label for="attempts-allowed-2">';
337 $html .= '<input type="radio" name="attempts-allowed" value="unlimited" class="course-p" id="attempts-allowed-2" ' . ( ( ! isset( $options[ $key ] ) ) || $options[ $key ] == 0 ? 'checked' : '' ) . '>';
338 $html .= '<span class="radio-icon"></span>';
339 $html .= '<span class="label-text">' . __( 'Unlimited', 'tutor' ) . '</span>';
340 $html .= '</label>';
341 $html .= '</div>';
342 $html .= '</div>';
343 $html .= '</div>';
344 $html .= '</div>';
345 break;
346
347 default:
348 // code...
349 break;
350 }
351
352 if ( in_array( $field['type'], $down_desc_fields ) ) {
353 $html .= isset( $field['desc'] ) ? '<div class="content">' . $field['desc'] . '</div>' : '';
354 }
355 $html .= '</div>';
356 $html .= '</div>';
357
358 }
359 $html .= '</div>';
360 if ( 'payments' !== $field['type'] ) {
361 $html .= $this->tutor_setup_wizard_action();
362 } else {
363 $html .= $this->tutor_setup_wizard_action_final();
364 }
365 $html .= '</li>';
366 $i++;
367 }
368
369 echo tutor_kses_html( $html );
370 }
371
372
373 public function tutor_setup_attributes() {
374 $general_fields = array(
375
376 'general' => array(
377 'lable' => __( 'General Settings', 'tutor' ),
378 'attr' => array(
379 'enable_course_marketplace' => array(
380 'type' => 'marketplace',
381 ),
382 'public_profile_layout' => array(
383 'type' => 'switch',
384 'data' => array(
385 'off' => 'private',
386 'on' => 'pp-rectangle',
387 ),
388 'lable' => __( 'Instructor Profile', 'tutor' ),
389 'desc' => __( 'Allow users to have a instructor profile to showcase awards and completed courses.', 'tutor' ),
390 ),
391 'student_public_profile_layout' => array(
392 'type' => 'switch',
393 'data' => array(
394 'off' => 'private',
395 'on' => 'pp-rectangle',
396 ),
397 'lable' => __( 'Student Profile', 'tutor' ),
398 'desc' => __( 'Allow users to have a student profile to showcase awards and completed courses.', 'tutor' ),
399 ),
400 'lesson_permalink_base' => array(
401 'type' => 'text',
402 'max' => 50,
403 'lable' => __( 'Lesson permalink', 'tutor' ),
404 'desc' => sprintf( __( 'Example: %s', 'tutor' ), get_home_url() . '/courses/sample-course/<strong>' . ( tutor_utils()->get_option( 'lesson_permalink_base', 'lessons' ) ) . '</strong>/sample-lesson/' ),
405 ),
406 ),
407 ),
408
409 'course' => array(
410 'lable' => __( 'Course Settings', 'tutor' ),
411 'attr' => array(
412 'display_course_instructors' => array(
413 'type' => 'switch',
414 'lable' => __( 'Show Instructor Bio', 'tutor' ),
415 'desc' => __( 'Let the students know the instructor(s). Display their credentials, professional experience, and more.', 'tutor' ),
416 ),
417 'enable_q_and_a_on_course' => array(
418 'type' => 'switch',
419 'lable' => __( 'Question and Anwser', 'tutor' ),
420 'desc' => __( 'Allows a Q&A forum on each course.', 'tutor' ),
421 ),
422 'courses_col_per_row' => array(
423 'type' => 'rows',
424 'lable' => __( 'Courses Per Row', 'tutor' ),
425 'tooltip' => __( 'How many courses per row on the archive pages.', 'tutor' ),
426 ),
427 'courses_per_page' => array(
428 'type' => 'slider',
429 'lable' => __( 'Courses Per Page', 'tutor' ),
430 'tooltip' => __( 'How many courses per page on the archive pages.', 'tutor' ),
431 ),
432 ),
433 ),
434
435 /*
436 'quiz' => array(
437 'lable' => __('Quiz Settings', 'tutor'),
438 'attr' => array(
439 'quiz_when_time_expires' => array(
440 'type' => 'radio',
441 'lable' => __('When Time Expires', 'tutor'),
442 'options' => array(
443 'autosubmit' => __('The current quiz answers are submitted automatically.', 'tutor'),
444 'graceperiod' => __('The current quiz answers are submitted by students.', 'tutor'),
445 'autoabandon' => __('Attempts must be submitted before time expires, otherwise they will not be counted', 'tutor'),
446 ),
447 'tooltip' => __('What message to display when the quiz time expires?', 'tutor'),
448 ),
449 'quiz_attempts_allowed' => array(
450 'type' => 'attempt',
451 'lable' => __('Attempts Allowed', 'tutor'),
452 'tooltip' => __('How many attempts does a student get to pass a quiz?', 'tutor'),
453 ),
454 'quiz_grade_method' => array(
455 'type' => 'dropdown',
456 'lable' => __('Final Grade Calculation', 'tutor'),
457 'options' => array(
458 array(
459 'title' => __('Highest Grade', 'tutor'),
460 'desc' => __('Pick the student’s best grade', 'tutor'),
461 'value' => 'highest_grade',
462 ),
463 array(
464 'title' => __('Average Grade', 'tutor'),
465 'desc' => __('Use the average score', 'tutor'),
466 'value' => 'average_grade',
467 ),
468 array(
469 'title' => __('First Attempt', 'tutor'),
470 'desc' => __('Pick the first attempt', 'tutor'),
471 'value' => 'first_attempt',
472 ),
473 array(
474 'title' => __('Last Attempt', 'tutor'),
475 'desc' => __('Pick the most recent attempt', 'tutor'),
476 'value' => 'last_attempt',
477 ),
478 ),
479 'tooltip' => __('When you allow multiple quiz attempts, which grade do you want to count?', 'tutor'),
480 )
481 )
482 ),
483 */
484
485 'instructor' => array(
486 'lable' => __( 'Instructor Settings', 'tutor' ),
487 'attr' => array(
488 'enable_become_instructor_btn' => array(
489 'type' => 'switch',
490 'lable' => __( 'New Signup', 'tutor' ),
491 'desc' => __( 'Choose between open and closed instructor signup. If you’re creating a course marketplace, instructor signup should be open.', 'tutor' ),
492 ),
493 'instructor_can_publish_course' => array(
494 'type' => 'switch',
495 'lable' => __( 'Earning', 'tutor' ),
496 'desc' => __( 'Enable earning for instructors?', 'tutor' ),
497 ),
498 ),
499 ),
500
501 'payment' => array(
502 'lable' => __( 'Payment Settings ', 'tutor' ),
503 'attr' => array(
504 'enable_guest_course_cart' => array(
505 'type' => 'switch',
506 'lable' => __( 'Guest Checkout', 'tutor' ),
507 'desc' => __( 'Allow users to buy and consume content without logging in.', 'tutor' ),
508 ),
509 'commission_split' => array(
510 'type' => 'range',
511 'lable' => __( 'Commission Rate', 'tutor' ),
512 'tooltip' => __( 'Control revenue sharing between admin and instructor.', 'tutor' ),
513 ),
514 'earning_instructor_commission' => array(
515 'type' => 'commission',
516 ),
517 'earning_admin_commission' => array(
518 'type' => 'commission',
519 ),
520 'withdraw_split' => array(
521 'type' => 'payments',
522 'lable' => __( 'Payment Withdrawal Method', 'tutor' ),
523 'desc' => __( 'Choose your preferred withdrawal method from the options.', 'tutor' ),
524 ),
525
526 ),
527 ),
528
529 );
530
531 return $general_fields;
532 }
533
534 public function tutor_setup_wizard_settings() {
535
536 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
537
538 ?>
539 <div class="tutor-wizard-container">
540 <div class="tutor-wrapper-boarding tutor-setup-wizard-settings">
541 <div class="tutor-setup-wrapper">
542 <ul class="tutor-setup-title">
543 <li data-url="general" class="general active current"><?php _e( 'General', 'tutor' ); ?></li>
544 <li data-url="course" class="course"><?php _e( 'Course', 'tutor' ); ?></li>
545 <!-- <li data-url="quiz" class="quiz"><?php // _e('Quiz', 'tutor'); ?></li> -->
546 <li data-url="instructor" class="instructor"><?php _e( 'Instructor', 'tutor' ); ?></li>
547 <!-- <li data-url="profile" class="profile"><?php // _e('Profile', 'tutor'); ?></li> -->
548 <li data-url="payment" class="payment"><?php _e( 'Payment', 'tutor' ); ?></li>
549 <li data-url="finish" style="display:none" class="finish"><?php _e( 'Finish', 'tutor' ); ?></li>
550 </ul>
551
552
553 <form id="tutor-setup-form" method="post">
554 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
555 <input type="hidden" name="action" value="setup_action">
556
557 <?php $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' ); ?>
558 <input type="hidden" name="enable_course_marketplace" class="enable_course_marketplace_data" value="<?php echo ( $course_marketplace ? 'on' : 'off' ); ?>">
559
560 <ul class="tutor-setup-content">
561 <?php $this->tutor_setup_generator(); ?>
562 <li>
563 <div class="tutor-setup-content-heading greetings">
564 <div class="header">
565 <img src="<?php echo tutor()->url . 'assets/images/greeting-img.png'; ?>" alt="greeting">
566 </div>
567 <div class="content">
568 <h2><?php _e( 'Congratulations, you’re all set!', 'tutor' ); ?></h2>
569 <p><?php _e( 'Tutor LMS is up and running on your website! If you really want to become a Tutor LMS genius, read our <a target="_blank" href="https://docs.themeum.com/tutor-lms/">documentation</a> that covers everything!', 'tutor' ); ?></p>
570 <p><?php _e( 'If you need further assistance, please don’t hesitate to contact us via our <a target="_blank" href="https://www.themeum.com/contact-us/">contact form.</a>', 'tutor' ); ?></p>
571 </div>
572 <div class="tutor-setup-content-footer footer">
573 <?php
574 $welcome_url = admin_url( 'admin.php?page=tutor&welcome=1' );
575 $addons_url = admin_url( 'admin.php?page=tutor-addons' );
576 $course_url = admin_url( 'admin.php?page=tutor' );
577 ?>
578 <a class="tutor-btn tutor-btn-primary tutor-btn-md primary-btn" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $course_url ); ?>">
579 <?php _e( 'Create a New Course', 'tutor' ); ?>
580 </a>
581 <a class="tutor-btn tutor-btn-tertiary tutor-is-outline tutor-btn-md" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $addons_url ); ?>">
582 <?php _e( 'Explore Addons', 'tutor' ); ?>
583 </a>
584 </div>
585 </div>
586 </li>
587 </ul>
588 </form>
589 </div>
590 </div>
591 </div>
592 <?php
593 }
594
595 public function tutor_setup_wizard_action() {
596 $html = '<div class="tutor-setup-content-footer footer">';
597 $html .= '<div class="tutor-setup-btn-wrapper">';
598 $html .= '<button class="tutor-btn tutor-btn-disable-outline tutor-btn-md tutor-setup-previous">';
599 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
600 $html .= '</button>';
601 $html .= '</div>';
602 $html .= '<div class="tutor-setup-btn-wrapper">';
603 $html .= '<button class="tutor-setup-skip">' . __( 'Skip this step', 'tutor' ) . '</button>';
604 $html .= '</div>';
605 $html .= '<div class="tutor-setup-btn-wrapper">';
606 $html .= '<button class="tutor-btn tutor-btn-md tutor-setup-next">';
607 $html .= '<span>' . __( 'Next', 'tutor' ) . '</span>&nbsp;<span>&#8594;</span>';
608 $html .= '</button>';
609 $html .= '</div>';
610 $html .= '</div>';
611
612 return $html;
613 }
614 public function tutor_setup_wizard_action_final() {
615 $html = '<div class="tutor-setup-content-footer footer">';
616 $html .= '<div class="tutor-setup-btn-wrapper">';
617 $html .= '<button class="tutor-btn tutor-btn-disable-outline tutor-btn-md tutor-setup-previous">';
618 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
619 $html .= '</button>';
620 $html .= '</div>';
621 $html .= '<div class="tutor-setup-btn-wrapper">';
622 $html .= '<button class="tutor-setup-skip">' . __( 'Skip this step', 'tutor' ) . '</button>';
623 $html .= '</div>';
624 $html .= '<div class="tutor-setup-btn-wrapper">';
625 $html .= '<button class="tutor-btn tutor-btn-md tutor-redirect tutor-setup-next">';
626 $html .= '<span>' . __( 'Finish Setup', 'tutor' );
627 $html .= '</button>';
628 $html .= '</div>';
629 $html .= '</div>';
630
631 return $html;
632 }
633
634 public function tutor_setup_wizard_boarding() {
635 global $current_user;
636 ?>
637 <div class="tutor-wizard-container">
638 <div class="tutor-wrapper-boarding tutor-setup-wizard-boarding active">
639 <div class="wizard-boarding-header">
640 <div>
641 <img src="<?php echo tutor()->url . 'assets/images/tutor-logo.svg'; ?>" />
642 </div>
643 <div>
644 <div class="wizard-boarding-header-sub tutor-text-regular-h5 tutor-color-text-primary">
645 <?php printf( __( 'Hello %s, welcome to Tutor LMS!', 'tutor' ), $current_user->user_login ); ?>
646 </div>
647 <div class="wizard-boarding-header-main tutor-text-semi-h3 tutor-color-text-primary tutor-mt-10">
648 <?php _e( 'Thank You for Choosing Us', 'tutor' ); ?>
649 </div>
650 </div>
651 </div>
652 <div class="wizard-boarding-body tutor-mt-60">
653 <ul class="slider tutor-boarding">
654 <li>
655 <div class="slide-thumb">
656 <img src="<?php echo tutor()->url . 'assets/images/scalable_lms_solution.jpg'; ?>" alt="<?php _e( 'A Powerful, Smart, and Scalable LMS Solution', 'tutor' ); ?>"/>
657 </div>
658 <div class="slide-title tutor-text-medium-h5 tutor-color-text-primary"><?php _e( 'A Powerful, Smart, and Scalable LMS Solution', 'tutor' ); ?></div>
659 <div class="slide-subtitle tutor-text-regular-body tutor-color-text-subsued tutor-mt-16">
660 <?php _e( 'From individual instructors to vast eLearning platforms, Tutor LMS grows with you to create your ideal vision of an LMS website.', 'tutor' ); ?>
661 </div>
662 </li>
663 <li>
664 <div class="slide-thumb">
665 <img src="<?php echo tutor()->url . 'assets/images/extensive_course_builder.jpg'; ?>" alt="<?php _e( 'Extensive Course Builder', 'tutor' ); ?>"/>
666 </div>
667 <div class="slide-title tutor-text-medium-h5 tutor-color-text-primary"><?php _e( 'Extensive Course Builder', 'tutor' ); ?></div>
668 <div class="slide-subtitle tutor-text-regular-body tutor-color-text-subsued tutor-mt-16">
669 <?php _e( 'Tutor LMS comes with a state-of-the-art frontend course builder. Construct rich and resourceful courses with ease.', 'tutor' ); ?>
670 </div>
671 </li>
672 <li>
673 <div class="slide-thumb">
674 <img src="<?php echo tutor()->url . 'assets/images/advanced_quiz_creator.jpg'; ?>" alt="<?php _e( 'Advanced Quiz Creator', 'tutor' ); ?>"/>
675 </div>
676 <div class="slide-title tutor-text-medium-h5 tutor-color-text-primary"><?php _e( 'Advanced Quiz Creator', 'tutor' ); ?></div>
677 <div class="slide-subtitle tutor-text-regular-body tutor-color-text-subsued tutor-mt-16">
678 <?php _e( 'Build interactive quizzes with the vast selection of question types and verify the learning of your students.', 'tutor' ); ?>
679 </div>
680 </li>
681 <li>
682 <div class="slide-thumb">
683 <img src="<?php echo tutor()->url . 'assets/images/freedom_with_ecommerce.jpg'; ?>" alt="<?php _e( 'Freedom With eCommerce', 'tutor' ); ?>"/>
684 </div>
685 <div class="slide-title tutor-text-medium-h5 tutor-color-text-primary"><?php _e( 'Freedom With eCommerce', 'tutor' ); ?></div>
686 <div class="slide-subtitle tutor-text-regular-body tutor-color-text-subsued tutor-mt-16">
687 <?php _e( 'Select an eCommerce plugin and sell courses any way you like and use any payment gateway you want!', 'tutor' ); ?>
688 </div>
689 </li>
690 <li>
691 <div class="slide-thumb">
692 <img src="<?php echo tutor()->url . 'assets/images/reports_and_analytics.jpg'; ?>" alt="<?php _e( 'Reports and Analytics', 'tutor' ); ?>"/>
693 </div>
694 <div class="slide-title tutor-text-medium-h5 tutor-color-text-primary"><?php _e( 'Reports and Analytics', 'tutor' ); ?></div>
695 <div class="slide-subtitle tutor-text-regular-body tutor-color-text-subsued tutor-mt-16">
696 <?php _e( 'Track what type of courses sell the most! Gain insights on user purchases, manage reviews and track quiz attempts.', 'tutor' ); ?>
697 </div>
698 </li>
699 </ul>
700 </div>
701 <div class="wizard-boarding-footer">
702 <div class="">
703 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-boarding-next">
704 <?php _e( 'Let’s Start', 'tutor' ); ?>
705 </button>
706 </div>
707 <div>
708 <a href="<?php echo admin_url( 'admin.php?page=tutor' ); ?>" class="tutor-text-btn-medium">
709 <?php _e( 'I already know, skip it!', 'tutor' ); ?>
710 </a>
711 </div>
712 </div>
713 </div>
714 </div>
715 <?php
716 }
717
718 public function tutor_setup_wizard_type() {
719 $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' );
720 $course_marketplace = 1 === $course_marketplace ? 'on' : 'off';
721 ?>
722 <div class="tutor-wizard-container">
723 <div class="tutor-wrapper-type tutor-setup-wizard-type">
724 <div class="wizard-type-header">
725 <div class="logo"><img src="<?php echo esc_url( tutor()->url . 'assets/images/tutor-logo.svg' ); ?>" /></div>
726 <div class="title"><?php _e( 'Let’s get the platform up and running', 'tutor' ); ?></div>
727 <div class="subtitle"><?php _e( 'Pick a category for your LMS platform. You can always update this later.', 'tutor' ); ?></div>
728 </div>
729 <div class="wizard-type-body">
730 <div class="wizard-type-item">
731 <input id="enable_course_marketplace-0" type="radio" name="enable_course_marketplace" value="off"
732 <?php
733 if ( ! $course_marketplace ) {
734 echo 'checked'; }
735 ?>
736 />
737 <span class="icon"></span>
738 <label for="enable_course_marketplace-0">
739 <img src="<?php echo esc_url( tutor()->url . 'assets/images/single-marketplace.svg' ); ?>" />
740 <div class="title"><?php _e( 'Individual', 'tutor' ); ?></div>
741 <div class="subtitle"><?php _e( 'Share solo journey as an educator and spared knowledge', 'tutor' ); ?></div>
742 <div class="action">
743 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-type-next">
744 <?php _e( 'Next', 'tutor' ); ?>
745 </button>
746 </div>
747 </label>
748 </div>
749
750 <div class="wizard-type-item">
751 <input id="enable_course_marketplace-1" type="radio" name="enable_course_marketplace" value="on"
752 <?php
753 if ( $course_marketplace ) {
754 echo 'checked'; }
755 ?>
756 />
757 <span class="icon"></span>
758 <label for="enable_course_marketplace-1">
759 <img src="<?php echo esc_url( tutor()->url . 'assets/images/multiple-marketplace.svg' ); ?>" />
760 <div class="title"><?php _e( 'Marketplace', 'tutor' ); ?></div>
761 <div class="subtitle"><?php _e( 'Create an eLearning platform to let anyone earn by teaching online', 'tutor' ); ?></div>
762 <div class="action">
763 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-type-next">
764 <?php _e( 'Next', 'tutor' ); ?>
765 </button>
766 </div>
767 </label>
768 </div>
769 </div>
770
771 <div class="wizard-type-footer">
772 <div class="tutor-text-regular-caption">
773 <span><?php _e( 'Not sure?', 'tutor' ); ?></span>&nbsp;
774 <a href="#" class="tutor-type-skip" class="">
775 <?php _e( 'Let’s go to the next step.', 'tutor' ); ?>
776 </a>
777 </div>
778 </div>
779 </div>
780 </div>
781 <?php
782 }
783
784
785 public function tutor_setup_wizard_header() {
786 set_current_screen();
787 ?>
788 <!DOCTYPE html>
789 <html <?php language_attributes(); ?>>
790 <head>
791 <meta name="viewport" content="width=device-width" />
792 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
793 <title><?php esc_html_e( 'Tutor &rsaquo; Setup Wizard', 'tutor' ); ?></title>
794 <?php do_action( 'admin_enqueue_scripts' ); ?>
795 <?php wp_print_scripts( 'tutor-plyr' ); ?>
796 <?php wp_print_scripts( 'tutor-slick' ); ?>
797 <?php wp_print_scripts( 'tutor-setup' ); ?>
798 <?php do_action( 'admin_print_styles' ); ?>
799 <?php do_action( 'admin_head' ); ?>
800 </head>
801 <body class="tutor-setup wp-core-ui">
802 <?php
803 }
804
805
806 public function tutor_setup_wizard_footer() {
807 ?>
808 </body>
809 </html>
810 <?php
811 }
812
813 public function enqueue_scripts() {
814 if ( isset( $_GET['page'] ) && $_GET['page'] == 'tutor-setup' ) {
815 wp_enqueue_style( 'tutor-setup', tutor()->url . 'assets/css/tutor-setup.min.css', array(), TUTOR_VERSION );
816 wp_enqueue_style( 'tutor-slick', tutor()->url . 'assets/packages/slick/slick.css', array(), TUTOR_VERSION );
817 wp_enqueue_style( 'tutor-slick-theme', tutor()->url . 'assets/packages/slick/slick-theme.css', array(), TUTOR_VERSION );
818 wp_register_script( 'tutor-slick', tutor()->url . 'assets/packages/slick/slick.min.js', array( 'jquery' ), TUTOR_VERSION, true );
819 wp_register_script( 'tutor-setup-v2', tutor()->url . 'assets/js/tutor.min.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
820 wp_register_script( 'tutor-setup', tutor()->url . 'assets/js/tutor-setup.min.js', array( 'jquery', 'tutor-slick', 'wp-i18n' ), TUTOR_VERSION, true );
821 wp_localize_script( 'tutor-setup', '_tutorobject', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
822 }
823 }
824
825
826 /**
827 * Check if welcome page already visited
828 *
829 * @return mixed
830 */
831 public static function is_welcome_page_visited(): bool {
832 return false;
833 // $visited = get_option( 'tutor_welcome_page_visited' );
834 // return $visited ? true : false;
835 }
836
837 /**
838 * Mark as welcome page visited
839 *
840 * @return void
841 */
842 public static function mark_as_visited() {
843 update_option( 'tutor_welcome_page_visited', true );
844 }
845 }
846
847