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