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