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