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