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