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