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