PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.6.3
Tutor LMS – eLearning and online course solution v3.6.3
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 year ago Admin.php 1 year ago Ajax.php 1 year ago Announcements.php 1 year ago Assets.php 1 year ago Backend_Page_Trait.php 1 year ago BaseController.php 1 year ago Course.php 1 year ago Course_Embed.php 3 years ago Course_Filter.php 1 year ago Course_List.php 1 year 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 Input.php 1 year ago Instructor.php 1 year ago Instructors_List.php 1 year ago Lesson.php 1 year ago Options_V2.php 1 year ago Permalink.php 2 years ago Post_types.php 1 year ago Private_Course_Access.php 1 year ago Q_And_A.php 1 year ago Question_Answers_List.php 3 years ago Quiz.php 1 year ago QuizBuilder.php 1 year ago Quiz_Attempts_List.php 1 year ago RestAPI.php 2 years ago Reviews.php 3 years ago Rewrite_Rules.php 2 years ago Shortcode.php 1 year ago Singleton.php 1 year ago Student.php 1 year ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 1 year ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 1 year ago Tutor.php 1 year ago TutorEDD.php 1 year ago Tutor_Base.php 2 years ago Tutor_Setup.php 1 year ago Upgrader.php 1 year ago User.php 1 year ago Utils.php 1 year ago Video_Stream.php 3 years ago WhatsNew.php 2 years ago Withdraw.php 1 year ago Withdraw_Requests_List.php 1 year ago WooCommerce.php 11 months ago
Options_V2.php
2053 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\Ecommerce\OptionKeys;
14 use TUTOR\Input;
15 use Tutor\Traits\JsonResponse;
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-pro' ), $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 $request = json_decode( stripslashes( $_POST['data'] ), true );
435
436 $settings_found = false;
437
438 if ( json_last_error() ) {
439 $this->response_bad_request( __( 'Invalid json file', 'tutor' ) );
440 }
441
442 if ( ! isset( $request['data'] ) ) {
443 $this->response_bad_request( __( 'Data not found or invalid', 'tutor' ) );
444 }
445
446 if ( is_array( $request['data'] ) && count( $request['data'] ) ) {
447 foreach ( $request['data'] as $content ) {
448 if ( isset( $content['content_type'] ) && 'settings' === $content['content_type'] ) {
449 $settings_found = true;
450 }
451 }
452 }
453
454 if ( ! $settings_found ) {
455 $this->response_bad_request( __( 'Settings not found', 'tutor' ) );
456 }
457
458 $settings_data = is_array( $request ) && isset( $request['data'] ) ? $request['data'][0]['data'] : array();
459 $update_settings = $this->update_settings_log( $settings_data, 'Imported' );
460
461 $response = array(
462 'job_progress' => '100',
463 'exported_data' => $update_settings,
464 );
465
466 $this->json_response( __( 'Settings imported successfully!', 'tutor' ), $response );
467 }
468
469 /**
470 * Validate options before save.
471 *
472 * @since 2.8.0
473 *
474 * @param array $options option submitted to save.
475 *
476 * @return void
477 */
478 public function validate_options( $options ) {
479 $success = true;
480 $message = '';
481
482 $enable_sharing = $options['enable_revenue_sharing'] ?? 'off';
483 $admin_commission = (int) $options['earning_admin_commission'] ?? 0;
484 $instructor_commission = (int) $options['earning_instructor_commission'] ?? 0;
485
486 if ( 'on' === $enable_sharing && ( $admin_commission + $instructor_commission ) > 100 ) {
487 $success = false;
488 $message = __( 'Total share percentage must be 100% or less', 'tutor' );
489 }
490
491 if ( ! $success ) {
492 wp_send_json(
493 array(
494 'success' => $success,
495 'message' => $message,
496 )
497 );
498 }
499 }
500
501 /**
502 * Function tutor_option_save
503 *
504 * @since 2.0.0
505 *
506 * @return void send wp_json response
507 */
508 public function tutor_option_save() {
509 tutor_utils()->checking_nonce();
510
511 ! current_user_can( 'manage_options' ) ? wp_send_json_error() : 0;
512
513 $data_before = get_option( 'tutor_option' );
514 $option = (array) tutor_utils()->array_get( 'tutor_option', $_POST, array() ); //phpcs:ignore
515
516 do_action( 'tutor_option_save_before', $option );
517
518 $option = tutor_utils()->sanitize_recursively( $option );
519 $option = apply_filters( 'tutor_option_input', $option );
520
521 $time = strtotime( 'now' ) + ( 6 * 60 * 60 );
522 $save_import_data['datetime'] = $time;
523 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
524 $save_import_data['datatype'] = 'saved';
525 $save_import_data['dataset'] = $option;
526 $import_data[ 'tutor-saved-' . $time ] = $save_import_data;
527 $update_option = array();
528 $get_option_data = get_option( 'tutor_settings_log', array() );
529
530 if ( ! empty( $get_option_data ) ) {
531 $update_option = array_merge( $import_data, $get_option_data );
532 } else {
533 $update_option = array_merge( $update_option, $import_data );
534 }
535
536 $update_option = array_slice( $update_option, 0, 10 );
537
538 update_option( 'tutor_settings_log', $update_option, false );
539 update_option( 'tutor_option', $option );
540 update_option( 'tutor_option_update_time', gmdate( 'j M, Y, g:i a', $time ) );
541
542 /**
543 * Hook for each tutor settings option change detection.
544 * Example: `tutor_option_{course_permalink_base}_changed`
545 *
546 * @since 2.6.0
547 */
548 $data_after = get_option( 'tutor_option' );
549 if ( $data_before !== $data_after && is_array( $data_after ) ) {
550 foreach ( $data_after as $key => $value ) {
551 $from = $data_before[ $key ] ?? null;
552 $to = $value;
553 if ( $from !== $to ) {
554 do_action( "tutor_option_{$key}_changed", $from, $to );
555 }
556 }
557 }
558
559 do_action( 'tutor_option_save_after' );
560
561 $data = apply_filters(
562 'tutor_option_saved_data',
563 array(
564 'success' => true,
565 'message' => __( 'Settings Saved', 'tutor' ),
566 'options' => $option,
567 )
568 );
569
570 wp_send_json( $data );
571 }
572
573 /**
574 * Handle monetization option value change.
575 *
576 * @since 3.0.0
577 *
578 * @return void
579 */
580 public function handle_changed_monetization_option() {
581 add_filter(
582 'tutor_option_saved_data',
583 function ( $res ) {
584 $res['reload_required'] = true;
585 return $res;
586 }
587 );
588 }
589
590 /**
591 * Function tutor_option_save
592 *
593 * @since 2.0.0
594 *
595 * @return void send wp_json response
596 */
597 public function tutor_option_default_save() {
598 tutor_utils()->checking_nonce();
599
600 ! current_user_can( 'manage_options' ) ? wp_send_json_error() : 0;
601 $attr = $this->get_setting_fields();
602 $tutor_default_option = get_option( 'tutor_default_option' );
603 $tutor_saved_option = get_option( 'tutor_option' );
604
605 foreach ( $attr as $sections ) {
606 if ( is_array( $sections ) && count( $sections ) ) {
607 foreach ( $sections as $section ) {
608 foreach ( $section['blocks'] as $blocks ) {
609 if ( isset( $blocks['fields'] ) ) {
610 foreach ( $blocks['fields'] as $field ) {
611 if ( isset( $field['key'] ) ) {
612 if ( isset( $tutor_default_option[ $field['key'] ] ) ) {
613 $attr_default[ $field['key'] ] = $tutor_saved_option[ $field['key'] ];
614 } else {
615 $attr_default[ $field['key'] ] = $field['default'] ?? '';
616 }
617 }
618 }
619 }
620 }
621 }
622 }
623 }
624
625 update_option( 'tutor_option', $attr_default );
626
627 wp_send_json_success( $attr_default );
628 }
629
630 /**
631 * Load settings page
632 *
633 * @since 2.0.0
634 *
635 * @return void
636 */
637 public function load_settings_page() {
638 extract( $this->get_setting_fields() ); //phpcs:ignore
639
640 if ( ! $template_path ) {
641 $template_path = tutor()->path . '/views/options/settings.php';
642 }
643 include $template_path;
644 }
645
646 /**
647 * Get settings fields
648 *
649 * @since 2.0.0
650 *
651 * @return mixed
652 */
653 public function get_setting_fields() {
654 if ( $this->setting_fields ) {
655 // Return from property if already prepared.
656 return $this->setting_fields;
657 }
658
659 $pages = tutor_utils()->get_pages();
660
661 $site_url = site_url();
662 $course_base = $this->get( 'course_permalink_base', 'courses' );
663 $lesson_key = $this->get( 'lesson_permalink_base', 'lessons' );
664 $quiz_key = $this->get( 'quiz_permalink_base', 'quizzes' );
665
666 $course_url = $site_url . '/<code>' . $course_base . '</code>/sample-course';
667 $lesson_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $lesson_key . '</code>/sample-lesson/';
668 $quiz_url = $site_url . '/' . $course_base . '/sample-course/<code>' . $quiz_key . '</code>/sample-quiz/';
669
670 $student_url = tutor_utils()->profile_url( 0, false );
671 $methods_array = array();
672 $withdrawl_methods = apply_filters( 'tutor_withdrawal_methods_all', array() );
673
674 foreach ( $withdrawl_methods as $key => $method ) {
675 $methods_array[ $key ] = $method['method_name'];
676 }
677
678 $page_args = array(
679 'post_type' => 'page',
680 'post_status' => 'publish',
681 'posts_per_page' => 1,
682 'title' => 'Courses',
683 );
684
685 $page_posts = get_posts( $page_args );
686 $course_archive_page_id = ( is_array( $page_posts ) && count( $page_posts ) ) ? $page_posts[0] : null;
687
688 $attr = array(
689 'general' => array(
690 'label' => __( 'General', 'tutor' ),
691 'slug' => 'general',
692 'desc' => __( 'General Settings', 'tutor' ),
693 'template' => 'basic',
694 'icon' => 'tutor-icon-earth',
695 'blocks' => array(
696 array(
697 'label' => false,
698 'block_type' => 'uniform',
699 'slug' => 'general-page',
700 'fields' => array(
701 array(
702 'key' => 'tutor_dashboard_page_id',
703 'type' => 'select',
704 'label' => __( 'Dashboard Page', 'tutor' ),
705 'default' => '0',
706 'options' => $pages,
707 'desc' => __( 'This page will be used for student and instructor dashboard', 'tutor' ),
708 'searchable' => true,
709 ),
710 ),
711 ),
712 array(
713 'label' => false,
714 'block_type' => 'uniform',
715 'slug' => 'general-page',
716 'fields' => array(
717 array(
718 'key' => 'tutor_toc_page_id',
719 'type' => 'select',
720 'label' => __( 'Terms and Conditions Page', 'tutor' ),
721 'default' => '0',
722 'options' => $pages,
723 'desc' => __( 'This page will be used as the Terms and Conditions page', 'tutor' ),
724 'searchable' => true,
725 ),
726 array(
727 'key' => OptionKeys::PRIVACY_POLICY,
728 'type' => 'select',
729 'label' => __( 'Privacy Policy', 'tutor' ),
730 'default' => 0,
731 'options' => $pages,
732 'desc' => __( 'Choose the page for privacy policy.', 'tutor' ),
733 'searchable' => true,
734 ),
735 ),
736 ),
737 array(
738 'label' => __( 'Others', 'tutor' ),
739 'slug' => 'others',
740 'block_type' => 'isolate',
741 'fields' => array(
742 array(
743 'key' => 'enable_course_marketplace',
744 'type' => 'toggle_switch',
745 'label' => __( 'Enable Marketplace', 'tutor' ),
746 'label_title' => '',
747 'default' => 'off',
748 'desc' => __( 'Allow multiple instructors to sell their courses.', 'tutor' ),
749 ),
750 array(
751 'key' => 'pagination_per_page',
752 'type' => 'number',
753 'number_type' => 'integer',
754 'label' => __( 'Pagination', 'tutor' ),
755 'default' => '20',
756 'desc' => __( 'Set the number of rows to be displayed per page', 'tutor' ),
757 ),
758 ),
759 ),
760 array(
761 'label' => __( 'Instructor', 'tutor' ),
762 'slug' => 'instructor',
763 'block_type' => 'uniform',
764 'fields' => array(
765 array(
766 'key' => 'enable_become_instructor_btn',
767 'type' => 'toggle_switch',
768 'label' => __( 'Become an Instructor Button', 'tutor' ),
769 'label_title' => '',
770 'default' => 'off',
771 'desc' => __( 'Enable the option to display this button on the student dashboard.', 'tutor' ),
772 ),
773 array(
774 'key' => 'instructor_can_publish_course',
775 'type' => 'toggle_switch',
776 'label' => __( 'Allow Instructors to Publish Courses', 'tutor' ),
777 'label_title' => '',
778 'default' => 'off',
779 'desc' => __( 'Enable instructors to publish the course directly. If disabled, admins will be able to review course content before publishing.', 'tutor' ),
780 ),
781 array(
782 'key' => 'instructor_can_delete_course',
783 'type' => 'toggle_switch',
784 'label' => __( 'Allow Instructors to Trash Courses', 'tutor' ),
785 'label_title' => '',
786 'default' => 'on',
787 'desc' => __( 'Enable this setting to allow instructors to delete courses.', 'tutor' ),
788 ),
789 ),
790 ),
791 ),
792 ),
793 'course' => array(
794 'label' => __( 'Course', 'tutor' ),
795 'slug' => 'course',
796 'desc' => __( 'Course Settings', 'tutor' ),
797 'template' => 'basic',
798 'icon' => 'tutor-icon-book-open',
799 'blocks' => array(
800 'block_course' => array(
801 'label' => '',
802 'slug' => 'course',
803 'block_type' => 'uniform',
804 'fields' => array(
805 array(
806 'key' => 'student_must_login_to_view_course',
807 'type' => 'toggle_switch',
808 'label' => __( 'Course Visibility', 'tutor' ),
809 'label_title' => '',
810 'default' => 'off',
811 'desc' => __( 'Students must be logged in to view course', 'tutor' ),
812 ),
813 array(
814 'key' => 'course_content_access_for_ia',
815 'type' => 'toggle_switch',
816 'label' => __( 'Course Content Access', 'tutor' ),
817 'default' => 'off',
818 'label_title' => '',
819 'desc' => __( 'Allow instructors and admins to view the course content without enrolling', 'tutor' ),
820 ),
821 array(
822 'key' => 'course_content_summary',
823 'type' => 'toggle_switch',
824 'label' => __( 'Content Summary', 'tutor' ),
825 'default' => 'on',
826 'desc' => __( 'Enabling this feature will show a course content summary on the Course Details page.', 'tutor' ),
827 ),
828 array(
829 'key' => 'enable_spotlight_mode',
830 'type' => 'toggle_switch',
831 'label' => __( 'Spotlight Mode', 'tutor' ),
832 'default' => 'off',
833 'label_title' => '',
834 'desc' => __( 'This will hide the header and the footer and enable spotlight (full screen) mode when students view lessons.', 'tutor' ),
835 ),
836 array(
837 'key' => 'auto_course_complete_on_all_lesson_completion',
838 'type' => 'toggle_switch',
839 'label' => __( 'Auto Complete Course on All Lesson Completion', 'tutor' ),
840 'default' => 'off',
841 'label_title' => '',
842 'desc' => __( 'If enabled, an Enrolled Course will be automatically completed if all its Lessons, Quizzes, and Assignments are already completed by the Student', 'tutor' ),
843 ),
844 array(
845 'key' => 'course_completion_process',
846 'type' => 'radio_vertical',
847 'label' => __( 'Course Completion Process', 'tutor' ),
848 'default' => 'flexible',
849 'select_options' => false,
850 'options' => array(
851 'flexible' => array(
852 'label' => __( 'Flexible', 'tutor' ),
853 'desc' => __( 'Students can complete courses anytime in the Flexible mode', 'tutor' ),
854 ),
855 'strict' => array(
856 'label' => __( 'Strict', 'tutor' ),
857 'desc' => __( 'Students have to complete, pass all the lessons and quizzes (if any) to mark a course as complete.', 'tutor' ),
858 ),
859 ),
860 'desc' => __( 'Choose when a user can click on the <strong>“Complete Course”</strong> button', 'tutor' ),
861 ),
862 array(
863 'key' => 'course_retake_feature',
864 'type' => 'toggle_switch',
865 'label' => __( 'Course Retake', 'tutor' ),
866 'default' => 'off',
867 'label_title' => '',
868 'desc' => __( 'Enabling this feature will allow students to reset course progress and start over.', 'tutor' ),
869 ),
870 array(
871 'key' => 'enable_course_review_moderation',
872 'type' => 'toggle_switch',
873 'label' => __( "Publish Course Review on Admin's Approval", 'tutor' ),
874 'default' => 'off',
875 'label_title' => '',
876 'desc' => __( 'Enable to publish/re-publish Course Review after the approval of Site Admin', 'tutor' ),
877 ),
878 ),
879 ),
880 'block_lesson' => array(
881 'label' => __( 'Lesson', 'tutor' ),
882 'slug' => 'lesson',
883 'block_type' => 'uniform',
884 'fields' => array(
885 array(
886 'key' => 'enable_lesson_classic_editor',
887 'type' => 'toggle_switch',
888 'label' => __( 'WP Editor for Lesson', 'tutor' ),
889 'label_title' => '',
890 'default' => 'off',
891 'desc' => __( 'Enable classic editor to edit lesson.', 'tutor' ),
892 ),
893 array(
894 'key' => 'autoload_next_course_content',
895 'type' => 'toggle_switch',
896 'label' => __( 'Automatically Load Next Course Content.', 'tutor' ),
897 'label_title' => '',
898 'default' => 'off',
899 'desc' => __( 'Enable this feature to automatically load the next course content after the current one is finished.', 'tutor' ),
900 ),
901 array(
902 'key' => 'enable_comment_for_lesson',
903 'type' => 'toggle_switch',
904 'label' => __( 'Enable Lesson Comment', 'tutor' ),
905 'label_title' => '',
906 'default' => 'off',
907 'desc' => __( 'Enable this feature to allow students to post comments on lessons.', 'tutor' ),
908 ),
909 ),
910 ),
911 'block_quiz' => array(
912 'label' => __( 'Quiz', 'tutor' ),
913 'slug' => 'quiz',
914 'block_type' => 'uniform',
915 'fields' => array(
916 array(
917 'key' => 'quiz_when_time_expires',
918 'type' => 'radio_vertical',
919 'label' => __( 'When time expires', 'tutor' ),
920 'default' => 'auto_abandon',
921 'select_options' => false,
922 'options' => array(
923 'auto_submit' => array(
924 'label' => __( 'Auto Submit', 'tutor' ),
925 'desc' => __( 'The current quiz answers are submitted automatically.', 'tutor' ),
926 ),
927 'auto_abandon' => array(
928 'label' => __( 'Auto Abandon', 'tutor' ),
929 'desc' => __( 'Attempts must be submitted before time expires, otherwise they will not be counted.', 'tutor' ),
930 ),
931 ),
932 'desc' => __( 'Choose which action to follow when the quiz time expires.', 'tutor' ),
933 ),
934 array(
935 'key' => 'quiz_answer_display_time',
936 'type' => 'number',
937 'label' => __( 'Correct Answer Display Time (When Reveal Mode is enabled)', 'tutor' ),
938 'default' => '2',
939 'desc' => __( 'Put the answer display time in seconds', 'tutor' ),
940 ),
941 array(
942 'key' => 'quiz_attempts_allowed',
943 'type' => 'number',
944 'number_type' => 'integer',
945 'label' => __( 'Default Quiz Attempt limit (When Retry Mode is enabled)', 'tutor' ),
946 'default' => '10',
947 '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' ),
948 ),
949 array(
950 'key' => 'quiz_previous_button_enabled',
951 'type' => 'toggle_switch',
952 'label' => __( 'Show Quiz Previous Button', 'tutor' ),
953 'default' => 'on',
954 'desc' => __( 'Choose whether to show or hide the previous button for each question.', 'tutor' ),
955 ),
956 array(
957 'key' => 'quiz_grade_method',
958 'type' => 'radio_horizontal_full',
959 'label' => __( 'Final Grade Calculation', 'tutor' ),
960 'desc' => __( 'When multiple attempts are allowed, select which method should be used to calculate a student\'s final grade for the quiz.', 'tutor' ),
961 'default' => 'highest_grade',
962 'options' => array(
963 'highest_grade' => __( 'Highest Grade', 'tutor' ),
964 'average_grade' => __( 'Average Grade', 'tutor' ),
965 'first_attempt' => __( 'First Attempt', 'tutor' ),
966 'last_attempt' => __( 'Last Attempt', 'tutor' ),
967 ),
968 ),
969 ),
970 ),
971 array(
972 'label' => __( 'Video', 'tutor' ),
973 'slug' => 'video',
974 'block_type' => 'uniform',
975 'fields' => array(
976 array(
977 'key' => 'supported_video_sources',
978 'type' => 'checkbox_vertical',
979 'default' => array( 'youtube', 'vimeo' ),
980 'label' => __( 'Preferred Video Source', 'tutor' ),
981 'label_title' => __( 'Preferred Video Source', 'tutor' ),
982 'options' => tutor_utils()->get_video_sources( true ),
983 'desc' => __( 'Select the video hosting platform(s) you want to enable.', 'tutor' ),
984 ),
985 array(
986 'key' => 'disable_default_player_youtube',
987 'type' => 'toggle_switch',
988 'label' => __( 'Use Tutor Player for YouTube', 'tutor' ),
989 'label_title' => '',
990 'default' => 'off',
991 'desc' => __( 'Enable this option to use Tutor LMS video player for YouTube.', 'tutor' ),
992 ),
993 array(
994 'key' => 'disable_default_player_vimeo',
995 'type' => 'toggle_switch',
996 'label' => __( 'Use Tutor Player for Vimeo', 'tutor' ),
997 'label_title' => '',
998 'default' => 'off',
999 'desc' => __( 'Enable this option to use Tutor LMS video player for Vimeo.', 'tutor' ),
1000 ),
1001 ),
1002 ),
1003 ),
1004 ),
1005 'monetization' => array(
1006 'label' => __( 'Monetization', 'tutor' ),
1007 'slug' => 'monetization',
1008 'desc' => __( 'Monetization Settings', 'tutor' ),
1009 'template' => 'basic',
1010 'icon' => 'tutor-icon-badge-discount',
1011 'blocks' => array(
1012 'block_options' => array(
1013 'label' => __( 'Options', 'tutor' ),
1014 'slug' => 'options',
1015 'block_type' => 'uniform',
1016 'fields' => array(
1017 array(
1018 'key' => 'monetize_by',
1019 'type' => 'select',
1020 'label' => __( 'Select eCommerce Engine', 'tutor' ),
1021 'select_options' => false,
1022 'options' => apply_filters(
1023 'tutor_monetization_options',
1024 array(
1025 'free' => __( 'Disable Monetization', 'tutor' ),
1026 )
1027 ),
1028 'default' => 'free',
1029 'desc' => __( 'Select a monetization option to generate revenue by selling courses.', 'tutor' ),
1030 ),
1031 ),
1032 ),
1033 'block_woocommerce' => array(
1034 'label' => __( 'WooCommerce', 'tutor' ),
1035 'slug' => 'woocommerce',
1036 'block_type' => 'uniform',
1037 'fields' => array(
1038 array(
1039 'key' => 'tutor_woocommerce_order_auto_complete',
1040 'type' => 'toggle_switch',
1041 'label' => __( 'Automatically Complete WooCommerce Orders', 'tutor' ),
1042 'label_title' => '',
1043 'default' => 'off',
1044 'desc' => __( 'If enabled, in the case of Courses, WooCommerce Orders will get the "Completed" status .', 'tutor' ),
1045 ),
1046 array(
1047 'key' => 'wc_automatic_order_complete_redirect_to_courses',
1048 'type' => 'toggle_switch',
1049 'label' => __( 'Auto Redirect to Courses', 'tutor' ),
1050 'default' => 'off',
1051 'label_title' => '',
1052 'desc' => __( 'When a user\'s WooCommerce order is auto-completed, they will be redirected to enrolled courses', 'tutor' ),
1053 ),
1054 array(
1055 'key' => 'enable_guest_course_cart',
1056 'type' => 'toggle_switch',
1057 'label' => __( 'Enable Guest Mode', 'tutor' ),
1058 'label_title' => '',
1059 'default' => 'off',
1060 'desc' => __( 'Allow customers to place orders without an account.', 'tutor' ),
1061 ),
1062 ),
1063 ),
1064 'block_revenue_sharing' => array(
1065 'label' => __( 'Revenue Sharing', 'tutor' ),
1066 'slug' => 'revenue_sharing',
1067 'block_type' => 'uniform',
1068 'fields' => array(
1069 array(
1070 'key' => 'enable_revenue_sharing',
1071 'type' => 'toggle_switch',
1072 'label' => __( 'Enable Revenue Sharing', 'tutor' ),
1073 'label_title' => '',
1074 'default' => 'off',
1075 'desc' => __( 'Allow revenue generated from selling courses to be shared with course creators.', 'tutor' ),
1076 'toggle_fields' => 'sharing_percentage',
1077 'toggle_blocks' => 'fees,withdraw',
1078 ),
1079 array(
1080 'key' => 'sharing_percentage',
1081 'type' => 'double_input',
1082 'label' => __( 'Sharing Percentage', 'tutor' ),
1083 'label_title' => '',
1084 'default' => '',
1085 'fields' => array(
1086 'earning_instructor_commission' => array(
1087 'id' => 'revenue-instructor',
1088 'type' => 'ratio',
1089 'title' => __( 'Instructor Takes', 'tutor' ),
1090 'default' => 20,
1091 ),
1092 'earning_admin_commission' => array(
1093 'id' => 'revenue-admin',
1094 'type' => 'ratio',
1095 'title' => __( 'Admin Takes', 'tutor' ),
1096 'default' => 80,
1097 ),
1098 ),
1099 'desc' => __( 'Set how the sales revenue will be shared among admins and instructors.', 'tutor' ),
1100 ),
1101 ),
1102 ),
1103 'block_fees' => array(
1104 'label' => __( 'Fees', 'tutor' ),
1105 'slug' => 'fees',
1106 'block_type' => 'uniform',
1107 'fields' => array(
1108 array(
1109 'key' => 'enable_fees_deducting',
1110 'type' => 'toggle_switch',
1111 'label' => __( 'Deduct Fees', 'tutor' ),
1112 'label_title' => '',
1113 'default' => 'off',
1114 'desc' => __( 'Fees are charged from the entire sales amount. The remaining amount will be divided among admin and instructors.', 'tutor' ),
1115 'toggle_fields' => 'fees_name,fee_amount_type',
1116 ),
1117 array(
1118 'key' => 'fees_name',
1119 'type' => 'textarea',
1120 'label' => __( 'Fee Description', 'tutor' ),
1121 'placeholder' => __( 'Fee Description', 'tutor' ),
1122 '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' ),
1123 'maxlength' => 200,
1124 'rows' => 5,
1125 'default' => 'Maintenance Fees',
1126 ),
1127 array(
1128 'key' => 'fee_amount_type',
1129 'type' => 'group_fields',
1130 'label' => __( 'Fee Amount & Type', 'tutor' ),
1131 'desc' => __( 'Select the fee type and add fee amount/percentage', 'tutor' ),
1132 'group_fields' => array(
1133 'fees_type' => array(
1134 'type' => 'select',
1135 'default' => 'fixed',
1136 'select_options' => false,
1137 'options' => array(
1138 'percent' => __( 'Percent', 'tutor' ),
1139 'fixed' => __( 'Fixed', 'tutor' ),
1140 ),
1141 ),
1142 'fees_amount' => array(
1143 'type' => 'number',
1144 'default' => '0',
1145 ),
1146 ),
1147 ),
1148 ),
1149 ),
1150 'block_withdraw' => array(
1151 'label' => __( 'Withdraw', 'tutor' ),
1152 'slug' => 'withdraw',
1153 'block_type' => 'uniform',
1154 'fields' => array(
1155 array(
1156 'key' => 'min_withdraw_amount',
1157 'type' => 'number',
1158 'label' => __( 'Minimum Withdrawal Amount', 'tutor' ),
1159 'default' => '80',
1160 'desc' => __( 'Instructors should earn equal or above this amount to make a withdraw request.', 'tutor' ),
1161 ),
1162 array(
1163 'key' => 'minimum_days_for_balance_to_be_available',
1164 'type' => 'number',
1165 'number_type' => 'integer',
1166 'label' => __( 'Minimum Days Before Balance is Available', 'tutor' ),
1167 'default' => '7',
1168 'min' => 1,
1169 'desc' => __( 'Any income has to remain this many days in the platform before it is available for withdrawal.', 'tutor' ),
1170 ),
1171 array(
1172 'key' => 'tutor_withdrawal_methods',
1173 'type' => 'checkbox_horizontal',
1174 'label' => __( 'Enable Withdraw Method', 'tutor' ),
1175 'default' => array( 'bank_transfer_withdraw' ),
1176 'options' => $methods_array,
1177 'desc' => __( 'Set how you would like to withdraw money from the website.', 'tutor' ),
1178 ),
1179 array(
1180 'key' => 'tutor_bank_transfer_withdraw_instruction',
1181 'type' => 'textarea',
1182 'label' => __( 'Bank Instructions', 'tutor' ),
1183 'default' => __( 'Write the up to date bank informations of your instructor here.', 'tutor' ),
1184 'desc' => __( 'Write bank instructions for the instructors to conduct withdrawals.', 'tutor' ),
1185 ),
1186 ),
1187 ),
1188 ),
1189 ),
1190 'design' => array(
1191 'label' => __( 'Design', 'tutor' ),
1192 'slug' => 'design',
1193 'desc' => __( 'Design Settings', 'tutor' ),
1194 'template' => 'design',
1195 'icon' => 'tutor-icon-color-palette',
1196 'blocks' => array(
1197 'block_course' => array(
1198 'label' => __( 'Course', 'tutor' ),
1199 'slug' => 'course',
1200 'block_type' => 'uniform',
1201 'fields' => array(
1202 array(
1203 'key' => 'courses_col_per_row',
1204 'type' => 'radio_horizontal',
1205 'label' => __( 'Column Per Row', 'tutor' ),
1206 'default' => '3',
1207 'options' => array(
1208 '1' => __( 'One', 'tutor' ),
1209 '2' => __( 'Two', 'tutor' ),
1210 '3' => __( 'Three', 'tutor' ),
1211 '4' => __( 'Four', 'tutor' ),
1212 ),
1213 'desc' => __( 'Define how many columns you want to use to display courses.', 'tutor' ),
1214 ),
1215 array(
1216 'key' => 'course_archive_filter',
1217 'type' => 'toggle_switch',
1218 'label' => __( 'Course Filter', 'tutor' ),
1219 'label_title' => '',
1220 'default' => 'off',
1221 'desc' => __( 'Show sorting and filtering options on course archive page', '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' => 'supported_course_filters',
1233 'type' => 'checkbox_horizontal',
1234 'label' => __( 'Preferred Course Filters', 'tutor' ),
1235 'default' => array( 'search', 'category' ),
1236 'options' => array(
1237 'search' => __( 'Keyword Search', 'tutor' ),
1238 'category' => __( 'Category', 'tutor' ),
1239 'tag' => __( 'Tag', 'tutor' ),
1240 'difficulty_level' => __( 'Difficulty Level', 'tutor' ),
1241 'price_type' => __( 'Price Type', 'tutor' ),
1242 ),
1243 'desc' => __( 'Choose preferred filter options you\'d like to show on the course archive page.', 'tutor' ),
1244 ),
1245 array(
1246 'key' => 'course_archive_filter_sorting',
1247 'type' => 'toggle_switch',
1248 'label' => __( 'Course Sorting', 'tutor' ),
1249 'label_title' => '',
1250 'default' => 'on',
1251 'desc' => __( 'If enabled, the courses will be sortable by Course Name or Creation Date in either Ascending or Descending order', 'tutor' ),
1252 ),
1253 ),
1254 ),
1255 'layout' => array(
1256 'label' => __( 'Layout', 'tutor' ),
1257 'slug' => 'layout',
1258 'block_type' => 'uniform',
1259 'fields' => array(
1260 array(
1261 'key' => 'instructor_list_layout',
1262 'type' => 'group_radio',
1263 'label' => __( 'Instructor List Layout', 'tutor' ),
1264 'desc' => __( 'Choose a layout for the list of instructors inside a course page. You can change this at any time.', 'tutor' ),
1265 'default' => 'portrait',
1266 'group_options' => array(
1267 'vertical' => array(
1268 'default' => array(
1269 'title' => __( 'Portrait', 'tutor' ),
1270 'image' => 'instructor-layout/instructor-portrait.svg',
1271 ),
1272 'cover' => array(
1273 'title' => __( 'Cover', 'tutor' ),
1274 'image' => 'instructor-layout/instructor-cover.svg',
1275 ),
1276 'minimal' => array(
1277 'title' => __( 'Minimal', 'tutor' ),
1278 'image' => 'instructor-layout/instructor-minimal.svg',
1279 ),
1280 ),
1281 'horizontal' => array(
1282 'portrait-horizontal' => array(
1283 'title' => __( 'Portrait Horizontal', 'tutor' ),
1284 'image' => 'instructor-layout/instructor-horizontal-portrait.svg',
1285 ),
1286 'minimal-horizontal' => array(
1287 'title' => __( 'Minimal Horizontal', 'tutor' ),
1288 'image' => 'instructor-layout/instructor-horizontal-minimal.svg',
1289 ),
1290 ),
1291 ),
1292 ),
1293 array(
1294 'key' => 'public_profile_layout',
1295 'type' => 'group_radio_full_3',
1296 'label' => __( 'Instructor Public Profile Layout', 'tutor' ),
1297 'desc' => __( 'Choose a layout design for a instructor’s public profile', 'tutor' ),
1298 'default' => 'pp-rectangle',
1299 'group_options' => array(
1300 'private' => array(
1301 'title' => __( 'Private', 'tutor' ),
1302 'image' => 'profile-layout/profile-private.svg',
1303 ),
1304 'pp-circle' => array(
1305 'title' => __( 'Modern', 'tutor' ),
1306 'image' => 'profile-layout/profile-modern.svg',
1307 ),
1308 'no-cp' => array(
1309 'title' => __( 'Minimal', 'tutor' ),
1310 'image' => 'profile-layout/profile-minimal.svg',
1311 ),
1312 'pp-rectangle' => array(
1313 'title' => __( 'Classic', 'tutor' ),
1314 'image' => 'profile-layout/profile-classic.svg',
1315 ),
1316 ),
1317 ),
1318 array(
1319 'key' => 'student_public_profile_layout',
1320 'type' => 'group_radio_full_3',
1321 'label' => __( 'Student Public Profile Layout', 'tutor' ),
1322 'desc' => __( 'Choose a layout design for a student’s public profile', 'tutor' ),
1323 'default' => 'pp-rectangle',
1324 'group_options' => array(
1325 'private' => array(
1326 'title' => __( 'Private', 'tutor' ),
1327 'image' => 'profile-layout/profile-private.svg',
1328 ),
1329 'pp-circle' => array(
1330 'title' => __( 'Modern', 'tutor' ),
1331 'image' => 'profile-layout/profile-modern.svg',
1332 ),
1333 'no-cp' => array(
1334 'title' => __( 'Minimal', 'tutor' ),
1335 'image' => 'profile-layout/profile-minimal.svg',
1336 ),
1337 'pp-rectangle' => array(
1338 'title' => __( 'Classic', 'tutor' ),
1339 'image' => 'profile-layout/profile-classic.svg',
1340 ),
1341 ),
1342 ),
1343 ),
1344 ),
1345 'course-details' => array(
1346 'label' => __( 'Course Details', 'tutor' ),
1347 'slug' => 'course-details',
1348 'block_type' => 'isolate',
1349 'fields' => array(
1350 array(
1351 'key' => 'course_details_adjustments',
1352 'type' => 'checkgroup',
1353 'label' => __( 'Page Features', 'tutor' ),
1354 'desc' => __( 'You can keep the following features active or inactive as per the need of your business model', 'tutor' ),
1355 'group_options' => array(
1356 array(
1357 'key' => 'display_course_instructors',
1358 'type' => 'toggle_single',
1359 'label' => __( 'Instructor Info', 'tutor' ),
1360 'default' => 'on',
1361 'desc' => __( 'Toggle to show instructor info', 'tutor' ),
1362 ),
1363 array(
1364 'key' => 'enable_q_and_a_on_course',
1365 'type' => 'toggle_single',
1366 'label' => __( 'Q&A', 'tutor' ),
1367 'default' => 'on',
1368 'desc' => __( 'Enable to add a Q&A section', 'tutor' ),
1369 ),
1370 array(
1371 'key' => 'enable_course_author',
1372 'type' => 'toggle_single',
1373 'label' => __( 'Author', 'tutor' ),
1374 'label_title' => __( 'Enable', 'tutor' ),
1375 'default' => 'off',
1376 'desc' => __( 'Enable to show course author name', 'tutor' ),
1377 ),
1378 array(
1379 'key' => 'enable_course_level',
1380 'type' => 'toggle_single',
1381 'label' => __( 'Level', 'tutor' ),
1382 'label_title' => __( 'Enable', 'tutor' ),
1383 'default' => 'on',
1384 'desc' => __( 'Enable to show course level', 'tutor' ),
1385 ),
1386 array(
1387 'key' => 'enable_course_share',
1388 'type' => 'toggle_single',
1389 'label' => __( 'Social Share', 'tutor' ),
1390 'label_title' => __( 'Enable', 'tutor' ),
1391 'default' => 'on',
1392 'desc' => __( 'Toggle to enable course social share', 'tutor' ),
1393 ),
1394 array(
1395 'key' => 'enable_course_duration',
1396 'type' => 'toggle_single',
1397 'label' => __( 'Duration', 'tutor' ),
1398 'label_title' => __( 'Disable', 'tutor' ),
1399 'default' => 'on',
1400 'desc' => __( 'Enable to show course duration', 'tutor' ),
1401 ),
1402 array(
1403 'key' => 'enable_course_total_enrolled',
1404 'type' => 'toggle_single',
1405 'label' => __( 'Total Enrolled', 'tutor' ),
1406 'label_title' => __( 'Enable', 'tutor' ),
1407 'default' => 'on',
1408 'desc' => __( 'Enable to show total enrolled students', 'tutor' ),
1409 ),
1410 array(
1411 'key' => 'enable_course_update_date',
1412 'type' => 'toggle_single',
1413 'label' => __( 'Update Date', 'tutor' ),
1414 'label_title' => __( 'Enable', 'tutor' ),
1415 'default' => 'on',
1416 'desc' => __( 'Enable to show course update information', 'tutor' ),
1417 ),
1418 array(
1419 'key' => 'enable_course_progress_bar',
1420 'type' => 'toggle_single',
1421 'label' => __( 'Progress Bar', 'tutor' ),
1422 'label_title' => __( 'Enable', 'tutor' ),
1423 'default' => 'on',
1424 'desc' => __( 'Enable to show course progress for Students', 'tutor' ),
1425 ),
1426 array(
1427 'key' => 'enable_course_material',
1428 'type' => 'toggle_single',
1429 'label' => __( 'Material', 'tutor' ),
1430 'label_title' => __( 'Enable', 'tutor' ),
1431 'default' => 'on',
1432 'desc' => __( 'Enable to show course materials', 'tutor' ),
1433 ),
1434 array(
1435 'key' => 'enable_course_about',
1436 'type' => 'toggle_single',
1437 'label' => __( 'About', 'tutor' ),
1438 'label_title' => __( 'Enable', 'tutor' ),
1439 'default' => 'on',
1440 'desc' => __( 'Enable to show course about section', 'tutor' ),
1441 ),
1442 array(
1443 'key' => 'enable_course_description',
1444 'type' => 'toggle_single',
1445 'label' => __( 'Description', 'tutor' ),
1446 'label_title' => __( 'Enable', 'tutor' ),
1447 'default' => 'on',
1448 'desc' => __( 'Enable to show course description', 'tutor' ),
1449 ),
1450 array(
1451 'key' => 'enable_course_benefits',
1452 'type' => 'toggle_single',
1453 'label' => __( 'Benefits', 'tutor' ),
1454 'label_title' => __( 'Enable', 'tutor' ),
1455 'default' => 'on',
1456 'desc' => __( 'Enable to show course benefits section', 'tutor' ),
1457 ),
1458 array(
1459 'key' => 'enable_course_requirements',
1460 'type' => 'toggle_single',
1461 'label' => __( 'Requirements', 'tutor' ),
1462 'label_title' => __( 'Enable', 'tutor' ),
1463 'default' => 'on',
1464 'desc' => __( 'Enable to show courses requirements section', 'tutor' ),
1465 ),
1466 array(
1467 'key' => 'enable_course_target_audience',
1468 'type' => 'toggle_single',
1469 'label' => __( 'Target Audience', 'tutor' ),
1470 'label_title' => __( 'Disable', 'tutor' ),
1471 'default' => 'on',
1472 'desc' => __( 'Enable to show course target audience section', 'tutor' ),
1473 ),
1474 array(
1475 'key' => 'enable_course_announcements',
1476 'type' => 'toggle_single',
1477 'label' => __( 'Announcements', 'tutor' ),
1478 'label_title' => __( 'Enable', 'tutor' ),
1479 'default' => 'on',
1480 'desc' => __( 'Enable to show course announcements section', 'tutor' ),
1481 ),
1482 array(
1483 'key' => 'enable_course_review',
1484 'type' => 'toggle_single',
1485 'label' => __( 'Review', 'tutor' ),
1486 'label_title' => __( 'Enable', 'tutor' ),
1487 'default' => 'on',
1488 'desc' => __( 'Enable to show course review section', 'tutor' ),
1489 ),
1490 ),
1491 ),
1492 ),
1493 ),
1494 'colors' => array(
1495 'label' => __( 'Colors', 'tutor' ),
1496 'slug' => 'colors',
1497 'block_type' => 'color_picker',
1498 'fields_group' => array(
1499 array(
1500 'key' => 'color_preset_type',
1501 'type' => 'color_preset',
1502 'label' => __( 'Preset Colors', 'tutor' ),
1503 'desc' => __( 'These colors will be used throughout your website. Choose between these presets or create your own custom palette.', 'tutor' ),
1504 'default' => 'default',
1505 'fields' => array(
1506 /* First 4 preset_name should be same as color_fields */
1507 array(
1508 'key' => 'default',
1509 'label' => __( 'Default', 'tutor' ),
1510 'colors' => array(
1511 array(
1512 'slug' => 'tutor_primary_color',
1513 'preset_name' => 'primary',
1514 'value' => '#3E64DE',
1515 ),
1516 array(
1517 'slug' => 'tutor_primary_hover_color',
1518 'preset_name' => 'hover',
1519 'value' => '#395BCA',
1520 ),
1521 array(
1522 'slug' => 'tutor_text_color',
1523 'preset_name' => 'text',
1524 'value' => '#212327',
1525 ),
1526 array(
1527 'slug' => 'tutor_gray_color',
1528 'preset_name' => 'gray',
1529 'value' => '#E3E5EB',
1530 ),
1531 array(
1532 'slug' => 'tutor_border_color',
1533 'preset_name' => 'border',
1534 'value' => '#CDCFD5',
1535 ),
1536 ),
1537 ),
1538 array(
1539 'key' => 'landscape',
1540 'label' => __( 'Landscape', 'tutor' ),
1541 'colors' => array(
1542 array(
1543 'slug' => 'tutor_primary_color',
1544 'preset_name' => 'primary',
1545 'value' => '#239371',
1546 ),
1547 array(
1548 'slug' => 'tutor_primary_hover_color',
1549 'preset_name' => 'hover',
1550 'value' => '#117D5D',
1551 ),
1552 array(
1553 'slug' => 'tutor_text_color',
1554 'preset_name' => 'text',
1555 'value' => '#212327',
1556 ),
1557 array(
1558 'slug' => 'tutor_gray_color',
1559 'preset_name' => 'gray',
1560 'value' => '#E3E5EB',
1561 ),
1562 array(
1563 'slug' => 'tutor_border_color',
1564 'preset_name' => 'border',
1565 'value' => '#CDCFD5',
1566 ),
1567 ),
1568 ),
1569 array(
1570 'key' => 'ocean',
1571 'label' => __( 'Ocean', 'tutor' ),
1572 'colors' => array(
1573 array(
1574 'slug' => 'tutor_primary_color',
1575 'preset_name' => 'primary',
1576 'value' => '#5A18C2',
1577 ),
1578 array(
1579 'slug' => 'tutor_primary_hover_color',
1580 'preset_name' => 'hover',
1581 'value' => '#3F02A0',
1582 ),
1583 array(
1584 'slug' => 'tutor_text_color',
1585 'preset_name' => 'text',
1586 'value' => '#212327',
1587 ),
1588 array(
1589 'slug' => 'tutor_gray_color',
1590 'preset_name' => 'gray',
1591 'value' => '#E3E5EB',
1592 ),
1593 array(
1594 'slug' => 'tutor_border_color',
1595 'preset_name' => 'border',
1596 'value' => '#CDCFD5',
1597 ),
1598 ),
1599 ),
1600 array(
1601 'key' => 'custom',
1602 'label' => __( 'Custom', 'tutor' ),
1603 'colors' => array(
1604 array(
1605 'slug' => 'tutor_primary_color',
1606 'preset_name' => 'primary',
1607 'value' => '#3E64DE',
1608 ),
1609 array(
1610 'slug' => 'tutor_primary_hover_color',
1611 'preset_name' => 'hover',
1612 'value' => '#28408E',
1613 ),
1614 array(
1615 'slug' => 'tutor_text_color',
1616 'preset_name' => 'text',
1617 'value' => '#1A1B1E',
1618 ),
1619 array(
1620 'slug' => 'tutor_gray_color',
1621 'preset_name' => 'gray',
1622 'value' => '#E3E5EB',
1623 ),
1624 array(
1625 'slug' => 'tutor_border_color',
1626 'preset_name' => 'border',
1627 'value' => '#CDCFD5',
1628 ),
1629 ),
1630 ),
1631 ),
1632 ),
1633 array(
1634 'key' => 'tutor_color_presets',
1635 'type' => 'color_fields',
1636 'label' => __( 'Preset Colors', 'tutor' ),
1637 'fields' => array(
1638 array(
1639 'key' => 'tutor_primary_color',
1640 'type' => 'color_field',
1641 'preset_name' => 'primary',
1642 'preset_exist' => true,
1643 'label' => __( 'Primary Color', 'tutor' ),
1644 'default' => '#3E64DE',
1645 'desc' => __( 'Choose a primary color', 'tutor' ),
1646 ),
1647 array(
1648 'key' => 'tutor_primary_hover_color',
1649 'type' => 'color_field',
1650 'preset_name' => 'hover',
1651 'preset_exist' => true,
1652 'label' => __( 'Primary Hover Color', 'tutor' ),
1653 'default' => '#395BCA',
1654 'desc' => __( 'Choose a primary hover color', 'tutor' ),
1655 ),
1656 array(
1657 'key' => 'tutor_text_color',
1658 'type' => 'color_field',
1659 'preset_name' => 'text',
1660 'preset_exist' => true,
1661 'label' => __( 'Text Color', 'tutor' ),
1662 'default' => '#212327',
1663 'desc' => __( 'Choose a text color for your website', 'tutor' ),
1664 ),
1665 array(
1666 'key' => 'tutor_gray_color',
1667 'type' => 'color_field',
1668 'preset_name' => 'gray',
1669 'preset_exist' => false,
1670 'label' => __( 'Gray', 'tutor' ),
1671 'default' => '#E3E5EB',
1672 'desc' => __( 'Choose a color for elements like table, card etc', 'tutor' ),
1673 ),
1674 array(
1675 'key' => 'tutor_border_color',
1676 'type' => 'color_field',
1677 'preset_name' => 'border',
1678 'preset_exist' => false,
1679 'label' => __( 'Border', 'tutor' ),
1680 'default' => '#CDCFD5',
1681 'desc' => __( 'Choose a border color for your website', 'tutor' ),
1682 ),
1683 ),
1684 ),
1685 ),
1686 ),
1687 ),
1688 ),
1689 'advanced' => array(
1690 'label' => __( 'Advanced', 'tutor' ),
1691 'slug' => 'advanced',
1692 'desc' => __( 'Advanced Settings', 'tutor' ),
1693 'template' => 'basic',
1694 'icon' => 'tutor-icon-filter',
1695 'blocks' => array(
1696 array(
1697 'label' => __( 'Course', 'tutor' ),
1698 'slug' => 'options',
1699 'block_type' => 'uniform',
1700 'fields' => array(
1701 array(
1702 'key' => 'enable_gutenberg_course_edit',
1703 'type' => 'toggle_switch',
1704 'label' => __( 'Gutenberg Editor', 'tutor' ),
1705 'default' => 'off',
1706 'desc' => __( 'Enable this to create courses using the Gutenberg Editor.', 'tutor' ),
1707 ),
1708 array(
1709 'key' => 'hide_course_from_shop_page',
1710 'type' => 'toggle_switch',
1711 'label' => __( 'Hide Course Products on Shop Page', 'tutor' ),
1712 'default' => 'off',
1713 'desc' => __( 'Enable to hide course products on shop page.', 'tutor' ),
1714 ),
1715 array(
1716 'key' => 'course_archive_page',
1717 'type' => 'select',
1718 'label' => __( 'Course Archive Page', 'tutor' ),
1719 'default' => $course_archive_page_id->ID ?? '0',
1720 'options' => $pages,
1721 'desc' => __( 'This page will be used to list all the published courses.', 'tutor' ),
1722 'searchable' => true,
1723 ),
1724 array(
1725 'key' => 'instructor_register_page',
1726 'type' => 'select',
1727 'label' => __( 'Instructor Registration Page', 'tutor' ),
1728 'default' => '0',
1729 'options' => $pages,
1730 'desc' => __( 'Choose the page for instructor registration.', 'tutor' ),
1731 'searchable' => true,
1732 ),
1733 array(
1734 'key' => 'student_register_page',
1735 'type' => 'select',
1736 'label' => __( 'Student Registration Page', 'tutor' ),
1737 'default' => '0',
1738 'options' => $pages,
1739 'desc' => __( 'Choose the page for student registration.', 'tutor' ),
1740 'searchable' => true,
1741 ),
1742 array(
1743 'key' => 'lesson_video_duration_youtube_api_key',
1744 'type' => 'text',
1745 'label' => __( 'YouTube API Key', 'tutor' ),
1746 'default' => '',
1747 'desc' => __(
1748 'To host live videos on your platform using YouTube, enter your YouTube API key.',
1749 'tutor'
1750 ),
1751 'placeholder' => __( 'Insert API key here', 'tutor' ),
1752 ),
1753 ),
1754 ),
1755 array(
1756 'label' => __( 'Base Permalink', 'tutor' ),
1757 'slug' => 'base_permalink',
1758 'block_type' => 'uniform',
1759 'fields' => array(
1760 array(
1761 'key' => 'course_permalink_base',
1762 'type' => 'text',
1763 'label' => __( 'Course Permalink', 'tutor' ),
1764 'default' => 'courses',
1765 'desc' => $course_url,
1766 ),
1767 array(
1768 'key' => 'lesson_permalink_base',
1769 'type' => 'text',
1770 'label' => __( 'Lesson Permalink', 'tutor' ),
1771 'default' => 'lessons',
1772 'desc' => $lesson_url,
1773 ),
1774 array(
1775 'key' => 'quiz_permalink_base',
1776 'type' => 'text',
1777 'label' => __( 'Quiz Permalink', 'tutor' ),
1778 'default' => 'quizzes',
1779 'desc' => $quiz_url,
1780 ),
1781 ),
1782 ),
1783 array(
1784 'label' => __( 'Options', 'tutor' ),
1785 'slug' => 'options',
1786 'block_type' => 'uniform',
1787 'fields' => array(
1788 array(
1789 'key' => 'enable_profile_completion',
1790 'type' => 'toggle_switch',
1791 'label' => __( 'Profile Completion', 'tutor' ),
1792 'label_title' => '',
1793 'default' => 'off',
1794 'desc' => __( 'Enabling this feature will show a notification bar to students and instructors to complete their profile information', 'tutor' ),
1795 ),
1796 array(
1797 'key' => 'enable_tutor_native_login',
1798 'type' => 'toggle_switch',
1799 'label' => __( 'Enable Tutor LMS Login', 'tutor' ),
1800 'label_title' => '',
1801 'default' => 'on',
1802 'desc' => __( 'Enable to use the Tutor LMS native login system instead of the WordPress login page', 'tutor' ),
1803 ),
1804 array(
1805 'key' => 'delete_on_uninstall',
1806 'type' => 'toggle_switch',
1807 'label' => __( 'Erase upon uninstallation', 'tutor' ),
1808 'label_title' => '',
1809 'default' => 'off',
1810 'desc' => __( 'Delete all data during uninstallation', 'tutor' ),
1811 ),
1812 array(
1813 'key' => 'enable_tutor_maintenance_mode',
1814 'type' => 'toggle_switch',
1815 'label' => __( 'Maintenance Mode', 'tutor' ),
1816 'label_title' => '',
1817 'default' => 'off',
1818 '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' ),
1819 ),
1820 ),
1821 ),
1822 ),
1823 ),
1824 );
1825
1826 $attrs = apply_filters( 'tutor/options/extend/attr', apply_filters( 'tutor/options/attr', $attr ) );
1827
1828 // Get the active tab.
1829 $tab_page = tutor_utils()->array_get( 'tab_page', $_REQUEST, 'general' );
1830 $tab_data = null;
1831 $template = null;
1832
1833 foreach ( $attrs as $key => $section ) {
1834 if ( $tab_page == $key ) {
1835 if ( isset( $section['template_path'] ) && $section['template_path'] ) {
1836 $template = $section['template_path'];
1837 $tab_data = $section;
1838 }
1839 break;
1840 }
1841 }
1842
1843 // Store in runtime cache.
1844 $this->setting_fields = array(
1845 'option_fields' => $attrs,
1846 'active_tab' => $tab_page,
1847 'active_tab_data' => $tab_data,
1848 'template_path' => $template,
1849 );
1850
1851 return $this->setting_fields;
1852 }
1853
1854 /**
1855 * Generate field
1856 *
1857 * @since 2.0.0
1858 *
1859 * @param array $field field array.
1860 * @param array $blocks blocks array.
1861 *
1862 * @return void
1863 *
1864 * Generate Option Field
1865 */
1866 public function generate_field( $field = array(), $blocks = array() ) {
1867 ob_start();
1868 if ( isset( $field['type'] ) ) {
1869 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1870 }
1871 echo ob_get_clean();//phpcs:ignore
1872 }
1873
1874 /**
1875 * Include field type template & return buffered
1876 * string data.
1877 *
1878 * @since 2.0.0
1879 *
1880 * @param array $field field.
1881 *
1882 * @return string
1883 */
1884 public function field_type( $field = array() ) {
1885 ob_start();
1886 if ( isset( $field['type'] ) ) {
1887 include tutor()->path . "views/options/field-types/{$field['type']}.php";
1888 }
1889 return ob_get_clean();
1890 }
1891
1892 /**
1893 * Include Option blocks template & return
1894 * buffered string data.
1895 *
1896 * @since 2.0.0
1897 *
1898 * @param array $blocks blocks.
1899 *
1900 * @return string
1901 */
1902 public function blocks( $blocks = array() ) {
1903 ob_start();
1904 include apply_filters( 'tutor_settings_block_template_path', tutor()->path . 'views/options/option_blocks.php', $blocks );
1905 return ob_get_clean();
1906 }
1907
1908 /**
1909 * Include options template & returns
1910 * buffered string data.
1911 *
1912 * @since 2.0.0
1913 *
1914 * @param array $section section.
1915 *
1916 * @return string
1917 */
1918 public function template( $section = array() ) {
1919 ob_start();
1920 $blocks = $section['blocks'];
1921 if ( isset( $section['template'] ) ) {
1922 include apply_filters( 'tutor_option_template_path', tutor()->path . "views/options/template/{$section['template']}.php", $section['template'] );
1923 }
1924 return ob_get_clean();
1925 }
1926
1927
1928 /**
1929 * Load template inside template directory
1930 *
1931 * @since 2.0.0
1932 *
1933 * @param mixed $template_slug template slug.
1934 * @param mixed $section section.
1935 *
1936 * @return string
1937 */
1938 public function view_template( $template_slug, $section = array() ) {
1939 ob_start();
1940 if ( isset( $template_slug ) ) {
1941 require tutor()->path . "views/options/template/{$template_slug}";
1942 }
1943 return ob_get_clean();
1944 }
1945
1946 /**
1947 * Get field name
1948 *
1949 * It's useful when a field has event key like course.lessons
1950 *
1951 * @since 3.5.0
1952 *
1953 * @param array $field Option field array.
1954 *
1955 * @return string
1956 */
1957 public function get_field_name( array $field ) {
1958 $events = $field['event'] ?? null;
1959 $field_name = 'tutor_option';
1960 if ( $events ) {
1961 $events = explode( '.', $events );
1962 foreach ( $events as $event ) {
1963 $field_name .= '[' . $event . ']';
1964 }
1965 $field_name .= '[' . $field['key'] . ']';
1966 } else {
1967 $field_name .= '[' . $field['key'] . ']';
1968 }
1969
1970 return $field_name;
1971 }
1972
1973 /**
1974 * Json schema data
1975 *
1976 * @since 1.0.0
1977 *
1978 * @return array
1979 */
1980 public function get_export_json_schema() {
1981 $export_data = array(
1982 'schema_version' => '1.0.0',
1983 'exported_at' => current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ),
1984 'keep_media_files' => false,
1985 'data' => array(),
1986 );
1987
1988 return $export_data;
1989 }
1990
1991 /**
1992 * Update settings log based on the new data
1993 *
1994 * @since 3.6.0
1995 *
1996 * @param array $new_settings_data New exported/import settings data.
1997 * @param string $action_type Action type Imported/Exported.
1998 *
1999 * @return array Settings log data
2000 */
2001 public function update_settings_log( $new_settings_data, $action_type ) {
2002 $get_final_data = array();
2003
2004 $action = strtolower( $action_type );
2005
2006 $time = tutor_time();
2007
2008 $save_import_data['datetime'] = $time;
2009 $save_import_data['history_date'] = gmdate( 'j M, Y, g:i a', $time );
2010 $save_import_data['datatype'] = $action_type;
2011 $save_import_data['dataset'] = $new_settings_data;
2012 $import_data[ 'tutor-imported-' . $time ] = $save_import_data;
2013
2014 $get_option_data = get_option( 'tutor_settings_log' );
2015 if ( empty( $get_option_data ) ) {
2016 $get_option_data = array();
2017 }
2018 if ( ! empty( $get_option_data ) && null !== $save_import_data['dataset'] ) {
2019
2020 $update_option = array_merge( $import_data, $get_option_data );
2021
2022 $update_option = tutor_utils()->sanitize_recursively( $update_option );
2023
2024 if ( ! empty( $update_option ) ) {
2025 update_option( 'tutor_settings_log', $update_option );
2026 }
2027
2028 if ( 'imported' === $action ) {
2029 if ( ! empty( $save_import_data ) ) {
2030 update_option( 'tutor_option', $save_import_data['dataset'] );
2031 }
2032 }
2033
2034 $get_final_data = get_option( 'tutor_settings_log' );
2035
2036 } else {
2037 if ( ! empty( $import_data ) ) {
2038 update_option( 'tutor_settings_log', $import_data );
2039 }
2040
2041 if ( 'imported' === $action ) {
2042 if ( ! empty( $save_import_data ) ) {
2043 update_option( 'tutor_option', $save_import_data['dataset'] );
2044 }
2045 }
2046
2047 $get_final_data = get_option( 'tutor_settings_log' );
2048 }
2049
2050 return $get_final_data;
2051 }
2052 }
2053