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