PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.7.7
Tutor LMS – eLearning and online course solution v2.7.7
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 / Options_V2.php
tutor / classes Last commit date
Addons.php 2 years ago Admin.php 2 years ago Ajax.php 1 year ago Announcements.php 1 year ago Assets.php 2 years ago Backend_Page_Trait.php 3 years ago Course.php 1 year ago Course_Embed.php 3 years ago Course_Filter.php 1 year ago Course_List.php 1 year ago Course_Settings_Tabs.php 3 years ago Course_Widget.php 3 years ago Custom_Validation.php 3 years ago Dashboard.php 3 years ago FormHandler.php 2 years ago Frontend.php 2 years ago Gutenberg.php 3 years ago Input.php 3 years ago Instructor.php 1 year ago Instructors_List.php 1 year ago Lesson.php 1 year ago Options_V2.php 1 year ago Permalink.php 2 years ago Post_types.php 2 years ago Private_Course_Access.php 3 years ago Q_And_A.php 1 year ago Question_Answers_List.php 3 years ago Quiz.php 1 year ago Quiz_Attempts_List.php 1 year ago RestAPI.php 2 years ago Reviews.php 3 years ago Rewrite_Rules.php 2 years ago Shortcode.php 1 year ago Student.php 2 years ago Students_List.php 3 years ago Taxonomies.php 3 years ago Template.php 2 years ago Theme_Compatibility.php 3 years ago Tools.php 3 years ago Tools_V2.php 2 years ago Tutor.php 2 years ago TutorEDD.php 2 years ago Tutor_Base.php 2 years ago Tutor_Setup.php 2 years ago Upgrader.php 2 years ago User.php 2 years ago Utils.php 1 year ago Video_Stream.php 3 years ago WhatsNew.php 2 years ago Withdraw.php 2 years ago Withdraw_Requests_List.php 3 years ago WooCommerce.php 1 year ago
Options_V2.php
1807 lines
1 <?php
2 /**
3 * Settings options
4 *
5 * @package Tutor\Settings
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 2.0.0
9 */
10
11 namespace Tutor;
12
13 use TUTOR\Input;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Contains all the settings options
21 *
22 * @since 2.0.0
23 */
24 class Options_V2 {
25
26 /**
27 * Undocumented variable
28 *
29 * @since 2.0.0
30 *
31 * @var array $options
32 */
33 private $options;
34
35 /**
36 * Settings fields
37 *
38 * @since 2.0.0
39 *
40 * @var mixed $setting_fields
41 */
42 private $setting_fields;
43
44 /**
45 * Register hooks
46 *
47 * @since 2.0.0
48 *
49 * @param boolean $register_hook should register hook or not.
50 *
51 * @return void
52 */
53 public function __construct( $register_hook = true ) {
54 if ( ! $register_hook ) {
55 return;
56 }
57
58 // Saving option.
59 add_action( 'tutor_option_save_before', array( $this, 'validate_options' ) );
60 add_action( 'wp_ajax_tutor_option_save', array( $this, 'tutor_option_save' ) );
61 add_action( 'wp_ajax_tutor_option_default_save', array( $this, 'tutor_option_default_save' ) );
62 add_action( 'wp_ajax_tutor_option_search', array( $this, 'tutor_option_search' ) );
63 add_action( 'wp_ajax_tutor_export_settings', array( $this, 'tutor_export_settings' ) );
64 add_action( 'wp_ajax_tutor_export_single_settings', array( $this, 'tutor_export_single_settings' ) );
65 add_action( 'wp_ajax_tutor_delete_single_settings', array( $this, 'tutor_delete_single_settings' ) );
66 add_action( 'wp_ajax_tutor_import_settings', array( $this, 'tutor_import_settings' ) );
67 add_action( 'wp_ajax_tutor_apply_settings', array( $this, 'tutor_apply_settings' ) );
68 add_action( 'wp_ajax_load_saved_data', array( $this, 'load_saved_data' ) );
69 add_action( 'wp_ajax_reset_settings_data', array( $this, 'reset_settings_data' ) );
70 }
71
72 /**
73 * Get settings value
74 *
75 * @since 2.0.0
76 *
77 * @param mixed $key option key.
78 * @param mixed $default default value.
79 *
80 * @return mixed
81 */
82 private function get( $key = null, $default = false ) {
83
84 if ( ! $this->options ) {
85 // Get if already not prepared.
86 $this->options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
87 }
88
89 $option = $this->options;
90
91 if ( empty( $option ) || ! is_array( $option ) ) {
92 return $default;
93 }
94
95 if ( ! $key ) {
96 return $option;
97 }
98
99 if ( array_key_exists( $key, $option ) ) {
100 return apply_filters( $key, $option[ $key ] );
101 }
102
103 // Access array value via dot notation, such as option->get('value.subvalue').
104 if ( strpos( $key, '.' ) ) {
105 $option_key_array = explode( '.', $key );
106 $new_option = $option;
107 foreach ( $option_key_array as $dot_key ) {
108 if ( isset( $new_option[ $dot_key ] ) ) {
109 $new_option = $new_option[ $dot_key ];
110 } else {
111 return $default;
112 }
113 }
114
115 return apply_filters( $key, $new_option );
116 }
117
118 return $default;
119 }
120
121 /**
122 * Function to get all fields for search tutor_option_search
123 *
124 * @since 2.0.0
125 *
126 * @return void send wp_json response
127 */
128 public function tutor_option_search() {
129 tutor_utils()->checking_nonce();
130
131 $data_array = array();
132 foreach ( $this->get_setting_fields() as $sections ) {
133 if ( is_array( $sections ) && ! empty( $sections ) ) {
134 foreach ( tutils()->sanitize_recursively( $sections ) as $section ) {
135 foreach ( $section['blocks'] as $blocks ) {
136 if ( isset( $blocks['fields'] ) && ! empty( $blocks['fields'] ) ) {
137 foreach ( $blocks['fields'] as $fields ) {
138 $fields['section_label'] = isset( $section['label'] ) ? $section['label'] : '';
139 $fields['section_slug'] = isset( $section['slug'] ) ? $section['slug'] : '';
140 $fields['block_label'] = isset( $blocks['label'] ) ? $blocks['label'] : '';
141 $data_array['fields'][] = $fields;
142 }
143 }
144 }
145 }
146 }
147 }
148
149 wp_send_json_success( $data_array );
150 }
151
152 /**
153 * Export settings
154 *
155 * @since 2.0.0
156 *
157 * @return void send wp_json response
158 */
159 public function tutor_export_settings() {
160 tutor_utils()->checking_nonce();
161 // Check if user is privileged.
162 if ( ! current_user_can( 'administrator' ) ) {
163 wp_send_json_error( tutor_utils()->error_message() );
164 }
165
166 $tutor_option = get_option( 'tutor_option' );
167 wp_send_json_success( maybe_unserialize( $tutor_option ) );
168 }
169
170 /**
171 * Export single settings
172 *
173 * @since 2.0.0
174 *
175 * @return void send wp_json response
176 */
177 public function tutor_export_single_settings() {
178
179 tutor_utils()->checking_nonce();
180
181 // Check if user is privileged.
182 if ( ! current_user_can( 'administrator' ) ) {
183 wp_send_json_error( tutor_utils()->error_message() );
184 }
185
186 $tutor_settings_log = get_option( 'tutor_settings_log' );
187 $export_id = $this->get_request_data( 'export_id' );
188 wp_send_json_success( $tutor_settings_log[ $export_id ] );
189 }
190
191 /**
192 * Apply settings
193 *
194 * @since 2.0.0
195 *
196 * @return void send wp_json response
197 */
198 public function tutor_apply_settings() {
199
200 tutor_utils()->checking_nonce();
201
202 // Check if user is privileged.
203 if ( ! current_user_can( 'administrator' ) ) {
204 wp_send_json_error( tutor_utils()->error_message() );
205 }
206
207 $tutor_settings_log = get_option( 'tutor_settings_log' );
208 $apply_id = $this->get_request_data( 'apply_id' );
209
210 update_option( 'tutor_option', $tutor_settings_log[ $apply_id ]['dataset'] );
211
212 wp_send_json_success( $tutor_settings_log[ $apply_id ] );
213 }
214
215 /**
216 * Delete single setting
217 *
218 * @since 2.0.0
219 *
220 * @return void send wp_json response
221 */
222 public function tutor_delete_single_settings() {
223
224 tutor_utils()->checking_nonce();
225
226 // Check if user is privileged.
227 if ( ! current_user_can( 'administrator' ) ) {
228 wp_send_json_error( tutor_utils()->error_message() );
229 }
230
231 $tutor_settings_log = get_option( 'tutor_settings_log' );
232 $delete_id = $this->get_request_data( 'delete_id' );
233 unset( $tutor_settings_log[ $delete_id ] );
234 update_option( 'tutor_settings_log', $tutor_settings_log );
235
236 wp_send_json_success( $tutor_settings_log );
237 }
238
239 /**
240 * Get request data
241 *
242 * @since 2.0.0
243 *
244 * @param mixed $var option key.
245 *
246 * @return mixed
247 */
248 public function get_request_data( $var ) {
249 return isset( $_REQUEST[ $var ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $var ] ) ) : null;
250 }
251
252 /**
253 * Tutor default settings update options
254 * and send json response
255 *
256 * @since 2.0.0
257 *
258 * @return void send wp_json response
259 */
260 public function tutor_default_settings() {
261 $attr = $this->get_setting_fields();
262
263 foreach ( $attr as $sections ) {
264
265 foreach ( $sections as $section ) {
266 foreach ( $section['blocks'] as $blocks ) {
267 foreach ( $blocks['fields'] as $field ) {
268 if ( isset( $field['default'] ) ) {
269 $attr_default[ $field['key'] ] = $field['default'];
270 }
271 }
272 }
273 }
274 }
275
276 update_option( 'tutor_option', $attr_default );
277
278 wp_send_json_success( $attr_default );
279 }
280
281 /**
282 * Tutor settings log
283 *
284 * @since 2.0.0
285 *
286 * @return void send wp_json response
287 */
288 public function load_saved_data() {
289 tutor_utils()->checking_nonce();
290
291 // Check if user is privileged.
292 if ( ! current_user_can( 'administrator' ) ) {
293 wp_send_json_error( tutor_utils()->error_message() );
294 }
295
296 wp_send_json_success( get_option( 'tutor_settings_log' ) );
297 }
298
299 /**
300 * Reset settings
301 *
302 * @since 2.0.0
303 *
304 * @return void send wp_json response
305 */
306 public function reset_settings_data() {
307 tutor_utils()->checking_nonce();
308
309 // Check if user is privileged.
310 if ( ! current_user_can( 'administrator' ) ) {
311 wp_send_json_error( tutor_utils()->error_message() );
312 }
313
314 $reset_fields = $return_fields = $return_fields_group = array(); //phpcs:ignore
315 $reset_page = Input::post( 'reset_page' );
316 $setting_data = $this->get_setting_fields()['option_fields'][ $reset_page ]['blocks'];
317
318 foreach ( $setting_data as $blocks ) {
319
320 $block_fields = isset( $blocks['fields'] ) ? $blocks['fields'] : array();
321 foreach ( $block_fields as $fields ) {
322 $return_fields[] = $fields;
323 }
324
325 $block_fields_group = isset( $blocks['fields_group'] ) ? $blocks['fields_group'] : array();
326 foreach ( $block_fields_group as $fields ) {
327 $return_fields_group[] = $fields;
328 }
329 }
330
331 $reset_fields = array_merge( $return_fields, $return_fields_group );
332
333 wp_send_json_success( $reset_fields );
334 }
335
336 /**
337 * Import settings
338 *
339 * @since 2.0.0
340 *
341 * @return void
342 */
343 public function tutor_import_settings() {
344 tutor_utils()->checking_nonce();
345
346 // Check if user is privileged.
347 if ( ! current_user_can( 'administrator' ) ) {
348 wp_send_json_error( tutor_utils()->error_message() );
349 }
350
351 $request = $this->get_request_data( 'tutor_options' );
352 $request = json_decode( stripslashes( $request ), true );
353
354 $time = $this->get_request_data( 'time' );
355
356 $save_import_data['datetime'] = (int) $time;
357 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
358 $save_import_data['datatype'] = 'imported';
359 $save_import_data['dataset'] = $request['data'];
360 $import_data[ 'tutor-imported-' . $time ] = $save_import_data;
361
362 $get_option_data = get_option( 'tutor_settings_log' );
363 if ( empty( $get_option_data ) ) {
364 $get_option_data = array();
365 }
366 if ( ! empty( $get_option_data ) && null !== $save_import_data['dataset'] ) {
367
368 $update_option = array_merge( $import_data, $get_option_data );
369
370 $update_option = tutor_utils()->sanitize_recursively( $update_option );
371
372 if ( ! empty( $update_option ) ) {
373 update_option( 'tutor_settings_log', $update_option );
374 }
375
376 if ( ! empty( $save_import_data ) ) {
377 update_option( 'tutor_option', $save_import_data['dataset'] );
378 }
379
380 $get_final_data = get_option( 'tutor_settings_log' );
381 } else {
382 if ( ! empty( $import_data ) ) {
383 update_option( 'tutor_settings_log', $import_data );
384 }
385
386 if ( ! empty( $save_import_data ) ) {
387 update_option( 'tutor_option', $save_import_data['dataset'] );
388 }
389 $get_final_data = get_option( 'tutor_settings_log' );
390 }
391
392 wp_send_json_success( $get_final_data );
393 }
394
395 /**
396 * Validate options before save.
397 *
398 * @since 2.8.0
399 *
400 * @param array $options option submitted to save.
401 *
402 * @return void
403 */
404 public function validate_options( $options ) {
405 $success = true;
406 $message = '';
407
408 $enable_sharing = $options['enable_revenue_sharing'] ?? 'off';
409 $admin_commission = (int) $options['earning_admin_commission'] ?? 0;
410 $instructor_commission = (int) $options['earning_instructor_commission'] ?? 0;
411
412 if ( 'on' === $enable_sharing && ( $admin_commission + $instructor_commission ) > 100 ) {
413 $success = false;
414 $message = __( 'Total share percentage must be 100% or less' );
415 }
416
417 if ( ! $success ) {
418 wp_send_json(
419 array(
420 'success' => $success,
421 'message' => $message,
422 )
423 );
424 }
425
426 }
427
428 /**
429 * Function tutor_option_save
430 *
431 * @since 2.0.0
432 *
433 * @return void send wp_json response
434 */
435 public function tutor_option_save() {
436 tutor_utils()->checking_nonce();
437
438 ! current_user_can( 'manage_options' ) ? wp_send_json_error() : 0;
439
440 $data_before = get_option( 'tutor_option' );
441 $option = (array) tutor_utils()->array_get( 'tutor_option', $_POST, array() ); //phpcs:ignore
442 do_action( 'tutor_option_save_before', $option );
443
444 $option = tutor_utils()->sanitize_recursively( $option );
445 $option = apply_filters( 'tutor_option_input', $option );
446
447 $time = strtotime( 'now' ) + ( 6 * 60 * 60 );
448 $save_import_data['datetime'] = $time;
449 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
450 $save_import_data['datatype'] = 'saved';
451 $save_import_data['dataset'] = $option;
452 $import_data[ 'tutor-saved-' . $time ] = $save_import_data;
453 $update_option = array();
454 $get_option_data = get_option( 'tutor_settings_log', array() );
455
456 if ( ! empty( $get_option_data ) ) {
457 $update_option = array_merge( $import_data, $get_option_data );
458 } else {
459 $update_option = array_merge( $update_option, $import_data );
460 }
461
462 $update_option = array_slice( $update_option, 0, 10 );
463
464 update_option( 'tutor_settings_log', $update_option );
465 update_option( 'tutor_option', $option );
466 update_option( 'tutor_option_update_time', gmdate( 'j M, Y, g:i a', $time ) );
467
468 /**
469 * Hook for each tutor settings option change detection.
470 * Example: `tutor_option_{course_permalink_base}_changed`
471 *
472 * @since 2.6.0
473 */
474 $data_after = get_option( 'tutor_option' );
475 if ( $data_before !== $data_after && is_array( $data_after ) ) {
476 foreach ( $data_after as $key => $value ) {
477 $from = $data_before[ $key ] ?? null;
478 $to = $value;
479 if ( $from !== $to ) {
480 do_action( "tutor_option_{$key}_changed", $from, $to );
481 }
482 }
483 }
484
485 do_action( 'tutor_option_save_after' );
486
487 $data = apply_filters(
488 'tutor_option_saved_data',
489 array(
490 'success' => true,
491 'message' => __( 'Settings Saved', 'tutor' ),
492 'options' => $option,
493 )
494 );
495
496 wp_send_json( $data );
497 }
498
499 /**
500 * Function tutor_option_save
501 *
502 * @since 2.0.0
503 *
504 * @return void send wp_json response
505 */
506 public function tutor_option_default_save() {
507 tutor_utils()->checking_nonce();
508
509 ! current_user_can( 'manage_options' ) ? wp_send_json_error() : 0;
510 $attr = $this->get_setting_fields();
511 $tutor_default_option = get_option( 'tutor_default_option' );
512 $tutor_saved_option = get_option( 'tutor_option' );
513
514 foreach ( $attr as $sections ) {
515 foreach ( $sections as $section ) {
516 foreach ( $section['blocks'] as $blocks ) {
517 foreach ( $blocks['fields'] as $field ) {
518 if ( isset( $tutor_default_option[ $field['key'] ] ) ) {
519 $attr_default[ $field['key'] ] = $tutor_saved_option[ $field['key'] ];
520 } else {
521 if ( null !== $field['key'] ) {
522 $attr_default[ $field['key'] ] = $field['default'];
523 }
524 }
525 }
526 }
527 }
528 }
529
530 update_option( 'tutor_option', $attr_default );
531
532 wp_send_json_success( $attr_default );
533 }
534
535 /**
536 * Load settings page
537 *
538 * @since 2.0.0
539 *
540 * @return void
541 */
542 public function load_settings_page() {
543 extract( $this->get_setting_fields() ); //phpcs:ignore
544
545 if ( ! $template_path ) {
546 $template_path = tutor()->path . '/views/options/settings.php';
547 }
548 include $template_path;
549 }
550
551 /**
552 * Get settings fields
553 *
554 * @since 2.0.0
555 *
556 * @return mixed
557 */
558 public function get_setting_fields() {
559 if ( $this->setting_fields ) {
560 // Return from property if already prepared.
561 return $this->setting_fields;
562 }
563
564 $pages = tutor_utils()->get_pages();
565
566 $site_url = site_url();
567 $course_base = $this->get( 'course_permalink_base', 'courses' );
568 $lesson_key = $this->get( 'lesson_permalink_base', 'lessons' );
569 $quiz_key = $this->get( 'quiz_permalink_base', 'quizzes' );
570
571 $course_url = $site_url . '/<code>' . $course_base . '</code>/sample-course';
572 $lesson_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $lesson_key . '</code>/sample-lesson/';
573 $quiz_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $quiz_key . '</code>/sample-quiz/';
574
575 $student_url = tutor_utils()->profile_url( 0, false );
576 $methods_array = array();
577 $withdrawl_methods = apply_filters( 'tutor_withdrawal_methods_all', array() );
578
579 foreach ( $withdrawl_methods as $key => $method ) {
580 $methods_array[ $key ] = $method['method_name'];
581 }
582
583 $page_args = array(
584 'post_type' => 'page',
585 'post_status' => 'publish',
586 'posts_per_page' => 1,
587 'title' => 'Courses',
588 );
589
590 $page_posts = get_posts( $page_args );
591 $course_archive_page_id = ( is_array( $page_posts ) && count( $page_posts ) ) ? $page_posts[0] : null;
592
593 $attr = array(
594 'general' => array(
595 'label' => __( 'General', 'tutor' ),
596 'slug' => 'general',
597 'desc' => __( 'General Settings', 'tutor' ),
598 'template' => 'basic',
599 'icon' => 'tutor-icon-earth',
600 'blocks' => array(
601 array(
602 'label' => false,
603 'block_type' => 'uniform',
604 'slug' => 'general-page',
605 'fields' => array(
606 array(
607 'key' => 'tutor_dashboard_page_id',
608 'type' => 'select',
609 'label' => __( 'Dashboard Page', 'tutor' ),
610 'default' => '0',
611 'options' => $pages,
612 'desc' => __( 'This page will be used for student and instructor dashboard', 'tutor' ),
613 ),
614 ),
615 ),
616 array(
617 'label' => false,
618 'block_type' => 'uniform',
619 'slug' => 'general-page',
620 'fields' => array(
621 array(
622 'key' => 'tutor_toc_page_id',
623 'type' => 'select',
624 'label' => __( 'Terms and Conditions Page', 'tutor' ),
625 'default' => '0',
626 'options' => $pages,
627 'desc' => __( 'This page will be used as the Terms and Conditions page', 'tutor' ),
628 ),
629 ),
630 ),
631 array(
632 'label' => __( 'Others', 'tutor' ),
633 'slug' => 'others',
634 'block_type' => 'isolate',
635 'fields' => array(
636 array(
637 'key' => 'enable_course_marketplace',
638 'type' => 'toggle_switch',
639 'label' => __( 'Enable Marketplace', 'tutor' ),
640 'label_title' => '',
641 'default' => 'off',
642 'desc' => __( 'Allow multiple instructors to upload their courses.', 'tutor' ),
643 ),
644 array(
645 'key' => 'pagination_per_page',
646 'type' => 'number',
647 'number_type' => 'integer',
648 'label' => __( 'Pagination', 'tutor' ),
649 'default' => '20',
650 'desc' => __( 'Set the number of rows to be displayed per page', 'tutor' ),
651 ),
652 ),
653 ),
654 array(
655 'label' => __( 'Instructor', 'tutor' ),
656 'slug' => 'instructor',
657 'block_type' => 'uniform',
658 'fields' => array(
659 array(
660 'key' => 'instructor_can_publish_course',
661 'type' => 'toggle_switch',
662 'label' => __( 'Allow Instructors To Publish Courses', 'tutor' ),
663 'label_title' => '',
664 'default' => 'off',
665 'desc' => __( 'Enable instructors to publish the course directly. If disabled, admins will be able to review course content before publishing.', 'tutor' ),
666 ),
667 array(
668 'key' => 'instructor_can_delete_course',
669 'type' => 'toggle_switch',
670 'label' => __( 'Allow Instructors to Trash Courses', 'tutor' ),
671 'label_title' => '',
672 'default' => 'on',
673 'desc' => __( 'Enable to allow instructors to trash courses. Disable to prevent them from trashing courses.', 'tutor' ),
674 ),
675 array(
676 'key' => 'enable_become_instructor_btn',
677 'type' => 'toggle_switch',
678 'label' => __( 'Become an Instructor Button', 'tutor' ),
679 'label_title' => '',
680 'default' => 'off',
681 'desc' => __( 'Enable the option to display this button on the student dashboard.', 'tutor' ),
682 ),
683 ),
684 ),
685 ),
686 ),
687 'course' => array(
688 'label' => __( 'Course', 'tutor' ),
689 'slug' => 'course',
690 'desc' => __( 'Course Settings', 'tutor' ),
691 'template' => 'basic',
692 'icon' => 'tutor-icon-book-open',
693 'blocks' => array(
694 'block_course' => array(
695 'label' => '',
696 'slug' => 'course',
697 'block_type' => 'uniform',
698 'fields' => array(
699 array(
700 'key' => 'student_must_login_to_view_course',
701 'type' => 'toggle_switch',
702 'label' => __( 'Course Visibility', 'tutor' ),
703 'label_title' => '',
704 'default' => 'off',
705 'desc' => __( 'Students must be logged in to view course', 'tutor' ),
706 ),
707 array(
708 'key' => 'course_content_access_for_ia',
709 'type' => 'toggle_switch',
710 'label' => __( 'Course Content Access', 'tutor' ),
711 'default' => 'off',
712 'label_title' => '',
713 'desc' => __( 'Allow instructors and admins to view the course content without enrolling', 'tutor' ),
714 ),
715 array(
716 'key' => 'course_content_summary',
717 'type' => 'toggle_switch',
718 'label' => __( 'Content Summary', 'tutor' ),
719 'default' => 'on',
720 'desc' => __( 'Enabling this feature will show a course content summary on the Course Details page.', 'tutor' ),
721 ),
722 array(
723 'key' => 'wc_automatic_order_complete_redirect_to_courses',
724 'type' => 'toggle_switch',
725 'label' => __( 'Auto redirect to courses', 'tutor' ),
726 'default' => 'off',
727 'label_title' => '',
728 'desc' => __( 'When a user\'s WooCommerce order is auto-completed, they will be redirected to enrolled courses', 'tutor' ),
729 ),
730 array(
731 'key' => 'enable_spotlight_mode',
732 'type' => 'toggle_switch',
733 'label' => __( 'Spotlight mode', 'tutor' ),
734 'default' => 'off',
735 'label_title' => '',
736 'desc' => __( 'This will hide the header and the footer and enable spotlight (full screen) mode when students view lessons.', 'tutor' ),
737 ),
738 array(
739 'key' => 'auto_course_complete_on_all_lesson_completion',
740 'type' => 'toggle_switch',
741 'label' => __( 'Auto Complete Course on all Lesson Completion', 'tutor' ),
742 'default' => 'off',
743 'label_title' => '',
744 'desc' => __( 'If enabled, an Enrolled Course will be automatically completed if all its Lessons, Quizzes, and Assignments are already completed by the Student', 'tutor' ),
745 ),
746 array(
747 'key' => 'course_completion_process',
748 'type' => 'radio_vertical',
749 'label' => __( 'Course Completion Process', 'tutor' ),
750 'default' => 'flexible',
751 'select_options' => false,
752 'options' => array(
753 'flexible' => __( 'Students can complete courses anytime in the Flexible mode', 'tutor' ),
754 'strict' => __( 'Students have to complete, pass all the lessons and quizzes (if any) to mark a course as complete.', 'tutor' ),
755 ),
756 'desc' => __( 'Choose when a user can click on the <strong>“Complete Course”</strong> button', 'tutor' ),
757 ),
758 array(
759 'key' => 'course_retake_feature',
760 'type' => 'toggle_switch',
761 'label' => __( 'Course Retake', 'tutor' ),
762 'default' => 'off',
763 'label_title' => '',
764 'desc' => __( 'Enabling this feature will allow students to reset course progress and start over.', 'tutor' ),
765 ),
766 array(
767 'key' => 'enable_course_review_moderation',
768 'type' => 'toggle_switch',
769 'label' => __( "Publish Course Review on Admin's Approval", 'tutor' ),
770 'default' => 'off',
771 'label_title' => '',
772 'desc' => __( 'Enable to publish/re-publish Course Review after the approval of Site Admin', 'tutor' ),
773 ),
774 ),
775 ),
776 'block_lesson' => array(
777 'label' => __( 'Lesson', 'tutor' ),
778 'slug' => 'lesson',
779 'block_type' => 'uniform',
780 'fields' => array(
781 array(
782 'key' => 'enable_lesson_classic_editor',
783 'type' => 'toggle_switch',
784 'label' => __( 'WP Editor for Lesson', 'tutor' ),
785 'label_title' => '',
786 'default' => 'off',
787 'desc' => __( 'Enable classic editor to edit lesson.', 'tutor' ),
788 ),
789 array(
790 'key' => 'autoload_next_course_content',
791 'type' => 'toggle_switch',
792 'label' => __( 'Automatically Load Next Course Content.', 'tutor' ),
793 'label_title' => '',
794 'default' => 'off',
795 'desc' => __( 'Enable this feature to automatically load the next course content after the current one is finished.', 'tutor' ),
796 ),
797 array(
798 'key' => 'enable_comment_for_lesson',
799 'type' => 'toggle_switch',
800 'label' => __( 'Enable Lesson Comment', 'tutor' ),
801 'label_title' => '',
802 'default' => 'off',
803 'desc' => __( 'Enable this feature to allow students to post comments on lessons.', 'tutor' ),
804 ),
805 ),
806 ),
807 'block_quiz' => array(
808 'label' => __( 'Quiz', 'tutor' ),
809 'slug' => 'quiz',
810 'block_type' => 'uniform',
811 'fields' => array(
812 array(
813 'key' => 'quiz_when_time_expires',
814 'type' => 'radio_vertical',
815 'label' => __( 'When time expires', 'tutor' ),
816 'default' => 'auto_abandon',
817 'select_options' => false,
818 'options' => array(
819 'auto_submit' => __( 'The current quiz answers are submitted automatically.', 'tutor' ),
820 // 'grace_period' => __( 'The current quiz answers are submitted by students.', 'tutor' )
821 'auto_abandon' => __( 'Attempts must be submitted before time expires, otherwise they will not be counted', 'tutor' ),
822 ),
823 'desc' => __( 'Choose which action to follow when the quiz time expires.', 'tutor' ),
824 ),
825 array(
826 'key' => 'quiz_answer_display_time',
827 'type' => 'number',
828 'label' => __( 'Correct Answer Display Time (when Reveal Mode is enabled)', 'tutor' ),
829 'default' => '2',
830 'desc' => __( 'Put the answer display time in seconds', 'tutor' ),
831 ),
832 array(
833 'key' => 'quiz_attempts_allowed',
834 'type' => 'number',
835 'number_type' => 'integer',
836 'label' => __( 'Default Quiz Attempt limit (when Retry Mode is enabled)', 'tutor' ),
837 'default' => '10',
838 'desc' => __( 'The highest number of attempts allowed for students to participate a quiz. 0 means unlimited. This will work as the default Quiz Attempt limit in case of Quiz Retry Mode.', 'tutor' ),
839 ),
840 array(
841 'key' => 'quiz_previous_button_enabled',
842 'type' => 'toggle_switch',
843 'label' => __( 'Show Quiz Previous Button', 'tutor' ),
844 'default' => 'on',
845 'desc' => __( 'Choose whether to show or hide the previous button for each question.', 'tutor' ),
846 ),
847 array(
848 'key' => 'quiz_grade_method',
849 'type' => 'radio_horizontal_full',
850 'label' => __( 'Final Grade Calculation', 'tutor' ),
851 'desc' => __( 'When multiple attempts are allowed, select which method should be used to calculate a student\'s final grade for the quiz.', 'tutor' ),
852 'default' => 'highest_grade',
853 'options' => array(
854 'highest_grade' => __( 'Highest Grade', 'tutor' ),
855 'average_grade' => __( 'Average Grade', 'tutor' ),
856 'first_attempt' => __( 'First Attempt', 'tutor' ),
857 'last_attempt' => __( 'Last Attempt', 'tutor' ),
858 ),
859 ),
860 ),
861 ),
862 array(
863 'label' => __( 'Video', 'tutor' ),
864 'slug' => 'video',
865 'block_type' => 'uniform',
866 'fields' => array(
867 array(
868 'key' => 'supported_video_sources',
869 'type' => 'checkbox_vertical',
870 'default' => array( 'youtube', 'vimeo' ),
871 'label' => __( 'Preferred Video Source', 'tutor' ),
872 'label_title' => __( 'Preferred Video Source', 'tutor' ),
873 'options' => tutor_utils()->get_video_sources( true ),
874 'desc' => __( 'Choose video sources you\'d like to support.', 'tutor' ),
875 ),
876 ),
877 ),
878 ),
879 ),
880 'monetization' => array(
881 'label' => __( 'Monetization', 'tutor' ),
882 'slug' => 'monetization',
883 'desc' => __( 'Monitization Settings', 'tutor' ),
884 'template' => 'basic',
885 'icon' => 'tutor-icon-badge-discount',
886 'blocks' => array(
887 'block_options' => array(
888 'label' => __( 'Options', 'tutor' ),
889 'slug' => 'options',
890 'block_type' => 'uniform',
891 'fields' => array(
892 array(
893 'key' => 'monetize_by',
894 'type' => 'select',
895 'label' => __( 'Select eCommerce Engine', 'tutor' ),
896 'select_options' => true,
897 'options' => apply_filters(
898 'tutor_monetization_options',
899 array(
900 'free' => __( 'Disable Monetization', 'tutor' ),
901 )
902 ),
903 'default' => 'free',
904 'desc' => __( 'Select a monetization option to generate revenue by selling courses. Supports: WooCommerce, Easy Digital Downloads, Paid Memberships Pro', 'tutor' ),
905 ),
906 array(
907 'key' => 'tutor_woocommerce_order_auto_complete',
908 'type' => 'toggle_switch',
909 'label' => __( 'Automatically Complete WooCommerce Orders', 'tutor' ),
910 'label_title' => '',
911 'default' => 'off',
912 'desc' => __( 'If enabled, in the case of Courses, WooCommerce Orders will get the "Completed" status .', 'tutor' ),
913 ),
914 array(
915 'key' => 'enable_revenue_sharing',
916 'type' => 'toggle_switch',
917 'label' => __( 'Enable Revenue Sharing', 'tutor' ),
918 'label_title' => '',
919 'default' => 'off',
920 'desc' => __( 'Allow revenue generated from selling courses to be shared with course creators.', 'tutor' ),
921 'toggle_fields' => 'sharing_percentage',
922 ),
923 array(
924 'key' => 'sharing_percentage',
925 'type' => 'double_input',
926 'label' => __( 'Sharing Percentage', 'tutor' ),
927 'label_title' => '',
928 'default' => '',
929 'fields' => array(
930 'earning_instructor_commission' => array(
931 'id' => 'revenue-instructor',
932 'type' => 'ratio',
933 'title' => 'Instructor Takes',
934 'default' => 20,
935 ),
936 'earning_admin_commission' => array(
937 'id' => 'revenue-admin',
938 'type' => 'ratio',
939 'title' => 'Admin Takes',
940 'default' => 80,
941 ),
942 ),
943 'desc' => __( 'Set how the sales revenue will be shared among admins and instructors.', 'tutor' ),
944 ),
945 array(
946 'key' => 'statement_show_per_page',
947 'type' => 'number',
948 'number_type' => 'integer',
949 'label' => __( 'Show Statement Per Page', 'tutor' ),
950 'default' => '20',
951
952 'desc' => __( 'Define the number of statements to show.', 'tutor' ),
953 ),
954 ),
955 ),
956 array(
957 'label' => __( 'Fees', 'tutor' ),
958 'slug' => 'fees',
959 'block_type' => 'uniform',
960 'fields' => array(
961 array(
962 'key' => 'enable_fees_deducting',
963 'type' => 'toggle_switch',
964 'label' => __( 'Deduct Fees', 'tutor' ),
965 'label_title' => '',
966 'default' => 'off',
967 'desc' => __( 'Fees are charged from the entire sales amount. The remaining amount will be divided among admin and instructors.', 'tutor' ),
968 'toggle_fields' => 'fees_name,fee_amount_type',
969 ),
970 array(
971 'key' => 'fees_name',
972 'type' => 'textarea',
973 'label' => __( 'Fee Description', 'tutor' ),
974 'placeholder' => __( 'Fee Description', 'tutor' ),
975 'desc' => __( 'Set a description for the fee that you are deducting. Make sure to give a reasonable explanation to maintain transparency with your site’s instructors.', 'tutor' ),
976 'maxlength' => 200,
977 'rows' => 5,
978 'default' => 'Maintenance Fees',
979 ),
980 array(
981 'key' => 'fee_amount_type',
982 'type' => 'group_fields',
983 'label' => __( 'Fee Amount & Type', 'tutor' ),
984 'desc' => __( 'Select the fee type and add fee amount/percentage', 'tutor' ),
985 'group_fields' => array(
986 'fees_type' => array(
987 'type' => 'select',
988 'default' => 'fixed',
989 'options' => array(
990 'percent' => __( 'Percent', 'tutor' ),
991 'fixed' => __( 'Fixed', 'tutor' ),
992 ),
993 ),
994 'fees_amount' => array(
995 'type' => 'number',
996 'default' => '0',
997 ),
998 ),
999 ),
1000 ),
1001 ),
1002 array(
1003 'label' => __( 'Withdraw', 'tutor' ),
1004 'slug' => 'withdraw',
1005 'block_type' => 'uniform',
1006 'fields' => array(
1007 array(
1008 'key' => 'min_withdraw_amount',
1009 'type' => 'number',
1010 'label' => __( 'Minimum Withdrawal Amount', 'tutor' ),
1011 'default' => '80',
1012 'desc' => __( 'Instructors should earn equal or above this amount to make a withdraw request.', 'tutor' ),
1013 ),
1014 array(
1015 'key' => 'minimum_days_for_balance_to_be_available',
1016 'type' => 'number',
1017 'number_type' => 'integer',
1018 'label' => __( 'Minimum Days Before Balance is Available', 'tutor' ),
1019 'default' => '7',
1020 'min' => 1,
1021 'desc' => __( 'Any income has to remain this many days in the platform before it is available for withdrawal.', 'tutor' ),
1022 ),
1023 array(
1024 'key' => 'tutor_withdrawal_methods',
1025 'type' => 'checkbox_horizontal',
1026 'label' => __( 'Enable Withdraw Method', 'tutor' ),
1027 'default' => array( 'bank_transfer_withdraw' ),
1028 'options' => $methods_array,
1029 'desc' => __( 'Set how you would like to withdraw money from the website.', 'tutor' ),
1030 ),
1031 array(
1032 'key' => 'tutor_bank_transfer_withdraw_instruction',
1033 'type' => 'textarea',
1034 'label' => __( 'Bank Instructions', 'tutor' ),
1035 'default' => __( 'Write the up to date bank informations of your instructor here.', 'tutor' ),
1036 'desc' => __( 'Write bank instructions for the instructors to conduct withdrawals.', 'tutor' ),
1037 ),
1038 ),
1039 ),
1040 ),
1041 ),
1042 'design' => array(
1043 'label' => __( 'Design', 'tutor' ),
1044 'slug' => 'design',
1045 'desc' => __( 'Design Settings', 'tutor' ),
1046 'template' => 'design',
1047 'icon' => 'tutor-icon-color-palette',
1048 'blocks' => array(
1049 'block_course' => array(
1050 'label' => __( 'Course', 'tutor' ),
1051 'slug' => 'course',
1052 'block_type' => 'uniform',
1053 'fields' => array(
1054 array(
1055 'key' => 'courses_col_per_row',
1056 'type' => 'radio_horizontal',
1057 'label' => __( 'Column Per Row', 'tutor' ),
1058 'default' => '3',
1059 'options' => array(
1060 '1' => 'One',
1061 '2' => 'Two',
1062 '3' => 'Three',
1063 '4' => 'Four',
1064 ),
1065 'desc' => __( 'Define how many columns you want to use to display courses.', 'tutor' ),
1066 ),
1067 array(
1068 'key' => 'course_archive_filter',
1069 'type' => 'toggle_switch',
1070 'label' => __( 'Course Filter', 'tutor' ),
1071 'label_title' => '',
1072 'default' => 'off',
1073 'desc' => __( 'Show sorting and filtering options on course archive page', 'tutor' ),
1074 ),
1075 array(
1076 'key' => 'courses_per_page',
1077 'type' => 'number',
1078 'number_type' => 'integer',
1079 'label' => __( 'Courses Per Page', 'tutor' ),
1080 'default' => '12',
1081 'desc' => __( 'Set the number of courses to display per page on the Course List page.', 'tutor' ),
1082 ),
1083 array(
1084 'key' => 'supported_course_filters',
1085 'type' => 'checkbox_horizontal',
1086 'label' => __( 'Preferred Course Filters', 'tutor' ),
1087 'default' => array( 'search', 'category' ),
1088 'options' => array(
1089 'search' => __( 'Keyword Search', 'tutor' ),
1090 'category' => __( 'Category', 'tutor' ),
1091 'tag' => __( 'Tag', 'tutor' ),
1092 'difficulty_level' => __( 'Difficulty Level', 'tutor' ),
1093 'price_type' => __( 'Price Type', 'tutor' ),
1094 ),
1095 'desc' => __( 'Choose preferred filter options you\'d like to show on the course archive page.', 'tutor' ),
1096 ),
1097 array(
1098 'key' => 'course_archive_filter_sorting',
1099 'type' => 'toggle_switch',
1100 'label' => __( 'Course Sorting', 'tutor' ),
1101 'label_title' => '',
1102 'default' => 'on',
1103 'desc' => __( 'If enabled, the courses will be sortable by Course Name or Creation Date in either Ascending or Descending order', 'tutor' ),
1104 ),
1105 ),
1106 ),
1107 'layout' => array(
1108 'label' => __( 'Layout', 'tutor' ),
1109 'slug' => 'layout',
1110 'block_type' => 'uniform',
1111 'fields' => array(
1112 array(
1113 'key' => 'instructor_list_layout',
1114 'type' => 'group_radio',
1115 'label' => __( 'Instructor List Layout', 'tutor' ),
1116 'desc' => __( 'Choose a layout for the list of instructors inside a course page. You can change this at any time.', 'tutor' ),
1117 'default' => 'portrait',
1118 'group_options' => array(
1119 'vertical' => array(
1120 'default' => array(
1121 'title' => 'Portrait',
1122 'image' => 'instructor-layout/instructor-portrait.svg',
1123 ),
1124 'cover' => array(
1125 'title' => 'Cover',
1126 'image' => 'instructor-layout/instructor-cover.svg',
1127 ),
1128 'minimal' => array(
1129 'title' => 'Minimal',
1130 'image' => 'instructor-layout/instructor-minimal.svg',
1131 ),
1132 ),
1133 'horizontal' => array(
1134 'portrait-horizontal' => array(
1135 'title' => 'Portrait Horizontal',
1136 'image' => 'instructor-layout/instructor-horizontal-portrait.svg',
1137 ),
1138 'minimal-horizontal' => array(
1139 'title' => 'Minimal Horizontal',
1140 'image' => 'instructor-layout/instructor-horizontal-minimal.svg',
1141 ),
1142 ),
1143 ),
1144 ),
1145 array(
1146 'key' => 'public_profile_layout',
1147 'type' => 'group_radio_full_3',
1148 'label' => __( 'Instructor Public Profile Layout', 'tutor' ),
1149 'desc' => __( 'Choose a layout design for a instructor’s public profile', 'tutor' ),
1150 'default' => 'pp-rectangle',
1151 'group_options' => array(
1152 'private' => array(
1153 'title' => 'Private',
1154 'image' => 'profile-layout/profile-private.svg',
1155 ),
1156 'pp-circle' => array(
1157 'title' => 'Modern',
1158 'image' => 'profile-layout/profile-modern.svg',
1159 ),
1160 'no-cp' => array(
1161 'title' => 'Minimal',
1162 'image' => 'profile-layout/profile-minimal.svg',
1163 ),
1164 'pp-rectangle' => array(
1165 'title' => 'Classic',
1166 'image' => 'profile-layout/profile-classic.svg',
1167 ),
1168 ),
1169 ),
1170 array(
1171 'key' => 'student_public_profile_layout',
1172 'type' => 'group_radio_full_3',
1173 'label' => __( 'Student Public Profile Layout', 'tutor' ),
1174 'desc' => __( 'Choose a layout design for a student’s public profile', 'tutor' ),
1175 'default' => 'pp-rectangle',
1176 'group_options' => array(
1177 'private' => array(
1178 'title' => 'Private',
1179 'image' => 'profile-layout/profile-private.svg',
1180 ),
1181 'pp-circle' => array(
1182 'title' => 'Modern',
1183 'image' => 'profile-layout/profile-modern.svg',
1184 ),
1185 'no-cp' => array(
1186 'title' => 'Minimal',
1187 'image' => 'profile-layout/profile-minimal.svg',
1188 ),
1189 'pp-rectangle' => array(
1190 'title' => 'Classic',
1191 'image' => 'profile-layout/profile-classic.svg',
1192 ),
1193 ),
1194 ),
1195 ),
1196 ),
1197 'course-details' => array(
1198 'label' => __( 'Course Details', 'tutor' ),
1199 'slug' => 'course-details',
1200 'block_type' => 'isolate',
1201 'fields' => array(
1202 array(
1203 'key' => 'course_details_adjustments',
1204 'type' => 'checkgroup',
1205 'label' => __( 'Page Features', 'tutor' ),
1206 'desc' => __( 'You can keep the following features active or inactive as per the need of your business model', 'tutor' ),
1207 'group_options' => array(
1208 array(
1209 'key' => 'display_course_instructors',
1210 'type' => 'toggle_single',
1211 'label' => __( 'Instructor Info', 'tutor' ),
1212 'default' => 'on',
1213 'desc' => __( 'Toggle to show instructor info', 'tutor' ),
1214 ),
1215 array(
1216 'key' => 'enable_q_and_a_on_course',
1217 'type' => 'toggle_single',
1218 'label' => __( 'Q&A', 'tutor' ),
1219 'default' => 'on',
1220 'desc' => __( 'Enable to add a Q&A section', 'tutor' ),
1221 ),
1222 array(
1223 'key' => 'enable_course_author',
1224 'type' => 'toggle_single',
1225 'label' => __( 'Author', 'tutor' ),
1226 'label_title' => __( 'Enable', 'tutor' ),
1227 'default' => 'off',
1228 'desc' => __( 'Enable to show course author name', 'tutor' ),
1229 ),
1230 array(
1231 'key' => 'enable_course_level',
1232 'type' => 'toggle_single',
1233 'label' => __( 'Level', 'tutor' ),
1234 'label_title' => __( 'Enable', 'tutor' ),
1235 'default' => 'on',
1236 'desc' => __( 'Enable to show course level', 'tutor' ),
1237 ),
1238 array(
1239 'key' => 'enable_course_share',
1240 'type' => 'toggle_single',
1241 'label' => __( 'Social Share', 'tutor' ),
1242 'label_title' => __( 'Enable', 'tutor' ),
1243 'default' => 'on',
1244 'desc' => __( 'Toggle to enable course social share', 'tutor' ),
1245 ),
1246 array(
1247 'key' => 'enable_course_duration',
1248 'type' => 'toggle_single',
1249 'label' => __( 'Duration', 'tutor' ),
1250 'label_title' => __( 'Disable', 'tutor' ),
1251 'default' => 'on',
1252 'desc' => __( 'Enable to show course duration', 'tutor' ),
1253 ),
1254 array(
1255 'key' => 'enable_course_total_enrolled',
1256 'type' => 'toggle_single',
1257 'label' => __( 'Total Enrolled', 'tutor' ),
1258 'label_title' => __( 'Enable', 'tutor' ),
1259 'default' => 'on',
1260 'desc' => __( 'Enable to show total enrolled students', 'tutor' ),
1261 ),
1262 array(
1263 'key' => 'enable_course_update_date',
1264 'type' => 'toggle_single',
1265 'label' => __( 'Update Date', 'tutor' ),
1266 'label_title' => __( 'Enable', 'tutor' ),
1267 'default' => 'on',
1268 'desc' => __( 'Enable to show course update information', 'tutor' ),
1269 ),
1270 array(
1271 'key' => 'enable_course_progress_bar',
1272 'type' => 'toggle_single',
1273 'label' => __( 'Progress Bar', 'tutor' ),
1274 'label_title' => __( 'Enable', 'tutor' ),
1275 'default' => 'on',
1276 'desc' => __( 'Enable to show course progress for Students', 'tutor' ),
1277 ),
1278 array(
1279 'key' => 'enable_course_material',
1280 'type' => 'toggle_single',
1281 'label' => __( 'Material', 'tutor' ),
1282 'label_title' => __( 'Enable', 'tutor' ),
1283 'default' => 'on',
1284 'desc' => __( 'Enable to show course materials', 'tutor' ),
1285 ),
1286 array(
1287 'key' => 'enable_course_about',
1288 'type' => 'toggle_single',
1289 'label' => __( 'About', 'tutor' ),
1290 'label_title' => __( 'Enable', 'tutor' ),
1291 'default' => 'on',
1292 'desc' => __( 'Enable to show course about section', 'tutor' ),
1293 ),
1294 array(
1295 'key' => 'enable_course_description',
1296 'type' => 'toggle_single',
1297 'label' => __( 'Description', 'tutor' ),
1298 'label_title' => __( 'Enable', 'tutor' ),
1299 'default' => 'on',
1300 'desc' => __( 'Enable to show course description', 'tutor' ),
1301 ),
1302 array(
1303 'key' => 'enable_course_benefits',
1304 'type' => 'toggle_single',
1305 'label' => __( 'Benefits', 'tutor' ),
1306 'label_title' => __( 'Enable', 'tutor' ),
1307 'default' => 'on',
1308 'desc' => __( 'Enable to show course benefits section', 'tutor' ),
1309 ),
1310 array(
1311 'key' => 'enable_course_requirements',
1312 'type' => 'toggle_single',
1313 'label' => __( 'Requirements', 'tutor' ),
1314 'label_title' => __( 'Enable', 'tutor' ),
1315 'default' => 'on',
1316 'desc' => __( 'Enable to show courses requirements setion', 'tutor' ),
1317 ),
1318 array(
1319 'key' => 'enable_course_target_audience',
1320 'type' => 'toggle_single',
1321 'label' => __( 'Target Audience', 'tutor' ),
1322 'label_title' => __( 'Disable', 'tutor' ),
1323 'default' => 'on',
1324 'desc' => __( 'Enable to show course target audience section', 'tutor' ),
1325 ),
1326 array(
1327 'key' => 'enable_course_announcements',
1328 'type' => 'toggle_single',
1329 'label' => __( 'Announcements', 'tutor' ),
1330 'label_title' => __( 'Enable', 'tutor' ),
1331 'default' => 'on',
1332 'desc' => __( 'Enable to show course announcements section', 'tutor' ),
1333 ),
1334 array(
1335 'key' => 'enable_course_review',
1336 'type' => 'toggle_single',
1337 'label' => __( 'Review', 'tutor' ),
1338 'label_title' => __( 'Enable', 'tutor' ),
1339 'default' => 'on',
1340 'desc' => __( 'Enable to show course review section', 'tutor' ),
1341 ),
1342 ),
1343 ),
1344 ),
1345 ),
1346 'colors' => array(
1347 'label' => __( 'Colors', 'tutor' ),
1348 'slug' => 'colors',
1349 'block_type' => 'color_picker',
1350 'fields_group' => array(
1351 array(
1352 'key' => 'color_preset_type',
1353 'type' => 'color_preset',
1354 'label' => __( 'Preset Colors', 'tutor' ),
1355 'desc' => __( 'These colors will be used throughout your website. Choose between these presets or create your own custom palette.', 'tutor' ),
1356 'default' => 'default',
1357 'fields' => array(
1358 /* First 4 preset_name should be same as color_fields */
1359 array(
1360 'key' => 'default',
1361 'label' => 'Default',
1362 'colors' => array(
1363 array(
1364 'slug' => 'tutor_primary_color',
1365 'preset_name' => 'primary',
1366 'value' => '#3E64DE',
1367 ),
1368 array(
1369 'slug' => 'tutor_primary_hover_color',
1370 'preset_name' => 'hover',
1371 'value' => '#395BCA',
1372 ),
1373 array(
1374 'slug' => 'tutor_text_color',
1375 'preset_name' => 'text',
1376 'value' => '#212327',
1377 ),
1378 array(
1379 'slug' => 'tutor_gray_color',
1380 'preset_name' => 'gray',
1381 'value' => '#E3E5EB',
1382 ),
1383 array(
1384 'slug' => 'tutor_border_color',
1385 'preset_name' => 'border',
1386 'value' => '#CDCFD5',
1387 ),
1388 ),
1389 ),
1390 array(
1391 'key' => 'landscape',
1392 'label' => 'Landscape',
1393 'colors' => array(
1394 array(
1395 'slug' => 'tutor_primary_color',
1396 'preset_name' => 'primary',
1397 'value' => '#239371',
1398 ),
1399 array(
1400 'slug' => 'tutor_primary_hover_color',
1401 'preset_name' => 'hover',
1402 'value' => '#117D5D',
1403 ),
1404 array(
1405 'slug' => 'tutor_text_color',
1406 'preset_name' => 'text',
1407 'value' => '#212327',
1408 ),
1409 array(
1410 'slug' => 'tutor_gray_color',
1411 'preset_name' => 'gray',
1412 'value' => '#E3E5EB',
1413 ),
1414 array(
1415 'slug' => 'tutor_border_color',
1416 'preset_name' => 'border',
1417 'value' => '#CDCFD5',
1418 ),
1419 ),
1420 ),
1421 array(
1422 'key' => 'ocean',
1423 'label' => 'Ocean',
1424 'colors' => array(
1425 array(
1426 'slug' => 'tutor_primary_color',
1427 'preset_name' => 'primary',
1428 'value' => '#5A18C2',
1429 ),
1430 array(
1431 'slug' => 'tutor_primary_hover_color',
1432 'preset_name' => 'hover',
1433 'value' => '#3F02A0',
1434 ),
1435 array(
1436 'slug' => 'tutor_text_color',
1437 'preset_name' => 'text',
1438 'value' => '#212327',
1439 ),
1440 array(
1441 'slug' => 'tutor_gray_color',
1442 'preset_name' => 'gray',
1443 'value' => '#E3E5EB',
1444 ),
1445 array(
1446 'slug' => 'tutor_border_color',
1447 'preset_name' => 'border',
1448 'value' => '#CDCFD5',
1449 ),
1450 ),
1451 ),
1452 array(
1453 'key' => 'custom',
1454 'label' => 'Custom',
1455 'colors' => array(
1456 array(
1457 'slug' => 'tutor_primary_color',
1458 'preset_name' => 'primary',
1459 'value' => '#3E64DE',
1460 ),
1461 array(
1462 'slug' => 'tutor_primary_hover_color',
1463 'preset_name' => 'hover',
1464 'value' => '#28408E',
1465 ),
1466 array(
1467 'slug' => 'tutor_text_color',
1468 'preset_name' => 'text',
1469 'value' => '#1A1B1E',
1470 ),
1471 array(
1472 'slug' => 'tutor_gray_color',
1473 'preset_name' => 'gray',
1474 'value' => '#E3E5EB',
1475 ),
1476 ),
1477 ),
1478 ),
1479 ),
1480 array(
1481 'key' => 'tutor_color_presets',
1482 'type' => 'color_fields',
1483 'label' => __( 'Preset Colors', 'tutor' ),
1484 'fields' => array(
1485 array(
1486 'key' => 'tutor_primary_color',
1487 'type' => 'color_field',
1488 'preset_name' => 'primary',
1489 'preset_exist' => true,
1490 'label' => __( 'Primary Color', 'tutor' ),
1491 'default' => '#3E64DE',
1492 'desc' => __( 'Choose a primary color', 'tutor' ),
1493 ),
1494 array(
1495 'key' => 'tutor_primary_hover_color',
1496 'type' => 'color_field',
1497 'preset_name' => 'hover',
1498 'preset_exist' => true,
1499 'label' => __( 'Primary Hover Color', 'tutor' ),
1500 'default' => '#395BCA',
1501 'desc' => __( 'Choose a primary hover color', 'tutor' ),
1502 ),
1503 array(
1504 'key' => 'tutor_text_color',
1505 'type' => 'color_field',
1506 'preset_name' => 'text',
1507 'preset_exist' => true,
1508 'label' => __( 'Text Color', 'tutor' ),
1509 'default' => '#212327',
1510 'desc' => __( 'Choose a text color for your website', 'tutor' ),
1511 ),
1512 array(
1513 'key' => 'tutor_gray_color',
1514 'type' => 'color_field',
1515 'preset_name' => 'gray',
1516 'preset_exist' => false,
1517 'label' => __( 'Gray', 'tutor' ),
1518 'default' => '#E3E5EB',
1519 'desc' => __( 'Choose a color for elements like table, card etc', 'tutor' ),
1520 ),
1521 array(
1522 'key' => 'tutor_border_color',
1523 'type' => 'color_field',
1524 'preset_name' => 'border',
1525 'preset_exist' => false,
1526 'label' => __( 'Border', 'tutor' ),
1527 'default' => '#CDCFD5',
1528 'desc' => __( 'Choose a border color for your website', 'tutor' ),
1529 ),
1530 ),
1531 ),
1532 ),
1533 ),
1534 'video_player' => array(
1535 'label' => __( 'Video Player', 'tutor' ),
1536 'slug' => 'video_player',
1537 'block_type' => 'uniform',
1538 'fields' => array(
1539 array(
1540 'key' => 'disable_default_player_youtube',
1541 'type' => 'toggle_switch',
1542 'label' => __( 'Use Tutor Player for YouTube', 'tutor' ),
1543 'label_title' => '',
1544 'default' => 'off',
1545 'desc' => __( 'Enable this option to use Tutor LMS video player for YouTube.', 'tutor' ),
1546 ),
1547 array(
1548 'key' => 'disable_default_player_vimeo',
1549 'type' => 'toggle_switch',
1550 'label' => __( 'Use Tutor Player for Vimeo', 'tutor' ),
1551 'label_title' => '',
1552 'default' => 'off',
1553 'desc' => __( 'Enable this option to use Tutor LMS video player for Vimeo.', 'tutor' ),
1554 ),
1555 ),
1556 ),
1557 ),
1558 ),
1559 'advanced' => array(
1560 'label' => __( 'Advanced', 'tutor' ),
1561 'slug' => 'advanced',
1562 'desc' => __( 'Advanced Settings', 'tutor' ),
1563 'template' => 'basic',
1564 'icon' => 'tutor-icon-filter',
1565 'blocks' => array(
1566 array(
1567 'label' => __( 'Course', 'tutor' ),
1568 'slug' => 'options',
1569 'block_type' => 'uniform',
1570 'fields' => array(
1571 array(
1572 'key' => 'enable_gutenberg_course_edit',
1573 'type' => 'toggle_switch',
1574 'label' => __( 'Gutenberg Editor', 'tutor' ),
1575 'default' => 'off',
1576 'desc' => __( 'Enable this to create courses using the Gutenberg Editor.', 'tutor' ),
1577 ),
1578 array(
1579 'key' => 'hide_course_from_shop_page',
1580 'type' => 'toggle_switch',
1581 'label' => __( 'Hide Course Products on Shop Page', 'tutor' ),
1582 'default' => 'off',
1583 'desc' => __( 'Enable to hide course products on shop page.', 'tutor' ),
1584 ),
1585 array(
1586 'key' => 'course_archive_page',
1587 'type' => 'select',
1588 'label' => __( 'Course Archive Page', 'tutor' ),
1589 'default' => $course_archive_page_id->ID ?? '0',
1590 'options' => $pages,
1591 'desc' => __( 'This page will be used to list all the published courses.', 'tutor' ),
1592 ),
1593 array(
1594 'key' => 'instructor_register_page',
1595 'type' => 'select',
1596 'label' => __( 'Instructor Registration Page', 'tutor' ),
1597 'default' => '0',
1598 'options' => $pages,
1599 'desc' => __( 'Choose the page for instructor registration.', 'tutor' ),
1600 ),
1601 array(
1602 'key' => 'student_register_page',
1603 'type' => 'select',
1604 'label' => __( 'Student Registration Page', 'tutor' ),
1605 'default' => '0',
1606 'options' => $pages,
1607 'desc' => __( 'Choose the page for student registration.', 'tutor' ),
1608 ),
1609 array(
1610 'key' => 'lesson_video_duration_youtube_api_key',
1611 'type' => 'text',
1612 'label' => __( 'Youtube API Key', 'tutor' ),
1613 'default' => '',
1614 'desc' => __( 'Insert the YouTube API key to host live videos using YouTube.', 'tutor' ),
1615 ),
1616 ),
1617 ),
1618 array(
1619 'label' => __( 'Base Permalink', 'tutor' ),
1620 'slug' => 'base_permalink',
1621 'block_type' => 'uniform',
1622 'fields' => array(
1623 array(
1624 'key' => 'course_permalink_base',
1625 'type' => 'text',
1626 'label' => __( 'Course Permalink', 'tutor' ),
1627 'default' => 'courses',
1628 'desc' => $course_url,
1629 ),
1630 array(
1631 'key' => 'lesson_permalink_base',
1632 'type' => 'text',
1633 'label' => __( 'Lesson Permalink', 'tutor' ),
1634 'default' => 'lessons',
1635 'desc' => $lesson_url,
1636 ),
1637 array(
1638 'key' => 'quiz_permalink_base',
1639 'type' => 'text',
1640 'label' => __( 'Quiz Permalink', 'tutor' ),
1641 'default' => 'quizzes',
1642 'desc' => $quiz_url,
1643 ),
1644 ),
1645 ),
1646 array(
1647 'label' => __( 'Options', 'tutor' ),
1648 'slug' => 'options',
1649 'block_type' => 'uniform',
1650 'fields' => array(
1651 array(
1652 'key' => 'enable_profile_completion',
1653 'type' => 'toggle_switch',
1654 'label' => __( 'Profile Completion', 'tutor' ),
1655 'label_title' => '',
1656 'default' => 'off',
1657 'desc' => __( 'Enabling this feature will show a notification bar to students and instructors to complete their profile information', 'tutor' ),
1658 ),
1659 array(
1660 'key' => 'enable_tutor_native_login',
1661 'type' => 'toggle_switch',
1662 'label' => __( 'Enable Tutor Login', 'tutor' ),
1663 'label_title' => '',
1664 'default' => 'on',
1665 'desc' => __( 'Enable to use the tutor login modal instead of the default WordPress login page', 'tutor' ),
1666 ),
1667 array(
1668 'key' => 'delete_on_uninstall',
1669 'type' => 'toggle_switch',
1670 'label' => __( 'Erase upon uninstallation', 'tutor' ),
1671 'label_title' => '',
1672 'default' => 'off',
1673 'desc' => __( 'Delete all data during uninstallation', 'tutor' ),
1674 ),
1675 array(
1676 'key' => 'enable_tutor_maintenance_mode',
1677 'type' => 'toggle_switch',
1678 'label' => __( 'Maintenance Mode', 'tutor' ),
1679 'label_title' => '',
1680 'default' => 'off',
1681 'desc' => __( 'Enabling the maintenance mode allows you to display a custom message on the frontend. During this time, visitors can not access the site content. But the wp-admin dashboard will remain accessible.', 'tutor' ),
1682 ),
1683 ),
1684 ),
1685 ),
1686 ),
1687 );
1688
1689 $attrs = apply_filters( 'tutor/options/extend/attr', apply_filters( 'tutor/options/attr', $attr ) );
1690
1691 // Get the active tab.
1692 $tab_page = tutor_utils()->array_get( 'tab_page', $_REQUEST, 'general' );
1693 $tab_data = null;
1694 $template = null;
1695
1696 foreach ( $attrs as $key => $section ) {
1697 if ( $tab_page == $key ) {
1698 if ( isset( $section['template_path'] ) && $section['template_path'] ) {
1699 $template = $section['template_path'];
1700 $tab_data = $section;
1701 }
1702 break;
1703 }
1704 }
1705
1706 // Store in runtime cache.
1707 $this->setting_fields = array(
1708 'option_fields' => $attrs,
1709 'active_tab' => $tab_page,
1710 'active_tab_data' => $tab_data,
1711 'template_path' => $template,
1712 );
1713
1714 return $this->setting_fields;
1715 }
1716
1717 /**
1718 * Generate field
1719 *
1720 * @since 2.0.0
1721 *
1722 * @param array $field field array.
1723 *
1724 * @return void
1725 *
1726 * Generate Option Field
1727 */
1728 public function generate_field( $field = array() ) {
1729 ob_start();
1730 if ( isset( $field['type'] ) ) {
1731 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1732 }
1733 echo ob_get_clean();//phpcs:ignore
1734 }
1735
1736 /**
1737 * Include field type template & return buffered
1738 * string data.
1739 *
1740 * @since 2.0.0
1741 *
1742 * @param array $field field.
1743 *
1744 * @return string
1745 */
1746 public function field_type( $field = array() ) {
1747 ob_start();
1748 if ( isset( $field['type'] ) ) {
1749 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1750 }
1751 return ob_get_clean();
1752 }
1753
1754 /**
1755 * Include Option blocks template & return
1756 * buffered string data.
1757 *
1758 * @since 2.0.0
1759 *
1760 * @param array $blocks blocks.
1761 *
1762 * @return string
1763 */
1764 public function blocks( $blocks = array() ) {
1765 ob_start();
1766 include tutor()->path . 'views/options/option_blocks.php';
1767 return ob_get_clean();
1768 }
1769
1770 /**
1771 * Include options template & returns
1772 * buffered string data.
1773 *
1774 * @since 2.0.0
1775 *
1776 * @param array $section section.
1777 *
1778 * @return string
1779 */
1780 public function template( $section = array() ) {
1781 ob_start();
1782 $blocks = $section['blocks'];
1783 if ( isset( $section['template'] ) ) {
1784 include tutor()->path . "views/options/template/{$section['template']}.php";
1785 }
1786 return ob_get_clean();
1787 }
1788
1789 /**
1790 * Load template inside template dirctory
1791 *
1792 * @since 2.0.0
1793 *
1794 * @param mixed $template_slug template slug.
1795 * @param mixed $section section.
1796 *
1797 * @return string
1798 */
1799 public function view_template( $template_slug, $section = array() ) {
1800 ob_start();
1801 if ( isset( $template_slug ) ) {
1802 require tutor()->path . "views/options/template/{$template_slug}";
1803 }
1804 return ob_get_clean();
1805 }
1806 }
1807