PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 4.0.0
Tutor LMS – eLearning and online course solution v4.0.0
4.0.0 3.9.15 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 1 day ago Admin.php 1 day ago Ajax.php 1 day ago Announcements.php 1 day ago Assets.php 1 day ago Backend_Page_Trait.php 1 year ago BaseController.php 1 year ago Config.php 1 day ago Container.php 11 months ago Course.php 1 day ago Course_Embed.php 3 years ago Course_Filter.php 1 day ago Course_List.php 1 day ago Course_Settings_Tabs.php 1 day ago Course_Widget.php 1 year ago Custom_Validation.php 1 day ago Dashboard.php 1 day ago Earnings.php 9 months ago FormHandler.php 1 day ago Frontend.php 1 day ago Gutenberg.php 1 year ago Icon.php 1 day ago Input.php 1 day ago Instructor.php 1 day ago Instructors_List.php 1 day ago Lesson.php 1 day ago Options_V2.php 1 day ago Permalink.php 1 day ago Post_types.php 2 days ago Private_Course_Access.php 1 day ago Q_And_A.php 1 day ago Question_Answers_List.php 11 months ago Quiz.php 1 day ago QuizBuilder.php 1 day ago Quiz_Attempts_List.php 1 day ago RestAPI.php 2 years ago Reviews.php 1 day ago Rewrite_Rules.php 2 years ago SampleCourse.php 1 day ago Shortcode.php 1 day ago Singleton.php 1 year ago Student.php 1 day ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 1 day ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 4 weeks ago Tutor.php 1 day ago TutorEDD.php 1 day ago Tutor_Base.php 2 years ago Tutor_Setup.php 1 day ago Upgrader.php 1 day ago User.php 1 day ago UserPreference.php 1 day ago Utils.php 1 day ago Video_Stream.php 3 years ago WhatsNew.php 10 months ago Withdraw.php 1 day ago Withdraw_Requests_List.php 11 months ago WooCommerce.php 1 day ago
Options_V2.php
1991 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 defined( 'ABSPATH' ) || exit;
14
15 use TUTOR\Input;
16 use Tutor\Traits\JsonResponse;
17 use Tutor\Ecommerce\OptionKeys;
18 use TUTOR\User;
19
20 /**
21 * Contains all the settings options
22 *
23 * @since 2.0.0
24 */
25 class Options_V2 {
26
27 use JsonResponse;
28
29 /**
30 * Learning modes.
31 *
32 * @since 4.0.0
33 */
34 const LEARNING_MODE_MODERN = 'modern';
35 const LEARNING_MODE_KIDS = 'kids';
36 const LEARNING_MODE_LEGACY = 'legacy';
37
38 /**
39 * Default theme.
40 *
41 * @since 4.0.0
42 */
43 const DEFAULT_THEME_LIGHT = 'light';
44 const DEFAULT_THEME_DARK = 'dark';
45 const DEFAULT_THEME_SYSTEM = 'system';
46
47 /**
48 * Brand color.
49 *
50 * @since 4.0.0
51 */
52 const DEFAULT_BRAND_COLOR = '#3e64de';
53
54 /**
55 * Undocumented variable
56 *
57 * @since 2.0.0
58 *
59 * @var array $options
60 */
61 private $options;
62
63 /**
64 * Settings fields
65 *
66 * @since 2.0.0
67 *
68 * @var mixed $setting_fields
69 */
70 private $setting_fields;
71
72 /**
73 * Register hooks
74 *
75 * @since 2.0.0
76 *
77 * @param boolean $register_hook should register hook or not.
78 *
79 * @return void
80 */
81 public function __construct( $register_hook = true ) {
82 if ( ! $register_hook ) {
83 return;
84 }
85
86 // Saving option.
87 add_action( 'tutor_option_save_before', array( $this, 'validate_options' ) );
88 add_action( 'wp_ajax_tutor_option_save', array( $this, 'tutor_option_save' ) );
89 add_action( 'wp_ajax_tutor_option_default_save', array( $this, 'tutor_option_default_save' ) );
90 add_action( 'wp_ajax_tutor_option_search', array( $this, 'tutor_option_search' ) );
91 add_action( 'wp_ajax_tutor_export_settings', array( $this, 'tutor_export_settings' ) );
92 add_action( 'wp_ajax_tutor_export_single_settings', array( $this, 'tutor_export_single_settings' ) );
93 add_action( 'wp_ajax_tutor_delete_single_settings', array( $this, 'tutor_delete_single_settings' ) );
94 add_action( 'wp_ajax_tutor_import_settings', array( $this, 'tutor_import_settings' ) );
95 add_action( 'wp_ajax_tutor_apply_settings', array( $this, 'tutor_apply_settings' ) );
96 add_action( 'wp_ajax_load_saved_data', array( $this, 'load_saved_data' ) );
97 add_action( 'wp_ajax_reset_settings_data', array( $this, 'reset_settings_data' ) );
98 add_action( 'tutor_option_monetize_by_changed', array( $this, 'handle_changed_monetization_option' ) );
99 }
100
101 /**
102 * Get settings value
103 *
104 * @since 2.0.0
105 *
106 * @param mixed $key option key.
107 * @param mixed $default default value.
108 *
109 * @return mixed
110 */
111 private function get( $key = null, $default = false ) {
112
113 if ( ! $this->options ) {
114 // Get if already not prepared.
115 $this->options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
116 }
117
118 $option = $this->options;
119
120 if ( empty( $option ) || ! is_array( $option ) ) {
121 return $default;
122 }
123
124 if ( ! $key ) {
125 return $option;
126 }
127
128 if ( array_key_exists( $key, $option ) ) {
129 return apply_filters( $key, $option[ $key ] );
130 }
131
132 // Access array value via dot notation, such as option->get('value.subvalue').
133 if ( strpos( $key, '.' ) ) {
134 $option_key_array = explode( '.', $key );
135 $new_option = $option;
136 foreach ( $option_key_array as $dot_key ) {
137 if ( isset( $new_option[ $dot_key ] ) ) {
138 $new_option = $new_option[ $dot_key ];
139 } else {
140 return $default;
141 }
142 }
143
144 return apply_filters( $key, $new_option );
145 }
146
147 return $default;
148 }
149
150 /**
151 * Get only list of options.
152 *
153 * @since 3.0.0
154 *
155 * @param array $only only options.
156 *
157 * @return array
158 */
159 public static function get_only( $only = array() ) {
160 $settings = get_option( 'tutor_option', array() );
161 return array_intersect_key( $settings, array_flip( $only ) );
162 }
163
164 /**
165 * Prepare settings search item.
166 *
167 * @since 3.0.0
168 *
169 * @param array $section section item.
170 * @param array $block block item.
171 * @param array $field field item.
172 *
173 * @return array prepared searchable field item.
174 */
175 private function prepare_search_item( $section, $block, $field ) {
176 $field['section_label'] = isset( $section['label'] ) ? $section['label'] : '';
177 $field['section_slug'] = isset( $section['slug'] ) ? $section['slug'] : '';
178 $field['block_label'] = isset( $block['label'] ) ? $block['label'] : '';
179
180 return $field;
181 }
182
183 /**
184 * Function to get all fields for search tutor_option_search
185 *
186 * @since 2.0.0
187 *
188 * @return void send wp_json response
189 */
190 public function tutor_option_search() {
191 tutor_utils()->checking_nonce();
192
193 if ( ! User::is_admin() ) {
194 wp_send_json_error( tutor_utils()->error_message() );
195 }
196
197 $data_array = array();
198 foreach ( $this->get_setting_fields() as $sections ) {
199 if ( is_array( $sections ) && ! empty( $sections ) ) {
200 foreach ( Input::sanitize_array( $sections ) as $section ) {
201 foreach ( $section['blocks'] as $blocks ) {
202 if ( isset( $blocks['fields'] ) && ! empty( $blocks['fields'] ) ) {
203 foreach ( $blocks['fields'] as $fields ) {
204 $data_array['fields'][] = $this->prepare_search_item( $section, $blocks, $fields );
205 }
206 }
207 }
208
209 /**
210 * Submenu item search.
211 *
212 * @since 3.0.0
213 */
214 if ( isset( $section['submenu'] ) && is_array( $section['submenu'] ) ) {
215 foreach ( Input::sanitize_array( $section['submenu'] ) as $submenu_section ) {
216 foreach ( $submenu_section['blocks'] as $block ) {
217 if ( isset( $block['fields'] ) && ! empty( $block['fields'] ) ) {
218 foreach ( $block['fields'] as $fields ) {
219 $data_array['fields'][] = $this->prepare_search_item( $submenu_section, $block, $fields );
220 }
221 }
222 }
223 }
224 }
225 }
226 }
227 }
228
229 wp_send_json_success( $data_array );
230 }
231
232 /**
233 * Export settings
234 *
235 * @since 2.0.0
236 *
237 * @return void send wp_json response
238 */
239 public function tutor_export_settings() {
240 tutor_utils()->checking_nonce();
241
242 if ( ! User::is_admin() ) {
243 wp_send_json_error( tutor_utils()->error_message() );
244 }
245
246 $tutor_option = get_option( 'tutor_option' );
247 $data = maybe_unserialize( $tutor_option );
248
249 $export_data = $this->get_export_json_schema();
250
251 $prepare_data = array(
252 'content_type' => 'settings',
253 'data' => $data,
254 );
255
256 $export_data['data'][] = $prepare_data;
257
258 $response = array(
259 'job_progress' => '100',
260 'exported_data' => $export_data,
261 'completed_contents' => array(
262 'settings' => true,
263 ),
264 );
265
266 // Update settings log.
267 $this->update_settings_log( $data, 'Exported' );
268
269 $this->json_response( __( 'Settings exported successfully', 'tutor' ), $response );
270 }
271
272 /**
273 * Export single settings
274 *
275 * @since 2.0.0
276 *
277 * @return void send wp_json response
278 */
279 public function tutor_export_single_settings() {
280
281 tutor_utils()->checking_nonce();
282
283 // Check if user is privileged.
284 if ( ! User::is_admin() ) {
285 wp_send_json_error( tutor_utils()->error_message() );
286 }
287
288 $tutor_settings_log = get_option( 'tutor_settings_log' );
289 $export_id = $this->get_request_data( 'export_id' );
290
291 $export_data = $this->get_export_json_schema();
292
293 $prepare_data = array(
294 'content_type' => 'settings',
295 'data' => $tutor_settings_log[ $export_id ]['dataset'],
296 );
297
298 $export_data['data'][] = $prepare_data;
299 wp_send_json_success( $export_data );
300 }
301
302 /**
303 * Apply settings
304 *
305 * @since 2.0.0
306 *
307 * @return void send wp_json response
308 */
309 public function tutor_apply_settings() {
310
311 tutor_utils()->checking_nonce();
312
313 // Check if user is privileged.
314 if ( ! User::is_admin() ) {
315 wp_send_json_error( tutor_utils()->error_message() );
316 }
317
318 $tutor_settings_log = get_option( 'tutor_settings_log' );
319 $apply_id = $this->get_request_data( 'apply_id' );
320
321 update_option( 'tutor_option', $tutor_settings_log[ $apply_id ]['dataset'] );
322
323 wp_send_json_success( $tutor_settings_log[ $apply_id ] );
324 }
325
326 /**
327 * Delete single setting
328 *
329 * @since 2.0.0
330 *
331 * @return void send wp_json response
332 */
333 public function tutor_delete_single_settings() {
334
335 tutor_utils()->checking_nonce();
336
337 // Check if user is privileged.
338 if ( ! User::is_admin() ) {
339 wp_send_json_error( tutor_utils()->error_message() );
340 }
341
342 $tutor_settings_log = get_option( 'tutor_settings_log' );
343 $delete_id = $this->get_request_data( 'delete_id' );
344 unset( $tutor_settings_log[ $delete_id ] );
345 update_option( 'tutor_settings_log', $tutor_settings_log, false );
346
347 wp_send_json_success( $tutor_settings_log );
348 }
349
350 /**
351 * Get request data
352 *
353 * @since 2.0.0
354 *
355 * @param mixed $var option key.
356 *
357 * @return mixed
358 */
359 public function get_request_data( $var ) {
360 return isset( $_REQUEST[ $var ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $var ] ) ) : null;
361 }
362
363 /**
364 * Tutor settings log
365 *
366 * @since 2.0.0
367 *
368 * @return void send wp_json response
369 */
370 public function load_saved_data() {
371 tutor_utils()->checking_nonce();
372
373 // Check if user is privileged.
374 if ( ! User::is_admin() ) {
375 wp_send_json_error( tutor_utils()->error_message() );
376 }
377
378 wp_send_json_success( get_option( 'tutor_settings_log' ) );
379 }
380
381 /**
382 * Reset settings
383 *
384 * @since 2.0.0
385 *
386 * @return void send wp_json response
387 */
388 public function reset_settings_data() {
389 tutor_utils()->checking_nonce();
390
391 // Check if user is privileged.
392 if ( ! User::is_admin() ) {
393 wp_send_json_error( tutor_utils()->error_message() );
394 }
395
396 $reset_fields = $return_fields = $return_fields_group = array(); //phpcs:ignore
397 $reset_page = Input::post( 'reset_page' );
398 $setting_data = $this->get_setting_fields()['option_fields'][ $reset_page ]['blocks'];
399
400 foreach ( $setting_data as $blocks ) {
401
402 $block_fields = isset( $blocks['fields'] ) ? $blocks['fields'] : array();
403 foreach ( $block_fields as $fields ) {
404 $return_fields[] = $fields;
405 }
406
407 $block_fields_group = isset( $blocks['fields_group'] ) ? $blocks['fields_group'] : array();
408 foreach ( $block_fields_group as $fields ) {
409 $return_fields_group[] = $fields;
410 }
411 }
412
413 $reset_fields = array_merge( $return_fields, $return_fields_group );
414
415 wp_send_json_success( $reset_fields );
416 }
417
418 /**
419 * Import settings
420 *
421 * @since 2.0.0
422 *
423 * @return void
424 */
425 public function tutor_import_settings() {
426 tutor_utils()->checking_nonce();
427
428 // Check if user is privileged.
429 if ( ! User::is_admin() ) {
430 wp_send_json_error( tutor_utils()->error_message() );
431 }
432
433 //phpcs:ignore
434 $data = $_FILES['data'];
435
436 if ( ! isset( $data['tmp_name'] ) ) {
437 $this->response_bad_request( __( 'Invalid file', 'tutor' ) );
438 }
439
440 $request = json_decode( file_get_contents( $data['tmp_name'] ), true );
441
442 unlink( $data['tmp_name'] );
443
444 $settings_found = false;
445
446 if ( json_last_error() ) {
447 $this->response_bad_request( __( 'Invalid json file', 'tutor' ) );
448 }
449
450 if ( ! isset( $request['data'] ) ) {
451 $this->response_bad_request( __( 'Data not found or invalid', 'tutor' ) );
452 }
453
454 if ( is_array( $request['data'] ) && count( $request['data'] ) ) {
455 foreach ( $request['data'] as $content ) {
456 if ( isset( $content['content_type'] ) && 'settings' === $content['content_type'] ) {
457 $settings_found = true;
458 }
459 }
460 }
461
462 if ( ! $settings_found ) {
463 $this->response_bad_request( __( 'Settings not found', 'tutor' ) );
464 }
465
466 $settings_data = is_array( $request ) && isset( $request['data'] ) ? $request['data'][0]['data'] : array();
467 $update_settings = $this->update_settings_log( $settings_data, 'Imported' );
468
469 $response = array(
470 'job_progress' => '100',
471 'exported_data' => $update_settings,
472 );
473
474 $this->json_response( __( 'Settings imported successfully!', 'tutor' ), $response );
475 }
476
477 /**
478 * Validate options before save.
479 *
480 * @since 2.8.0
481 *
482 * @param array $options option submitted to save.
483 *
484 * @return void
485 */
486 public function validate_options( $options ) {
487 $success = true;
488 $message = '';
489
490 $enable_sharing = $options['enable_revenue_sharing'] ?? 'off';
491 $admin_commission = (int) $options['earning_admin_commission'] ?? 0;
492 $instructor_commission = (int) $options['earning_instructor_commission'] ?? 0;
493
494 if ( 'on' === $enable_sharing && ( $admin_commission + $instructor_commission ) > 100 ) {
495 $success = false;
496 $message = __( 'Total share percentage must be 100% or less', 'tutor' );
497 }
498
499 if ( ! $success ) {
500 wp_send_json(
501 array(
502 'success' => $success,
503 'message' => $message,
504 )
505 );
506 }
507 }
508
509 /**
510 * Function tutor_option_save
511 *
512 * @since 2.0.0
513 *
514 * @return void send wp_json response
515 */
516 public function tutor_option_save() {
517 tutor_utils()->checking_nonce();
518
519 if ( ! User::is_admin() ) {
520 wp_send_json_error( tutor_utils()->error_message() );
521 }
522
523 $data_before = get_option( 'tutor_option' );
524 $login_page_id = 0;
525
526 if ( isset( $data_before['tutor_login_page'] ) ) {
527 $login_page_id = $data_before['tutor_login_page'];
528 }
529
530 $option = (array) tutor_utils()->array_get( 'tutor_option', $_POST, array() ); //phpcs:ignore
531
532 do_action( 'tutor_option_save_before', $option );
533
534 if ( ! isset( $option['tutor_login_page'] ) ) {
535 $option['tutor_login_page'] = $login_page_id ?? 0;
536 }
537
538 $option = Input::sanitize_array(
539 $option,
540 array(
541 'payment_settings' => 'wp_kses_post',
542 'tutor_bank_transfer_withdraw_instruction' => 'sanitize_textarea_field',
543 'certificate_showcase_desc' => 'sanitize_textarea_field',
544 'invoice_from_address' => 'sanitize_textarea_field',
545 'fees_name' => 'sanitize_textarea_field',
546 )
547 );
548 $option = apply_filters( 'tutor_option_input', $option );
549
550 $time = strtotime( 'now' ) + ( 6 * 60 * 60 );
551 $save_import_data['datetime'] = $time;
552 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
553 $save_import_data['datatype'] = 'saved';
554 $save_import_data['dataset'] = $option;
555 $import_data[ 'tutor-saved-' . $time ] = $save_import_data;
556 $update_option = array();
557 $get_option_data = get_option( 'tutor_settings_log', array() );
558
559 if ( ! empty( $get_option_data ) ) {
560 $update_option = array_merge( $import_data, $get_option_data );
561 } else {
562 $update_option = array_merge( $update_option, $import_data );
563 }
564
565 $update_option = array_slice( $update_option, 0, 10 );
566
567 update_option( 'tutor_settings_log', $update_option, false );
568 update_option( 'tutor_option', $option );
569 update_option( 'tutor_option_update_time', gmdate( 'j M, Y, g:i a', $time ) );
570
571 /**
572 * Hook for each tutor settings option change detection.
573 * Example: `tutor_option_{course_permalink_base}_changed`
574 *
575 * @since 2.6.0
576 */
577 $data_after = get_option( 'tutor_option' );
578 if ( $data_before !== $data_after && is_array( $data_after ) ) {
579 foreach ( $data_after as $key => $value ) {
580 $from = $data_before[ $key ] ?? null;
581 $to = $value;
582 if ( $from !== $to ) {
583 do_action( "tutor_option_{$key}_changed", $from, $to );
584 }
585 }
586 }
587
588 do_action( 'tutor_option_save_after' );
589
590 $data = apply_filters(
591 'tutor_option_saved_data',
592 array(
593 'success' => true,
594 'message' => __( 'Settings Saved', 'tutor' ),
595 'options' => $option,
596 )
597 );
598
599 wp_send_json( $data );
600 }
601
602 /**
603 * Handle monetization option value change.
604 *
605 * @since 3.0.0
606 *
607 * @return void
608 */
609 public function handle_changed_monetization_option() {
610 add_filter(
611 'tutor_option_saved_data',
612 function ( $res ) {
613 $res['reload_required'] = true;
614 return $res;
615 }
616 );
617 }
618
619 /**
620 * Function tutor_option_save
621 *
622 * @since 2.0.0
623 *
624 * @return void send wp_json response
625 */
626 public function tutor_option_default_save() {
627 tutor_utils()->checking_nonce();
628
629 if ( ! User::is_admin() ) {
630 wp_send_json_error( tutor_utils()->error_message() );
631 }
632
633 $attr = $this->get_setting_fields();
634 $tutor_default_option = get_option( 'tutor_default_option' );
635 $tutor_saved_option = get_option( 'tutor_option' );
636
637 foreach ( $attr as $sections ) {
638 if ( is_array( $sections ) && count( $sections ) ) {
639 foreach ( $sections as $section ) {
640 foreach ( $section['blocks'] as $blocks ) {
641 if ( isset( $blocks['fields'] ) ) {
642 foreach ( $blocks['fields'] as $field ) {
643 if ( isset( $field['key'] ) ) {
644 if ( isset( $tutor_default_option[ $field['key'] ] ) ) {
645 $attr_default[ $field['key'] ] = $tutor_saved_option[ $field['key'] ];
646 } else {
647 $attr_default[ $field['key'] ] = $field['default'] ?? '';
648 }
649 }
650 }
651 }
652 }
653 }
654 }
655 }
656
657 update_option( 'tutor_option', $attr_default );
658
659 wp_send_json_success( $attr_default );
660 }
661
662 /**
663 * Load settings page
664 *
665 * @since 2.0.0
666 *
667 * @return void
668 */
669 public function load_settings_page() {
670 extract( $this->get_setting_fields() ); //phpcs:ignore
671
672 if ( ! $template_path ) {
673 $template_path = tutor()->path . '/views/options/settings.php';
674 }
675 include $template_path;
676 }
677
678 /**
679 * Get settings fields
680 *
681 * @since 2.0.0
682 *
683 * @return mixed
684 */
685 public function get_setting_fields() {
686 if ( $this->setting_fields ) {
687 // Return from property if already prepared.
688 return $this->setting_fields;
689 }
690
691 $pages = tutor_utils()->get_pages();
692
693 $site_url = site_url();
694 $course_base = $this->get( 'course_permalink_base', 'courses' );
695 $lesson_key = $this->get( 'lesson_permalink_base', 'lessons' );
696 $quiz_key = $this->get( 'quiz_permalink_base', 'quizzes' );
697
698 $course_url = $site_url . '/<code>' . $course_base . '</code>/sample-course';
699 $lesson_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $lesson_key . '</code>/sample-lesson/';
700 $quiz_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $quiz_key . '</code>/sample-quiz/';
701
702 $student_url = tutor_utils()->profile_url( 0, false );
703 $methods_array = array();
704 $withdrawl_methods = apply_filters( 'tutor_withdrawal_methods_all', array() );
705
706 foreach ( $withdrawl_methods as $key => $method ) {
707 $methods_array[ $key ] = $method['method_name'];
708 }
709
710 $page_args = array(
711 'post_type' => 'page',
712 'post_status' => 'publish',
713 'posts_per_page' => 1,
714 'title' => 'Courses',
715 );
716
717 $page_posts = get_posts( $page_args );
718 $course_archive_page_id = ( is_array( $page_posts ) && count( $page_posts ) ) ? $page_posts[0] : null;
719
720 $attr = array(
721 'general' => array(
722 'label' => __( 'General', 'tutor' ),
723 'slug' => 'general',
724 'desc' => __( 'General Settings', 'tutor' ),
725 'template' => 'basic',
726 'icon' => 'tutor-icon-earth',
727 'blocks' => array(
728 array(
729 'label' => false,
730 'block_type' => 'uniform',
731 'slug' => 'general-page',
732 'fields' => array(
733 array(
734 'key' => 'tutor_dashboard_page_id',
735 'type' => 'select',
736 'label' => __( 'Dashboard Page', 'tutor' ),
737 'default' => '0',
738 'options' => $pages,
739 'desc' => __( 'This page will be used for student and instructor dashboard', 'tutor' ),
740 'searchable' => true,
741 ),
742 ),
743 ),
744 array(
745 'label' => false,
746 'block_type' => 'uniform',
747 'slug' => 'general-page',
748 'fields' => array(
749 array(
750 'key' => 'tutor_toc_page_id',
751 'type' => 'select',
752 'label' => __( 'Terms and Conditions Page', 'tutor' ),
753 'default' => '0',
754 'options' => $pages,
755 'desc' => __( 'This page will be used as the Terms and Conditions page', 'tutor' ),
756 'searchable' => true,
757 ),
758 array(
759 'key' => OptionKeys::PRIVACY_POLICY,
760 'type' => 'select',
761 'label' => __( 'Privacy Policy', 'tutor' ),
762 'default' => 0,
763 'options' => $pages,
764 'desc' => __( 'Choose the page for privacy policy.', 'tutor' ),
765 'searchable' => true,
766 ),
767 ),
768 ),
769 array(
770 'label' => __( 'Others', 'tutor' ),
771 'slug' => 'others',
772 'block_type' => 'isolate',
773 'fields' => array(
774 array(
775 'key' => 'enable_course_marketplace',
776 'type' => 'toggle_switch',
777 'label' => __( 'Enable Marketplace', 'tutor' ),
778 'label_title' => '',
779 'default' => 'off',
780 'desc' => __( 'Allow multiple instructors to sell their courses.', 'tutor' ),
781 ),
782 array(
783 'key' => 'pagination_per_page',
784 'type' => 'number',
785 'number_type' => 'integer',
786 'label' => __( 'Pagination', 'tutor' ),
787 'default' => '20',
788 'desc' => __( 'Set the number of rows to be displayed per page', 'tutor' ),
789 ),
790 ),
791 ),
792 array(
793 'label' => __( 'Instructor', 'tutor' ),
794 'slug' => 'instructor',
795 'block_type' => 'uniform',
796 'fields' => array(
797 array(
798 'key' => 'enable_become_instructor_btn',
799 'type' => 'toggle_switch',
800 'label' => __( 'Become an Instructor Button', 'tutor' ),
801 'label_title' => '',
802 'default' => 'off',
803 'desc' => __( 'Enable the option to display this button on the student dashboard.', 'tutor' ),
804 ),
805 array(
806 'key' => 'instructor_can_publish_course',
807 'type' => 'toggle_switch',
808 'label' => __( 'Allow Instructors to Publish Courses', 'tutor' ),
809 'label_title' => '',
810 'default' => 'off',
811 'desc' => __( 'Enable instructors to publish the course directly. If disabled, admins will be able to review course content before publishing.', 'tutor' ),
812 ),
813 array(
814 'key' => 'instructor_can_delete_course',
815 'type' => 'toggle_switch',
816 'label' => __( 'Allow Instructors to Trash Courses', 'tutor' ),
817 'label_title' => '',
818 'default' => 'on',
819 'desc' => __( 'Enable this setting to allow instructors to delete courses.', 'tutor' ),
820 ),
821 ),
822 ),
823 ),
824 ),
825 'course' => array(
826 'label' => __( 'Course', 'tutor' ),
827 'slug' => 'course',
828 'desc' => __( 'Course Settings', 'tutor' ),
829 'template' => 'basic',
830 'icon' => 'tutor-icon-book-open',
831 'blocks' => array(
832 'block_course' => array(
833 'label' => '',
834 'slug' => 'course',
835 'block_type' => 'uniform',
836 'fields' => array(
837 array(
838 'key' => 'student_must_login_to_view_course',
839 'type' => 'toggle_switch',
840 'label' => __( 'Course Visibility', 'tutor' ),
841 'label_title' => '',
842 'default' => 'off',
843 'desc' => __( 'Students must be logged in to view course', 'tutor' ),
844 ),
845 array(
846 'key' => 'course_content_access_for_ia',
847 'type' => 'toggle_switch',
848 'label' => __( 'Course Content Access', 'tutor' ),
849 'default' => 'off',
850 'label_title' => '',
851 'desc' => __( 'Allow instructors and admins to view the course content without enrolling', 'tutor' ),
852 ),
853 array(
854 'key' => 'course_content_summary',
855 'type' => 'toggle_switch',
856 'label' => __( 'Content Summary', 'tutor' ),
857 'default' => 'on',
858 'desc' => __( 'Enabling this feature will show a course content summary on the Course Details page.', 'tutor' ),
859 ),
860 array(
861 'key' => 'enable_spotlight_mode',
862 'type' => 'toggle_switch',
863 'label' => __( 'Spotlight Mode', 'tutor' ),
864 'default' => 'off',
865 'label_title' => '',
866 'desc' => __( 'This will hide the header and the footer and enable spotlight (full screen) mode when students view lessons.', 'tutor' ),
867 ),
868 array(
869 'key' => 'auto_course_complete_on_all_lesson_completion',
870 'type' => 'toggle_switch',
871 'label' => __( 'Auto Complete Course on All Lesson Completion', 'tutor' ),
872 'default' => 'off',
873 'label_title' => '',
874 'desc' => __( 'If enabled, an Enrolled Course will be automatically completed if all its Lessons, Quizzes, and Assignments are already completed by the Student', 'tutor' ),
875 ),
876 array(
877 'key' => 'course_completion_process',
878 'type' => 'radio_vertical',
879 'label' => __( 'Course Completion Process', 'tutor' ),
880 'default' => 'flexible',
881 'select_options' => false,
882 'options' => array(
883 'flexible' => array(
884 'label' => __( 'Flexible', 'tutor' ),
885 'desc' => __( 'Students can complete courses anytime in the Flexible mode', 'tutor' ),
886 ),
887 'strict' => array(
888 'label' => __( 'Strict', 'tutor' ),
889 'desc' => __( 'Students must complete all lessons, quizzes, and assignments to mark their courses as complete.', 'tutor' ),
890 ),
891 ),
892 'desc' => __( 'Choose when a user can click on the <strong>“Complete Course”</strong> button', 'tutor' ),
893 ),
894 array(
895 'key' => 'course_retake_feature',
896 'type' => 'toggle_switch',
897 'label' => __( 'Course Retake', 'tutor' ),
898 'default' => 'off',
899 'label_title' => '',
900 'desc' => __( 'Enabling this feature will allow students to reset course progress and start over.', 'tutor' ),
901 ),
902 array(
903 'key' => 'course_reset_progress',
904 'type' => 'toggle_switch',
905 'label' => __( 'Course Reset Progress', 'tutor' ),
906 'default' => 'off',
907 'label_title' => '',
908 'desc' => __( 'Enabling this feature allows students to reset their progress and start over before completing the course.', 'tutor' ),
909 ),
910 array(
911 'key' => 'enable_course_review_moderation',
912 'type' => 'toggle_switch',
913 'label' => __( "Publish Course Review on Admin's Approval", 'tutor' ),
914 'default' => 'off',
915 'label_title' => '',
916 'desc' => __( 'Enable to publish/re-publish Course Review after the approval of Site Admin', 'tutor' ),
917 ),
918 ),
919 ),
920 'block_lesson' => array(
921 'label' => __( 'Lesson', 'tutor' ),
922 'slug' => 'lesson',
923 'block_type' => 'uniform',
924 'fields' => array(
925 array(
926 'key' => 'enable_lesson_classic_editor',
927 'type' => 'toggle_switch',
928 'label' => __( 'WP Editor for Lesson', 'tutor' ),
929 'label_title' => '',
930 'default' => 'off',
931 'desc' => __( 'Enable classic editor to edit lesson.', 'tutor' ),
932 ),
933 array(
934 'key' => 'autoload_next_course_content',
935 'type' => 'toggle_switch',
936 'label' => __( 'Automatically Load Next Course Content.', 'tutor' ),
937 'label_title' => '',
938 'default' => 'off',
939 'desc' => __( 'Enable this feature to automatically load the next course content after the current one is finished.', 'tutor' ),
940 ),
941 array(
942 'key' => 'enable_comment_for_lesson',
943 'type' => 'toggle_switch',
944 'label' => __( 'Enable Lesson Comment', 'tutor' ),
945 'label_title' => '',
946 'default' => 'off',
947 'desc' => __( 'Enable this feature to allow students to post comments on lessons.', 'tutor' ),
948 ),
949 ),
950 ),
951 'block_quiz' => array(
952 'label' => __( 'Quiz', 'tutor' ),
953 'slug' => 'quiz',
954 'block_type' => 'uniform',
955 'fields' => array(
956 array(
957 'key' => 'quiz_when_time_expires',
958 'type' => 'radio_vertical',
959 'label' => __( 'When time expires', 'tutor' ),
960 'default' => 'auto_abandon',
961 'select_options' => false,
962 'options' => array(
963 'auto_submit' => array(
964 'label' => __( 'Auto Submit', 'tutor' ),
965 'desc' => __( 'The current quiz answers are submitted automatically.', 'tutor' ),
966 ),
967 'auto_abandon' => array(
968 'label' => __( 'Auto Abandon', 'tutor' ),
969 'desc' => __( 'Attempts must be submitted before time expires, otherwise they will not be counted.', 'tutor' ),
970 ),
971 ),
972 'desc' => __( 'Choose which action to follow when the quiz time expires.', 'tutor' ),
973 ),
974 array(
975 'key' => 'quiz_answer_display_time',
976 'type' => 'number',
977 'label' => __( 'Correct Answer Display Time (When Reveal Mode is enabled)', 'tutor' ),
978 'default' => '2',
979 'desc' => __( 'Put the answer display time in seconds', 'tutor' ),
980 ),
981 array(
982 'key' => 'quiz_previous_button_enabled',
983 'type' => 'toggle_switch',
984 'label' => __( 'Show Quiz Previous Button', 'tutor' ),
985 'default' => 'on',
986 'desc' => __( 'Choose whether to show or hide the previous button for each question.', 'tutor' ),
987 ),
988 array(
989 'key' => 'quiz_grade_method',
990 'type' => 'radio_horizontal_full',
991 'label' => __( 'Final Grade Calculation', 'tutor' ),
992 'desc' => __( 'When multiple attempts are allowed, select which method should be used to calculate a student\'s final grade for the quiz.', 'tutor' ),
993 'default' => 'highest_grade',
994 'options' => array(
995 'highest_grade' => __( 'Highest Grade', 'tutor' ),
996 'average_grade' => __( 'Average Grade', 'tutor' ),
997 'first_attempt' => __( 'First Attempt', 'tutor' ),
998 'last_attempt' => __( 'Last Attempt', 'tutor' ),
999 ),
1000 ),
1001 ),
1002 ),
1003 array(
1004 'label' => __( 'Video', 'tutor' ),
1005 'slug' => 'video',
1006 'block_type' => 'uniform',
1007 'fields' => array(
1008 array(
1009 'key' => 'supported_video_sources',
1010 'type' => 'checkbox_vertical',
1011 'default' => array( 'youtube', 'vimeo' ),
1012 'label' => __( 'Preferred Video Source', 'tutor' ),
1013 'label_title' => __( 'Preferred Video Source', 'tutor' ),
1014 'options' => tutor_utils()->get_video_sources( true ),
1015 'desc' => __( 'Select the video hosting platform(s) you want to enable.', 'tutor' ),
1016 ),
1017 array(
1018 'key' => 'disable_default_player_youtube',
1019 'type' => 'toggle_switch',
1020 'label' => __( 'Use Tutor Player for YouTube', 'tutor' ),
1021 'label_title' => '',
1022 'default' => 'off',
1023 'desc' => __( 'Enable this option to use Tutor LMS video player for YouTube.', 'tutor' ),
1024 ),
1025 array(
1026 'key' => 'disable_default_player_vimeo',
1027 'type' => 'toggle_switch',
1028 'label' => __( 'Use Tutor Player for Vimeo', 'tutor' ),
1029 'label_title' => '',
1030 'default' => 'off',
1031 'desc' => __( 'Enable this option to use Tutor LMS video player for Vimeo.', 'tutor' ),
1032 ),
1033 ),
1034 ),
1035 ),
1036 ),
1037 'monetization' => array(
1038 'label' => __( 'Monetization', 'tutor' ),
1039 'slug' => 'monetization',
1040 'desc' => __( 'Monetization Settings', 'tutor' ),
1041 'template' => 'basic',
1042 'icon' => 'tutor-icon-badge-discount',
1043 'blocks' => array(
1044 'block_options' => array(
1045 'label' => __( 'Options', 'tutor' ),
1046 'slug' => 'options',
1047 'block_type' => 'uniform',
1048 'fields' => array(
1049 array(
1050 'key' => 'monetize_by',
1051 'type' => 'select',
1052 'label' => __( 'Select eCommerce Engine', 'tutor' ),
1053 'select_options' => false,
1054 'options' => apply_filters(
1055 'tutor_monetization_options',
1056 array(
1057 'free' => __( 'Disable Monetization', 'tutor' ),
1058 )
1059 ),
1060 'default' => 'free',
1061 'desc' => __( 'Select a monetization option to generate revenue by selling courses.', 'tutor' ),
1062 ),
1063 ),
1064 ),
1065 'block_woocommerce' => array(
1066 'label' => __( 'WooCommerce', 'tutor' ),
1067 'slug' => 'woocommerce',
1068 'block_type' => 'uniform',
1069 'fields' => array(
1070 array(
1071 'key' => 'tutor_woocommerce_order_auto_complete',
1072 'type' => 'toggle_switch',
1073 'label' => __( 'Automatically Complete WooCommerce Orders', 'tutor' ),
1074 'label_title' => '',
1075 'default' => 'off',
1076 'desc' => __( 'If enabled, in the case of Courses, WooCommerce Orders will get the "Completed" status .', 'tutor' ),
1077 ),
1078 array(
1079 'key' => 'wc_automatic_order_complete_redirect_to_courses',
1080 'type' => 'toggle_switch',
1081 'label' => __( 'Auto Redirect to Courses', 'tutor' ),
1082 'default' => 'off',
1083 'label_title' => '',
1084 'desc' => __( 'When a user\'s WooCommerce order is auto-completed, they will be redirected to enrolled courses', 'tutor' ),
1085 ),
1086 array(
1087 'key' => 'enable_guest_course_cart',
1088 'type' => 'toggle_switch',
1089 'label' => __( 'Enable Guest Mode', 'tutor' ),
1090 'label_title' => '',
1091 'default' => 'off',
1092 'desc' => __( 'Allow customers to place orders without an account.', 'tutor' ),
1093 ),
1094 ),
1095 ),
1096 'block_revenue_sharing' => array(
1097 'label' => __( 'Revenue Sharing', 'tutor' ),
1098 'slug' => 'revenue_sharing',
1099 'block_type' => 'uniform',
1100 'fields' => array(
1101 array(
1102 'key' => 'enable_revenue_sharing',
1103 'type' => 'toggle_switch',
1104 'label' => __( 'Enable Revenue Sharing', 'tutor' ),
1105 'label_title' => '',
1106 'default' => 'off',
1107 'desc' => __( 'Allow revenue generated from selling courses to be shared with course creators.', 'tutor' ),
1108 'toggle_fields' => 'sharing_percentage',
1109 'toggle_blocks' => 'fees,withdraw',
1110 ),
1111 array(
1112 'key' => 'sharing_percentage',
1113 'type' => 'double_input',
1114 'label' => __( 'Sharing Percentage', 'tutor' ),
1115 'label_title' => '',
1116 'default' => '',
1117 'fields' => array(
1118 'earning_instructor_commission' => array(
1119 'id' => 'revenue-instructor',
1120 'type' => 'ratio',
1121 'title' => __( 'Instructor Takes', 'tutor' ),
1122 'default' => 20,
1123 ),
1124 'earning_admin_commission' => array(
1125 'id' => 'revenue-admin',
1126 'type' => 'ratio',
1127 'title' => __( 'Admin Takes', 'tutor' ),
1128 'default' => 80,
1129 ),
1130 ),
1131 'desc' => __( 'Set how the sales revenue will be shared among admins and instructors.', 'tutor' ),
1132 ),
1133 ),
1134 ),
1135 'block_fees' => array(
1136 'label' => __( 'Fees', 'tutor' ),
1137 'slug' => 'fees',
1138 'block_type' => 'uniform',
1139 'fields' => array(
1140 array(
1141 'key' => 'enable_fees_deducting',
1142 'type' => 'toggle_switch',
1143 'label' => __( 'Deduct Fees', 'tutor' ),
1144 'label_title' => '',
1145 'default' => 'off',
1146 'desc' => __( 'Fees are charged from the entire sales amount. The remaining amount will be divided among admin and instructors.', 'tutor' ),
1147 'toggle_fields' => 'fees_name,fee_amount_type',
1148 ),
1149 array(
1150 'key' => 'fees_name',
1151 'type' => 'textarea',
1152 'label' => __( 'Fee Description', 'tutor' ),
1153 'placeholder' => __( 'Fee Description', 'tutor' ),
1154 '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' ),
1155 'maxlength' => 200,
1156 'rows' => 5,
1157 'default' => 'Maintenance Fees',
1158 ),
1159 array(
1160 'key' => 'fee_amount_type',
1161 'type' => 'group_fields',
1162 'label' => __( 'Fee Amount & Type', 'tutor' ),
1163 'desc' => __( 'Select the fee type and add fee amount/percentage', 'tutor' ),
1164 'group_fields' => array(
1165 'fees_type' => array(
1166 'type' => 'select',
1167 'default' => 'fixed',
1168 'select_options' => false,
1169 'options' => array(
1170 'percent' => __( 'Percent', 'tutor' ),
1171 'fixed' => __( 'Fixed', 'tutor' ),
1172 ),
1173 ),
1174 'fees_amount' => array(
1175 'type' => 'number',
1176 'default' => '0',
1177 ),
1178 ),
1179 ),
1180 ),
1181 ),
1182 'block_withdraw' => array(
1183 'label' => __( 'Withdraw', 'tutor' ),
1184 'slug' => 'withdraw',
1185 'block_type' => 'uniform',
1186 'fields' => array(
1187 array(
1188 'key' => 'min_withdraw_amount',
1189 'type' => 'number',
1190 'label' => __( 'Minimum Withdrawal Amount', 'tutor' ),
1191 'default' => '80',
1192 'desc' => __( 'Instructors should earn equal or above this amount to make a withdraw request.', 'tutor' ),
1193 ),
1194 array(
1195 'key' => 'minimum_days_for_balance_to_be_available',
1196 'type' => 'number',
1197 'number_type' => 'integer',
1198 'label' => __( 'Minimum Days Before Balance is Available', 'tutor' ),
1199 'default' => '7',
1200 'min' => 1,
1201 'desc' => __( 'Any income has to remain this many days in the platform before it is available for withdrawal.', 'tutor' ),
1202 ),
1203 array(
1204 'key' => 'tutor_withdrawal_methods',
1205 'type' => 'checkbox_horizontal',
1206 'label' => __( 'Enable Withdraw Method', 'tutor' ),
1207 'default' => array( 'bank_transfer_withdraw' ),
1208 'options' => $methods_array,
1209 'desc' => __( 'Set how you would like to withdraw money from the website.', 'tutor' ),
1210 ),
1211 array(
1212 'key' => 'tutor_bank_transfer_withdraw_instruction',
1213 'type' => 'textarea',
1214 'label' => __( 'Bank Instructions', 'tutor' ),
1215 'default' => __( 'Write the up to date bank informations of your instructor here.', 'tutor' ),
1216 'desc' => __( 'Write bank instructions for the instructors to conduct withdrawals.', 'tutor' ),
1217 ),
1218 ),
1219 ),
1220 ),
1221 ),
1222 'design' => array(
1223 'label' => __( 'Design', 'tutor' ),
1224 'slug' => 'design',
1225 'desc' => __( 'Design Settings', 'tutor' ),
1226 'template' => 'design',
1227 'icon' => 'tutor-icon-color-palette',
1228 'blocks' => array(
1229 // Experimental.
1230 'block_appearance' => array(
1231 'label' => __( 'Appearance', 'tutor' ),
1232 'slug' => 'appearance',
1233 'block_type' => 'uniform',
1234 'fields' => array(
1235 array(
1236 'key' => 'learning_mode',
1237 'type' => 'radio_horizontal_image',
1238 'label' => __( 'Learning Mode', 'tutor' ),
1239 'desc' => __( 'Decide how students will experience the courses you create.', 'tutor' ),
1240 'default' => self::LEARNING_MODE_MODERN,
1241 'options' => array(
1242 self::LEARNING_MODE_MODERN => array(
1243 'title' => __( 'Modern', 'tutor' ),
1244 'image' => 'learning-mode/modern.svg',
1245 ),
1246 self::LEARNING_MODE_KIDS => array(
1247 'title' => __( 'Kids', 'tutor' ),
1248 'image' => 'learning-mode/kids.svg',
1249 ),
1250 self::LEARNING_MODE_LEGACY => array(
1251 'title' => __( 'Legacy', 'tutor' ),
1252 'image' => 'learning-mode/legacy.svg',
1253 ),
1254 ),
1255 ),
1256 array(
1257 'key' => 'default_theme',
1258 'type' => 'radio_horizontal_image',
1259 'label' => __( 'Default Theme', 'tutor' ),
1260 'desc' => __( 'Set the default appearance for learners across your platform. Learners can switch between dark and light mode if enabled.', 'tutor' ),
1261 'default' => self::DEFAULT_THEME_SYSTEM,
1262 'options' => array(
1263 self::DEFAULT_THEME_LIGHT => array(
1264 'title' => __( 'Light', 'tutor' ),
1265 'image' => 'default-theme/light.webp',
1266 ),
1267 self::DEFAULT_THEME_DARK => array(
1268 'title' => __( 'Dark', 'tutor' ),
1269 'image' => 'default-theme/dark.webp',
1270 ),
1271 self::DEFAULT_THEME_SYSTEM => array(
1272 'title' => __( 'Auto', 'tutor' ),
1273 'image' => 'default-theme/auto.webp',
1274 ),
1275 ),
1276 ),
1277 array(
1278 'key' => 'brand_color',
1279 'preset_name' => 'brand_color',
1280 'type' => 'color_field',
1281 'label' => __( 'Brand Color', 'tutor' ),
1282 'desc' => __( 'Customize the primary accent color used across your learning platform to match your brand identity.', 'tutor' ),
1283 'class' => 'color-picker-wrapper',
1284 'default' => tutor_utils()->get_default_brand_color(),
1285 ),
1286 ),
1287 ),
1288 'block_course' => array(
1289 'label' => __( 'Course', 'tutor' ),
1290 'slug' => 'course',
1291 'block_type' => 'uniform',
1292 'fields' => array(
1293 array(
1294 'key' => 'courses_col_per_row',
1295 'type' => 'radio_horizontal',
1296 'label' => __( 'Column Per Row', 'tutor' ),
1297 'default' => '3',
1298 'options' => array(
1299 '1' => __( 'One', 'tutor' ),
1300 '2' => __( 'Two', 'tutor' ),
1301 '3' => __( 'Three', 'tutor' ),
1302 '4' => __( 'Four', 'tutor' ),
1303 ),
1304 'desc' => __( 'Define how many columns you want to use to display courses.', 'tutor' ),
1305 ),
1306 array(
1307 'key' => 'courses_per_page',
1308 'type' => 'number',
1309 'number_type' => 'integer',
1310 'label' => __( 'Courses Per Page', 'tutor' ),
1311 'default' => '12',
1312 'desc' => __( 'Set the number of courses to display per page on the Course List page.', 'tutor' ),
1313 ),
1314 array(
1315 'key' => 'course_archive_filter',
1316 'type' => 'toggle_switch',
1317 'label' => __( 'Course Filter', 'tutor' ),
1318 'label_title' => '',
1319 'default' => 'off',
1320 'desc' => __( 'Show sorting and filtering options on course archive page', 'tutor' ),
1321 'toggle_fields' => 'supported_course_filters',
1322 ),
1323 array(
1324 'key' => 'supported_course_filters',
1325 'type' => 'checkbox_horizontal',
1326 'label' => __( 'Preferred Course Filters', 'tutor' ),
1327 'default' => array( 'search', 'category' ),
1328 'options' => array(
1329 'search' => __( 'Keyword Search', 'tutor' ),
1330 'category' => __( 'Category', 'tutor' ),
1331 'tag' => __( 'Tag', 'tutor' ),
1332 'difficulty_level' => __( 'Difficulty Level', 'tutor' ),
1333 'price_type' => __( 'Price Type', 'tutor' ),
1334 ),
1335 'desc' => __( 'Choose preferred filter options you\'d like to show on the course archive page.', 'tutor' ),
1336 ),
1337 array(
1338 'key' => 'course_archive_filter_sorting',
1339 'type' => 'toggle_switch',
1340 'label' => __( 'Course Sorting', 'tutor' ),
1341 'label_title' => '',
1342 'default' => 'on',
1343 'desc' => __( 'If enabled, the courses will be sortable by Course Name or Creation Date in either Ascending or Descending order', 'tutor' ),
1344 ),
1345 ),
1346 ),
1347 'layout' => array(
1348 'label' => __( 'Layout', 'tutor' ),
1349 'slug' => 'layout',
1350 'block_type' => 'uniform',
1351 'fields' => array(
1352 array(
1353 'key' => 'instructor_list_layout',
1354 'type' => 'group_radio',
1355 'label' => __( 'Instructor List Layout', 'tutor' ),
1356 'desc' => __( 'Choose a layout for the list of instructors inside a course page. You can change this at any time.', 'tutor' ),
1357 'default' => 'portrait',
1358 'group_options' => array(
1359 'vertical' => array(
1360 'default' => array(
1361 'title' => __( 'Portrait', 'tutor' ),
1362 'image' => 'instructor-layout/instructor-portrait.svg',
1363 ),
1364 'cover' => array(
1365 'title' => __( 'Cover', 'tutor' ),
1366 'image' => 'instructor-layout/instructor-cover.svg',
1367 ),
1368 'minimal' => array(
1369 'title' => __( 'Minimal', 'tutor' ),
1370 'image' => 'instructor-layout/instructor-minimal.svg',
1371 ),
1372 ),
1373 'horizontal' => array(
1374 'portrait-horizontal' => array(
1375 'title' => __( 'Portrait Horizontal', 'tutor' ),
1376 'image' => 'instructor-layout/instructor-horizontal-portrait.svg',
1377 ),
1378 'minimal-horizontal' => array(
1379 'title' => __( 'Minimal Horizontal', 'tutor' ),
1380 'image' => 'instructor-layout/instructor-horizontal-minimal.svg',
1381 ),
1382 ),
1383 ),
1384 ),
1385 array(
1386 'key' => 'public_profile_layout',
1387 'type' => 'group_radio_full_3',
1388 'label' => __( 'Instructor Public Profile Layout', 'tutor' ),
1389 'desc' => __( 'Choose a layout design for a instructor’s public profile', 'tutor' ),
1390 'default' => 'pp-rectangle',
1391 'group_options' => array(
1392 'private' => array(
1393 'title' => __( 'Private', 'tutor' ),
1394 'image' => 'profile-layout/profile-private.svg',
1395 ),
1396 'pp-circle' => array(
1397 'title' => __( 'Modern', 'tutor' ),
1398 'image' => 'profile-layout/profile-modern.svg',
1399 ),
1400 'no-cp' => array(
1401 'title' => __( 'Minimal', 'tutor' ),
1402 'image' => 'profile-layout/profile-minimal.svg',
1403 ),
1404 'pp-rectangle' => array(
1405 'title' => __( 'Classic', 'tutor' ),
1406 'image' => 'profile-layout/profile-classic.svg',
1407 ),
1408 ),
1409 ),
1410 array(
1411 'key' => 'student_public_profile_layout',
1412 'type' => 'group_radio_full_3',
1413 'label' => __( 'Student Public Profile Layout', 'tutor' ),
1414 'desc' => __( 'Choose a layout design for a student’s public profile', 'tutor' ),
1415 'default' => 'pp-rectangle',
1416 'group_options' => array(
1417 'private' => array(
1418 'title' => __( 'Private', 'tutor' ),
1419 'image' => 'profile-layout/profile-private.svg',
1420 ),
1421 'pp-circle' => array(
1422 'title' => __( 'Modern', 'tutor' ),
1423 'image' => 'profile-layout/profile-modern.svg',
1424 ),
1425 'no-cp' => array(
1426 'title' => __( 'Minimal', 'tutor' ),
1427 'image' => 'profile-layout/profile-minimal.svg',
1428 ),
1429 'pp-rectangle' => array(
1430 'title' => __( 'Classic', 'tutor' ),
1431 'image' => 'profile-layout/profile-classic.svg',
1432 ),
1433 ),
1434 ),
1435 ),
1436 ),
1437 'course-details' => array(
1438 'label' => __( 'Course Details', 'tutor' ),
1439 'slug' => 'course-details',
1440 'block_type' => 'isolate',
1441 'fields' => array(
1442 array(
1443 'key' => 'course_details_adjustments',
1444 'type' => 'checkgroup',
1445 'label' => __( 'Page Features', 'tutor' ),
1446 'desc' => __( 'You can keep the following features active or inactive as per the need of your business model', 'tutor' ),
1447 'group_options' => array(
1448 array(
1449 'key' => 'display_course_instructors',
1450 'type' => 'toggle_single',
1451 'label' => __( 'Instructor Info', 'tutor' ),
1452 'default' => 'on',
1453 'desc' => __( 'Toggle to show instructor info', 'tutor' ),
1454 ),
1455 array(
1456 'key' => 'enable_wishlist',
1457 'type' => 'toggle_single',
1458 'label' => __( 'Wishlist', 'tutor' ),
1459 'default' => 'on',
1460 'desc' => __( 'Toggle to disable/enable wishlist', 'tutor' ),
1461 ),
1462 array(
1463 'key' => 'enable_q_and_a_on_course',
1464 'type' => 'toggle_single',
1465 'label' => __( 'Q&A', 'tutor' ),
1466 'default' => 'on',
1467 'desc' => __( 'Enable to add a Q&A section', 'tutor' ),
1468 ),
1469 array(
1470 'key' => 'enable_course_author',
1471 'type' => 'toggle_single',
1472 'label' => __( 'Author', 'tutor' ),
1473 'label_title' => __( 'Enable', 'tutor' ),
1474 'default' => 'off',
1475 'desc' => __( 'Enable to show course author name', 'tutor' ),
1476 ),
1477 array(
1478 'key' => 'enable_course_level',
1479 'type' => 'toggle_single',
1480 'label' => __( 'Level', 'tutor' ),
1481 'label_title' => __( 'Enable', 'tutor' ),
1482 'default' => 'on',
1483 'desc' => __( 'Enable to show course level', 'tutor' ),
1484 ),
1485 array(
1486 'key' => 'enable_course_share',
1487 'type' => 'toggle_single',
1488 'label' => __( 'Social Share', 'tutor' ),
1489 'label_title' => __( 'Enable', 'tutor' ),
1490 'default' => 'on',
1491 'desc' => __( 'Toggle to enable course social share', 'tutor' ),
1492 ),
1493 array(
1494 'key' => 'enable_course_duration',
1495 'type' => 'toggle_single',
1496 'label' => __( 'Duration', 'tutor' ),
1497 'label_title' => __( 'Disable', 'tutor' ),
1498 'default' => 'on',
1499 'desc' => __( 'Enable to show course duration', 'tutor' ),
1500 ),
1501 array(
1502 'key' => 'enable_course_total_enrolled',
1503 'type' => 'toggle_single',
1504 'label' => __( 'Total Enrolled', 'tutor' ),
1505 'label_title' => __( 'Enable', 'tutor' ),
1506 'default' => 'on',
1507 'desc' => __( 'Enable to show total enrolled students', 'tutor' ),
1508 ),
1509 array(
1510 'key' => 'enable_course_update_date',
1511 'type' => 'toggle_single',
1512 'label' => __( 'Update Date', 'tutor' ),
1513 'label_title' => __( 'Enable', 'tutor' ),
1514 'default' => 'on',
1515 'desc' => __( 'Enable to show course update information', 'tutor' ),
1516 ),
1517 array(
1518 'key' => 'enable_course_progress_bar',
1519 'type' => 'toggle_single',
1520 'label' => __( 'Progress Bar', 'tutor' ),
1521 'label_title' => __( 'Enable', 'tutor' ),
1522 'default' => 'on',
1523 'desc' => __( 'Enable to show course progress for Students', 'tutor' ),
1524 ),
1525 array(
1526 'key' => 'enable_course_material',
1527 'type' => 'toggle_single',
1528 'label' => __( 'Material', 'tutor' ),
1529 'label_title' => __( 'Enable', 'tutor' ),
1530 'default' => 'on',
1531 'desc' => __( 'Enable to show course materials', 'tutor' ),
1532 ),
1533 array(
1534 'key' => 'enable_course_about',
1535 'type' => 'toggle_single',
1536 'label' => __( 'About', 'tutor' ),
1537 'label_title' => __( 'Enable', 'tutor' ),
1538 'default' => 'on',
1539 'desc' => __( 'Enable to show course about section', 'tutor' ),
1540 ),
1541 array(
1542 'key' => 'enable_course_description',
1543 'type' => 'toggle_single',
1544 'label' => __( 'Description', 'tutor' ),
1545 'label_title' => __( 'Enable', 'tutor' ),
1546 'default' => 'on',
1547 'desc' => __( 'Enable to show course description', 'tutor' ),
1548 ),
1549 array(
1550 'key' => 'enable_course_benefits',
1551 'type' => 'toggle_single',
1552 'label' => __( 'Benefits', 'tutor' ),
1553 'label_title' => __( 'Enable', 'tutor' ),
1554 'default' => 'on',
1555 'desc' => __( 'Enable to show course benefits section', 'tutor' ),
1556 ),
1557 array(
1558 'key' => 'enable_course_requirements',
1559 'type' => 'toggle_single',
1560 'label' => __( 'Requirements', 'tutor' ),
1561 'label_title' => __( 'Enable', 'tutor' ),
1562 'default' => 'on',
1563 'desc' => __( 'Enable to show courses requirements section', 'tutor' ),
1564 ),
1565 array(
1566 'key' => 'enable_course_target_audience',
1567 'type' => 'toggle_single',
1568 'label' => __( 'Target Audience', 'tutor' ),
1569 'label_title' => __( 'Disable', 'tutor' ),
1570 'default' => 'on',
1571 'desc' => __( 'Enable to show course target audience section', 'tutor' ),
1572 ),
1573 array(
1574 'key' => 'enable_course_announcements',
1575 'type' => 'toggle_single',
1576 'label' => __( 'Announcements', 'tutor' ),
1577 'label_title' => __( 'Enable', 'tutor' ),
1578 'default' => 'on',
1579 'desc' => __( 'Enable to show course announcements section', 'tutor' ),
1580 ),
1581 array(
1582 'key' => 'enable_course_review',
1583 'type' => 'toggle_single',
1584 'label' => __( 'Review', 'tutor' ),
1585 'label_title' => __( 'Enable', 'tutor' ),
1586 'default' => 'on',
1587 'desc' => __( 'Enable to show course review section', 'tutor' ),
1588 ),
1589 ),
1590 ),
1591 ),
1592 ),
1593 ),
1594 ),
1595 'advanced' => array(
1596 'label' => __( 'Advanced', 'tutor' ),
1597 'slug' => 'advanced',
1598 'desc' => __( 'Advanced Settings', 'tutor' ),
1599 'template' => 'basic',
1600 'icon' => 'tutor-icon-filter',
1601 'blocks' => array(
1602 array(
1603 'label' => __( 'Course', 'tutor' ),
1604 'slug' => 'options',
1605 'block_type' => 'uniform',
1606 'fields' => array(
1607 array(
1608 'key' => 'enable_gutenberg_course_edit',
1609 'type' => 'toggle_switch',
1610 'label' => __( 'Gutenberg Editor', 'tutor' ),
1611 'default' => 'off',
1612 'desc' => __( 'Enable this to create courses using the Gutenberg Editor.', 'tutor' ),
1613 ),
1614 array(
1615 'key' => 'hide_course_from_shop_page',
1616 'type' => 'toggle_switch',
1617 'label' => __( 'Hide Course Products on Shop Page', 'tutor' ),
1618 'default' => 'off',
1619 'desc' => __( 'Enable to hide course products on shop page.', 'tutor' ),
1620 ),
1621 array(
1622 'key' => 'course_archive_page',
1623 'type' => 'select',
1624 'label' => __( 'Course Archive Page', 'tutor' ),
1625 'default' => $course_archive_page_id->ID ?? '0',
1626 'options' => $pages,
1627 'desc' => __( 'This page will be used to list all the published courses.', 'tutor' ),
1628 'searchable' => true,
1629 ),
1630 array(
1631 'key' => 'instructor_register_page',
1632 'type' => 'select',
1633 'label' => __( 'Instructor Registration Page', 'tutor' ),
1634 'default' => '0',
1635 'options' => $pages,
1636 'desc' => __( 'Choose the page for instructor registration.', 'tutor' ),
1637 'searchable' => true,
1638 ),
1639 array(
1640 'key' => 'student_register_page',
1641 'type' => 'select',
1642 'label' => __( 'Student Registration Page', 'tutor' ),
1643 'default' => '0',
1644 'options' => $pages,
1645 'desc' => __( 'Choose the page for student registration.', 'tutor' ),
1646 'searchable' => true,
1647 ),
1648 array(
1649 'key' => 'lesson_video_duration_youtube_api_key',
1650 'type' => 'text',
1651 'label' => __( 'YouTube API Key', 'tutor' ),
1652 'default' => '',
1653 'desc' => __(
1654 'To host live videos on your platform using YouTube, enter your YouTube API key.',
1655 'tutor'
1656 ),
1657 'placeholder' => __( 'Insert API key here', 'tutor' ),
1658 ),
1659 ),
1660 ),
1661 array(
1662 'label' => __( 'Base Permalink', 'tutor' ),
1663 'slug' => 'base_permalink',
1664 'block_type' => 'uniform',
1665 'fields' => array(
1666 array(
1667 'key' => 'course_permalink_base',
1668 'type' => 'text',
1669 'label' => __( 'Course Permalink', 'tutor' ),
1670 'default' => 'courses',
1671 'desc' => $course_url,
1672 ),
1673 array(
1674 'key' => 'lesson_permalink_base',
1675 'type' => 'text',
1676 'label' => __( 'Lesson Permalink', 'tutor' ),
1677 'default' => 'lessons',
1678 'desc' => $lesson_url,
1679 ),
1680 array(
1681 'key' => 'quiz_permalink_base',
1682 'type' => 'text',
1683 'label' => __( 'Quiz Permalink', 'tutor' ),
1684 'default' => 'quizzes',
1685 'desc' => $quiz_url,
1686 ),
1687 ),
1688 ),
1689 array(
1690 'label' => __( 'Options', 'tutor' ),
1691 'slug' => 'options',
1692 'block_type' => 'uniform',
1693 'fields' => array(
1694 array(
1695 'key' => 'enable_profile_completion',
1696 'type' => 'toggle_switch',
1697 'label' => __( 'Profile Completion', 'tutor' ),
1698 'label_title' => '',
1699 'default' => 'off',
1700 'desc' => __( 'Enabling this feature will show a notification bar to students and instructors to complete their profile information', 'tutor' ),
1701 ),
1702 array(
1703 'key' => 'enable_tutor_native_login',
1704 'type' => 'toggle_switch',
1705 'label' => __( 'Enable Tutor LMS Login', 'tutor' ),
1706 'label_title' => '',
1707 'default' => 'on',
1708 'desc' => __( 'Enable to use the Tutor LMS native login system instead of the WordPress login page', 'tutor' ),
1709 ),
1710 array(
1711 'key' => 'delete_on_uninstall',
1712 'type' => 'toggle_switch',
1713 'label' => __( 'Erase upon uninstallation', 'tutor' ),
1714 'label_title' => '',
1715 'default' => 'off',
1716 'desc' => __( 'Delete all data during uninstallation', 'tutor' ),
1717 ),
1718 array(
1719 'key' => 'enable_tutor_maintenance_mode',
1720 'type' => 'toggle_switch',
1721 'label' => __( 'Maintenance Mode', 'tutor' ),
1722 'label_title' => '',
1723 'default' => 'off',
1724 'desc' => __( 'Enabling maintenance mode will display a custom message on the frontend. During maintenance mode, visitors cannot access site content, but the wp-admin dashboard remains accessible.', 'tutor' ),
1725 ),
1726 ),
1727 ),
1728 ),
1729 ),
1730 'legal_consents' => array(
1731 'label' => __( 'Legal Consents', 'tutor' ),
1732 'slug' => 'legal_consents',
1733 'desc' => __( 'Legal Consents', 'tutor' ),
1734 'template' => 'legal_consents',
1735 'icon' => 'tutor-icon-lesson',
1736 'blocks' => array(
1737 array(
1738 'label' => __( 'Legal Consents', 'tutor' ),
1739 'slug' => 'legal_consents',
1740 'block_type' => 'uniform',
1741 'fields' => array(
1742 array(
1743 'key' => 'legal_consents',
1744 'type' => 'text',
1745 'label' => __( 'Legal Consents', 'tutor' ),
1746 'default' => array(),
1747 ),
1748 ),
1749 ),
1750 ),
1751 ),
1752 );
1753
1754 $attrs = apply_filters( 'tutor/options/extend/attr', apply_filters( 'tutor/options/attr', $attr ) );
1755
1756 // Get the active tab.
1757 $tab_page = tutor_utils()->array_get( 'tab_page', $_REQUEST, 'general' );
1758 $tab_data = null;
1759 $template = null;
1760
1761 foreach ( $attrs as $key => $section ) {
1762 if ( $tab_page == $key ) {
1763 if ( isset( $section['template_path'] ) && $section['template_path'] ) {
1764 $template = $section['template_path'];
1765 $tab_data = $section;
1766 }
1767 break;
1768 }
1769 }
1770
1771 // Store in runtime cache.
1772 $this->setting_fields = array(
1773 'option_fields' => $attrs,
1774 'active_tab' => $tab_page,
1775 'active_tab_data' => $tab_data,
1776 'template_path' => $template,
1777 );
1778
1779 return $this->setting_fields;
1780 }
1781
1782 /**
1783 * Generate field
1784 *
1785 * @since 2.0.0
1786 *
1787 * @param array $field field array.
1788 * @param array $blocks blocks array.
1789 *
1790 * @return void
1791 *
1792 * Generate Option Field
1793 */
1794 public function generate_field( $field = array(), $blocks = array() ) {
1795 ob_start();
1796 if ( isset( $field['type'] ) ) {
1797 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1798 }
1799 echo ob_get_clean();//phpcs:ignore
1800 }
1801
1802 /**
1803 * Include field type template & return buffered
1804 * string data.
1805 *
1806 * @since 2.0.0
1807 *
1808 * @param array $field field.
1809 *
1810 * @return string
1811 */
1812 public function field_type( $field = array() ) {
1813 ob_start();
1814 if ( isset( $field['type'] ) ) {
1815 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1816 }
1817 return ob_get_clean();
1818 }
1819
1820 /**
1821 * Include Option blocks template & return
1822 * buffered string data.
1823 *
1824 * @since 2.0.0
1825 *
1826 * @param array $blocks blocks.
1827 *
1828 * @return string
1829 */
1830 public function blocks( $blocks = array() ) {
1831 ob_start();
1832 include apply_filters( 'tutor_settings_block_template_path', tutor()->path . 'views/options/option_blocks.php', $blocks );
1833 return ob_get_clean();
1834 }
1835
1836 /**
1837 * Include options template & returns
1838 * buffered string data.
1839 *
1840 * @since 2.0.0
1841 *
1842 * @param array $section section.
1843 *
1844 * @return string
1845 */
1846 public function template( $section = array() ) {
1847 ob_start();
1848 $blocks = $section['blocks'];
1849 if ( isset( $section['template'] ) ) {
1850 include apply_filters( 'tutor_option_template_path', tutor()->path . "views/options/template/{$section['template']}.php", $section['template'] );
1851 }
1852 return ob_get_clean();
1853 }
1854
1855
1856 /**
1857 * Load template inside template directory
1858 *
1859 * @since 2.0.0
1860 *
1861 * @param mixed $template_slug template slug.
1862 * @param mixed $section section.
1863 *
1864 * @return string
1865 */
1866 public function view_template( $template_slug, $section = array() ) {
1867 ob_start();
1868 if ( isset( $template_slug ) ) {
1869 require tutor()->path . "views/options/template/{$template_slug}";
1870 }
1871 return ob_get_clean();
1872 }
1873
1874 /**
1875 * Get field name
1876 *
1877 * It's useful when a field has event key like course.lessons
1878 *
1879 * @since 3.5.0
1880 *
1881 * @param array $field Option field array.
1882 *
1883 * @return string
1884 */
1885 public function get_field_name( array $field ) {
1886 $events = $field['event'] ?? null;
1887 $field_name = 'tutor_option';
1888 if ( $events ) {
1889 $events = explode( '.', $events );
1890 foreach ( $events as $event ) {
1891 $field_name .= '[' . $event . ']';
1892 }
1893 $field_name .= '[' . $field['key'] . ']';
1894 } else {
1895 $field_name .= '[' . $field['key'] . ']';
1896 }
1897
1898 return $field_name;
1899 }
1900
1901 /**
1902 * Json schema data
1903 *
1904 * @since 1.0.0
1905 *
1906 * @return array
1907 */
1908 public function get_export_json_schema() {
1909 $export_data = array(
1910 'schema_version' => '1.0.0',
1911 'exported_at' => current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ),
1912 'keep_media_files' => false,
1913 'keep_user_data' => false,
1914 'data' => array(),
1915 );
1916
1917 return $export_data;
1918 }
1919
1920 /**
1921 * Update settings log based on the new data
1922 *
1923 * @since 3.6.0
1924 *
1925 * @param array $new_settings_data New exported/import settings data.
1926 * @param string $action_type Action type Imported/Exported.
1927 *
1928 * @return array Settings log data
1929 */
1930 public function update_settings_log( $new_settings_data, $action_type ) {
1931 $get_final_data = array();
1932
1933 $action = strtolower( $action_type );
1934
1935 $time = tutor_time();
1936
1937 $save_import_data['datetime'] = $time;
1938 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
1939 $save_import_data['datatype'] = $action_type;
1940 $save_import_data['dataset'] = $new_settings_data;
1941 $import_data[ 'tutor-imported-' . $time ] = $save_import_data;
1942
1943 $get_option_data = get_option( 'tutor_settings_log' );
1944 if ( empty( $get_option_data ) ) {
1945 $get_option_data = array();
1946 }
1947 if ( ! empty( $get_option_data ) && null !== $save_import_data['dataset'] ) {
1948
1949 $update_option = array_merge( $import_data, $get_option_data );
1950
1951 $update_option = Input::sanitize_array(
1952 $update_option,
1953 array(
1954 'payment_settings' => 'wp_kses_post',
1955 'tutor_bank_transfer_withdraw_instruction' => 'sanitize_textarea_field',
1956 'certificate_showcase_desc' => 'sanitize_textarea_field',
1957 'invoice_from_address' => 'sanitize_textarea_field',
1958 'fees_name' => 'sanitize_textarea_field',
1959 )
1960 );
1961
1962 if ( ! empty( $update_option ) ) {
1963 update_option( 'tutor_settings_log', $update_option );
1964 }
1965
1966 if ( 'imported' === $action ) {
1967 if ( ! empty( $save_import_data ) ) {
1968 update_option( 'tutor_option', $save_import_data['dataset'] );
1969 }
1970 }
1971
1972 $get_final_data = get_option( 'tutor_settings_log' );
1973
1974 } else {
1975 if ( ! empty( $import_data ) ) {
1976 update_option( 'tutor_settings_log', $import_data );
1977 }
1978
1979 if ( 'imported' === $action ) {
1980 if ( ! empty( $save_import_data ) ) {
1981 update_option( 'tutor_option', $save_import_data['dataset'] );
1982 }
1983 }
1984
1985 $get_final_data = get_option( 'tutor_settings_log' );
1986 }
1987
1988 return $get_final_data;
1989 }
1990 }
1991