PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / admin / views / meta-boxes / course / settings.php

settings.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9, at inc/admin/views/meta-boxes/course/settings.php

736 lines 23.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class LP_Meta_Box_Course extends LP_Meta_Box {
4 /**
5 * Instance
6 *
7 * @var null|LP_Meta_Box_Course
8 */
9 private static $instance = null;
10
11 public $post_type = LP_COURSE_CPT;
12
13 public function add_meta_box() {
14 add_meta_box( 'course-settings', esc_html__( 'Course Settings', 'learnpress' ), array( $this, 'output' ), $this->post_type, 'normal', 'high' );
15 }
16
17 public function metabox( $post_id ) {
18 $tabs = apply_filters(
19 'lp_course_data_settings_tabs',
20 array(
21 'general' => array(
22 'label' => esc_html__( 'General', 'learnpress' ),
23 'target' => 'general_course_data',
24 'icon' => 'dashicons-admin-tools',
25 'priority' => 10,
26 'content' => $this->general( $post_id ),
27 ),
28 'price' => array(
29 'label' => esc_html__( 'Pricing', 'learnpress' ),
30 'target' => 'price_course_data',
31 'icon' => 'dashicons-cart',
32 'priority' => 20,
33 'content' => $this->lp_price( $post_id ),
34 ),
35 'extra' => array(
36 'label' => esc_html__( 'Extra Information', 'learnpress' ),
37 'target' => 'extra_course_data',
38 'icon' => 'dashicons-excerpt-view',
39 'priority' => 30,
40 'content' => $this->extra( $post_id ),
41 ),
42 'assessment' => array(
43 'label' => esc_html__( 'Assessment', 'learnpress' ),
44 'target' => 'assessment_course_data',
45 'icon' => 'dashicons-awards',
46 'priority' => 40,
47 'content' => $this->assessment( $post_id ),
48 ),
49 'author' => array(
50 'label' => esc_html__( 'Author', 'learnpress' ),
51 'target' => 'author_course_data',
52 'icon' => 'dashicons-businessman',
53 'priority' => 50,
54 'content' => $this->author( $post_id ),
55 ),
56 )
57 );
58
59 $tabs = apply_filters( 'learnpress/course/metabox/tabs', $tabs, $post_id );
60
61 uasort( $tabs, array( __CLASS__, 'data_tabs_sort' ) );
62
63 return $tabs;
64 }
65
66 public function general( $thepostid ) {
67 $repurchase_option_desc = sprintf( '1. %s', __( 'Reset course progress: The course progress and results of student will be removed.' ) );
68 $repurchase_option_desc .= '<br/>' . sprintf( '2. %s', __( 'Keep course progress: The course progress and results of student will remain.' ) );
69 $repurchase_option_desc .= '<br/>' . sprintf( '3. %s', __( 'Open popup: The student can decide whether their course progress will be reset with the confirm popup.' ) );
70
71 return apply_filters(
72 'lp/course/meta-box/fields/general',
73 array(
74 '_lp_duration' => new LP_Meta_Box_Duration_Field(
75 esc_html__( 'Duration', 'learnpress' ),
76 esc_html__( 'Set 0 for lifetime access.', 'learnpress' ),
77 '10',
78 array(
79 'default_time' => 'week',
80 'custom_attributes' => array(
81 'min' => '0',
82 'step' => '1',
83 ),
84 )
85 ),
86 '_lp_block_expire_duration' => new LP_Meta_Box_Checkbox_Field(
87 esc_html__( 'Block content', 'learnpress' ),
88 esc_html__( 'Block course when duration expires.', 'learnpress' ),
89 'no'
90 ),
91 '_lp_block_finished' => new LP_Meta_Box_Checkbox_Field(
92 '',
93 esc_html__( 'Block course after student finished this course.', 'learnpress' ),
94 'yes'
95 ),
96 '_lp_allow_course_repurchase' => new LP_Meta_Box_Checkbox_Field(
97 __( 'Allow Repurchase', 'learnpress' ),
98 esc_html__( 'Allow users to repurchase this course after course finished or blocked ( Do not apply to free courses ).', 'learnpress' ),
99 'no'
100 ),
101 '_lp_course_repurchase_option' => new LP_Meta_Box_Select_Field(
102 esc_html__( 'Repurchase action', 'learnpress' ),
103 $repurchase_option_desc,
104 'reset',
105 array(
106 'options' => array(
107 'reset' => esc_html__( 'Reset course progress', 'learnpress' ),
108 'keep' => esc_html__( 'Keep course progress', 'learnpress' ),
109 'popup' => esc_html__( 'Open popup', 'learnpress' ),
110 ),
111 'show' => array( '_lp_allow_course_repurchase', '=', 'yes' ), // use 'show' or 'hide'
112 )
113 ),
114 '_lp_level' => new LP_Meta_Box_Select_Field(
115 esc_html__( 'Level', 'learnpress' ),
116 esc_html__( 'Choose a difficulty level.', 'learnpress' ),
117 '',
118 array(
119 'options' => lp_course_level(),
120 )
121 ),
122 '_lp_students' => new LP_Meta_Box_Text_Field(
123 esc_html__( 'Fake Students Enrolled', 'learnpress' ),
124 esc_html__( 'How many students have taken this course', 'learnpress' ),
125 0,
126 array(
127 'type_input' => 'number',
128 'custom_attributes' => array(
129 'min' => '0',
130 'step' => '1',
131 ),
132 'style' => 'width: 70px;',
133 )
134 ),
135 '_lp_max_students' => new LP_Meta_Box_Text_Field(
136 esc_html__( 'Max student', 'learnpress' ),
137 esc_html__( 'Maximum students can join the course. Set 0 for unlimited.', 'learnpress' ),
138 0,
139 array(
140 'type_input' => 'number',
141 'custom_attributes' => array(
142 'min' => '0',
143 'step' => '1',
144 ),
145 'style' => 'width: 70px;',
146 )
147 ),
148 '_lp_retake_count' => new LP_Meta_Box_Text_Field(
149 esc_html__( 'Re-take Course', 'learnpress' ),
150 esc_html__( 'The number of times a user can learn again this course. Set 0 to disable.', 'learnpress' ),
151 0,
152 array(
153 'type_input' => 'number',
154 'custom_attributes' => array(
155 'min' => '0',
156 'step' => '1',
157 ),
158 'style' => 'width: 70px;',
159 )
160 ),
161 '_lp_has_finish' => new LP_Meta_Box_Checkbox_Field(
162 esc_html__( 'Finish button', 'learnpress' ),
163 esc_html__( 'Allow show finish button when the student has completed all items but has not passed the course assessment.', 'learnpress' ),
164 'yes'
165 ),
166 '_lp_featured' => new LP_Meta_Box_Checkbox_Field(
167 esc_html__( 'Featured list', 'learnpress' ),
168 esc_html__( 'Add the course to Featured List.', 'learnpress' ),
169 'no'
170 ),
171 '_lp_featured_review' => new LP_Meta_Box_Textarea_Field(
172 esc_html__( 'Featured review', 'learnpress' ),
173 esc_html__( 'A good review to promote the course.', 'learnpress' )
174 ),
175 '_lp_external_link_buy_course' => new LP_Meta_Box_Text_Field(
176 esc_html__( 'External link', 'learnpress' ),
177 esc_html__( 'Normally use for offline classes, Ex: link to a contact page. Format: https://google.com', 'learnpress' ),
178 '',
179 array(
180 'desc_tip' => 'You can apply for case: user register form.<br> You accept for user can learn courses by add manual order on backend',
181 )
182 ),
183 )
184 );
185 }
186
187 /**
188 * @editor tungnx
189 * @modify 4.1.5 - replace to lp_price function
190 */
191 /*public function price( $thepostid ) {
192 $post = get_post( $thepostid );
193
194 $thepostid = ! empty( $thepostid ) ? $thepostid : absint( $post->ID );
195
196 $message = '';
197 $price = get_post_meta( $thepostid, '_lp_price', true );
198 $payment = get_post_meta( $thepostid, '_lp_payment', true );
199 $sale_price = '';
200 $start_date = '';
201 $end_date = '';
202
203 if ( $payment != 'free' ) {
204 $sale_price = get_post_meta( $thepostid, '_lp_sale_price', true );
205 $start_date = get_post_meta( $thepostid, '_lp_sale_start', true );
206 $end_date = get_post_meta( $thepostid, '_lp_sale_end', true );
207 }
208
209 return apply_filters(
210 'lp/course/meta-box/fields/price',
211 array(
212 '_lp_price' => new LP_Meta_Box_Text_Field(
213 esc_html__( 'Regular price', 'learnpress' ),
214 sprintf( __( 'Set a regular price (<strong>%s</strong>). Leave it blank for <strong>Free</strong>.', 'learnpress' ), learn_press_get_currency() ),
215 $price,
216 array(
217 'type_input' => 'number',
218 'custom_attributes' => array(
219 'min' => '0',
220 'step' => '0.01',
221 ),
222 'style' => 'width: 70px;',
223 'class' => 'lp_meta_box_regular_price',
224 )
225 ),
226 '_lp_sale_price' => new LP_Meta_Box_Text_Field(
227 esc_html__( 'Sale price', 'learnpress' ),
228 '<a href="#" class="lp_sale_price_schedule">' . esc_html__( 'Schedule', 'learnpress' ) . '</a>',
229 $sale_price,
230 array(
231 'type_input' => 'number',
232 'custom_attributes' => array(
233 'min' => '0',
234 'step' => '0.01',
235 ),
236 'style' => 'width: 70px;',
237 'class' => 'lp_meta_box_sale_price',
238 )
239 ),
240 '_lp_sale_start' => new LP_Meta_Box_Date_Field(
241 esc_html__( 'Sale start dates', 'learnpress' ),
242 '',
243 '',
244 array(
245 'wrapper_class' => 'lp_sale_start_dates_fields',
246 'placeholder' => _x( 'From&hellip;', 'placeholder', 'learnpress' ),
247 )
248 ),
249 '_lp_sale_end' => new LP_Meta_Box_Date_Field(
250 esc_html__( 'Sale end dates', 'learnpress' ),
251 '',
252 '',
253 array(
254 'wrapper_class' => 'lp_sale_end_dates_fields',
255 'placeholder' => _x( 'To&hellip;', 'placeholder', 'learnpress' ),
256 'cancel' => true,
257 )
258 ),
259 '_lp_no_required_enroll' => new LP_Meta_Box_Checkbox_Field(
260 esc_html__( 'No requirement enroll', 'learnpress' ),
261 esc_html__( 'Students can see the content of all course items and do the quiz without login.', 'learnpress' ),
262 'no'
263 ),
264 )
265 );
266 }*/
267
268 /**
269 * Setting course price
270 *
271 * @param $post_id
272 *
273 * @author tungnx
274 * @since 4.1.5
275 * @version 1.0.0
276 * @return array
277 */
278 public function lp_price( $post_id ): array {
279 $key_exists = LP_Database::getInstance()->check_key_postmeta_exists( $post_id, '_lp_regular_price' );
280 $price = get_post_meta( $post_id, '_lp_price', true );
281 $regular_price = $key_exists ? get_post_meta( $post_id, '_lp_regular_price', true ) : $price;
282 $sale_price = get_post_meta( $post_id, '_lp_sale_price', true );
283
284 return apply_filters(
285 'lp/course/meta-box/fields/price',
286 array(
287 '_lp_regular_price' => new LP_Meta_Box_Text_Field(
288 esc_html__( 'Regular price', 'learnpress' ),
289 sprintf( __( 'Set a regular price (<strong>%s</strong>). Leave it blank for <strong>Free</strong>.', 'learnpress' ), learn_press_get_currency() ),
290 $regular_price,
291 array(
292 'type_input' => 'number',
293 'custom_attributes' => array(
294 'min' => '0',
295 'step' => '0.01',
296 ),
297 'style' => 'width: 70px;',
298 'class' => 'lp_meta_box_regular_price',
299 )
300 ),
301 '_lp_sale_price' => new LP_Meta_Box_Text_Field(
302 esc_html__( 'Sale price', 'learnpress' ),
303 '<a href="#" class="lp_sale_price_schedule">' . esc_html__( 'Schedule', 'learnpress' ) . '</a>',
304 $sale_price,
305 array(
306 'type_input' => 'number',
307 'custom_attributes' => array(
308 'min' => '0',
309 'step' => '0.01',
310 ),
311 'style' => 'width: 70px;',
312 'class' => 'lp_meta_box_sale_price',
313 )
314 ),
315 '_lp_sale_start' => new LP_Meta_Box_Date_Field(
316 esc_html__( 'Sale start dates', 'learnpress' ),
317 '',
318 '',
319 array(
320 'wrapper_class' => 'lp_sale_start_dates_fields',
321 'placeholder' => _x( 'From&hellip;', 'placeholder', 'learnpress' ),
322 )
323 ),
324 '_lp_sale_end' => new LP_Meta_Box_Date_Field(
325 esc_html__( 'Sale end dates', 'learnpress' ),
326 '',
327 '',
328 array(
329 'wrapper_class' => 'lp_sale_end_dates_fields',
330 'placeholder' => _x( 'To&hellip;', 'placeholder', 'learnpress' ),
331 'cancel' => true,
332 )
333 ),
334 '_lp_no_required_enroll' => new LP_Meta_Box_Checkbox_Field(
335 esc_html__( 'No requirement enroll', 'learnpress' ),
336 esc_html__( 'Students can see the content of all course items and do the quiz without login.', 'learnpress' ),
337 'no'
338 ),
339 )
340 );
341 }
342
343 public function author( $thepostid ) {
344 $post = get_post( $thepostid );
345
346 $author = $post ? $post->post_author : get_current_user_id();
347
348 $options = array();
349 $role = array( 'administrator', 'lp_teacher' );
350
351 $role = apply_filters( 'learn_press_course_author_role_meta_box', $role );
352
353 foreach ( $role as $_role ) {
354 $users_by_role = get_users( array( 'role' => $_role ) );
355
356 if ( $users_by_role ) {
357 foreach ( $users_by_role as $user ) {
358 $options[ $user->get( 'ID' ) ] = $user->user_login;
359 }
360 }
361 }
362
363 return apply_filters(
364 'lp/course/meta-box/fields/author',
365 array(
366 '_lp_course_author' => new LP_Meta_Box_Select_Field(
367 esc_html__( 'Author', 'learnpress' ),
368 '',
369 $author,
370 array(
371 'options' => $options,
372 'style' => 'min-width:200px;',
373 )
374 ),
375 )
376 );
377 }
378
379 public function assessment( $thepostid ) {
380 $post = get_post( $thepostid );
381
382 $course_result_desc = '';
383 $course_results = get_post_meta( $thepostid, '_lp_course_result', true );
384
385 $course_result_desc .= __( 'The method to assess the result of a student for a course.', 'learnpress' );
386
387 if ( $course_results == 'evaluate_final_quiz' && ! get_post_meta( $thepostid, '_lp_final_quiz', true ) ) {
388 $course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
389 }
390
391 $final_quizz_passing = '';
392
393 $course = learn_press_get_course( $thepostid );
394
395 if ( $course ) {
396 $passing_grade = $url = '';
397
398 $final_quiz = $course->get_final_quiz();
399
400 if ( $final_quiz ) {
401 $passing_grade = get_post_meta( $final_quiz, '_lp_passing_grade', true );
402
403 $url = get_edit_post_link( $final_quiz ) . '#_lp_passing_grade';
404
405 $final_quizz_passing = '
406 <div class="lp-metabox-evaluate-final_quiz">
407 <div class="lp-metabox-evaluate-final_quiz__message">'
408 . sprintf( esc_html__( 'Passing Grade: %s', 'learpress' ), $passing_grade . '%' ) .
409 ' - '
410 . sprintf( esc_html__( 'Edit: %s', 'learnpress' ), '<a href="' . esc_url_raw( $url ) . '">' . get_the_title( $final_quiz ) . '</a>' ) .
411 '</div>
412 </div>
413 ';
414 }
415 }
416
417 return apply_filters(
418 'lp/course/meta-box/fields/assessment',
419 array(
420 '_lp_course_result' => new LP_Meta_Box_Radio_Field(
421 esc_html__( 'Evaluation', 'learnpress' ),
422 $course_result_desc,
423 'evaluate_lesson',
424 array(
425 'options' => learn_press_course_evaluation_methods( $thepostid, '', $final_quizz_passing ),
426 )
427 ),
428 '_lp_passing_condition' => new LP_Meta_Box_Text_Field(
429 esc_html__( 'Passing Grade(%)', 'learnpress' ),
430 esc_html__( 'The condition that must be achieved to finish the course.', 'learnpress' ),
431 '80',
432 array(
433 'type_input' => 'number',
434 'custom_attributes' => array(
435 'min' => '0',
436 'step' => '1',
437 'max' => '100',
438 ),
439 'style' => 'width: 60px;',
440 )
441 ),
442 )
443 );
444 }
445
446 public function extra( $thepostid ) {
447 return apply_filters(
448 'lp/course/meta-box/fields/extra',
449 array(
450 '_lp_requirements' => new LP_Meta_Box_Extra_Field(
451 esc_html__( 'Requirements', 'learnpress' ),
452 '',
453 array()
454 ),
455 '_lp_target_audiences' => new LP_Meta_Box_Extra_Field(
456 esc_html__( 'Target Audience', 'learnpress' ),
457 '',
458 array()
459 ),
460 '_lp_key_features' => new LP_Meta_Box_Extra_Field(
461 esc_html__( 'Key Features', 'learnpress' ),
462 '',
463 array()
464 ),
465 '_lp_faqs' => new LP_Meta_Box_Extra_Faq_Field(
466 esc_html__( 'FAQs', 'learnpress' ),
467 '',
468 array()
469 ),
470 )
471 );
472 }
473
474 public function output( $post ) {
475 parent::output( $post );
476 ?>
477
478 <div class="lp-meta-box lp-meta-box--course">
479 <div class="lp-meta-box__inner">
480 <div class="lp-meta-box__course-tab">
481 <ul class="lp-meta-box__course-tab__tabs">
482 <?php
483 foreach ( $this->metabox( $post->ID ) as $key => $tab ) {
484 if ( $key === 'author' && ! is_super_admin() ) {
485 continue;
486 }
487
488 $class_tab = '';
489
490 if ( isset( $tab['class'] ) ) {
491 $class_tab = implode( ' ', (array) $tab['class'] );
492 }
493 ?>
494 <li class="<?php echo esc_attr( $key ); ?>_options <?php echo esc_attr( $key ); ?>_tab <?php echo esc_attr( $class_tab ); ?>">
495 <a href="#<?php echo esc_attr( $tab['target'] ); ?>">
496 <?php if ( isset( $tab['icon'] ) ) : ?>
497 <i class="<?php echo esc_attr( $tab['icon'] ); ?>"></i>
498 <?php endif; ?>
499 <span><?php echo esc_html( $tab['label'] ); ?></span>
500 </a>
501 </li>
502 <?php } ?>
503 </ul>
504
505 <div class="lp-meta-box__course-tab__content">
506 <?php foreach ( $this->metabox( $post->ID ) as $key => $tab_content ) { ?>
507 <?php
508 if ( $key === 'author' && ! is_super_admin() ) {
509 continue;
510 }
511 ?>
512 <?php if ( isset( $tab_content['content'] ) ) { ?>
513 <div id="<?php echo esc_attr( $tab_content['target'] ); ?>" class="lp-meta-box-course-panels">
514 <?php
515 do_action( 'learnpress/course-settings/before-' . $key );
516
517 foreach ( $tab_content['content'] as $meta_key => $object ) {
518 if ( is_a( $object, 'LP_Meta_Box_Field' ) ) {
519 $object->id = $meta_key;
520 echo wp_kses_post( $object->output( $post->ID ) );
521 }
522 }
523
524 do_action( 'learnpress/course-settings/after-' . $key );
525 ?>
526 </div>
527 <?php
528 }
529 }
530
531 do_action( 'lp_course_data_setting_tab_content', $post );
532 ?>
533 </div>
534 </div>
535 </div>
536 </div>
537
538 <?php
539 }
540
541 public function save( $post_id ) {
542 if ( ! empty( $this->metabox( $post_id ) ) ) {
543 foreach ( $this->metabox( $post_id ) as $key => $tab_content ) {
544 if ( isset( $tab_content['content'] ) ) {
545 foreach ( $tab_content['content'] as $meta_key => $object ) {
546 if ( is_a( $object, 'LP_Meta_Box_Field' ) ) {
547 $object->id = $meta_key;
548 $object->save( $post_id );
549 }
550 }
551 }
552 }
553 }
554
555 $course = learn_press_get_course( $post_id );
556
557 $evalution = isset( $_POST['_lp_course_result'] ) ? LP_Helper::sanitize_params_submitted( $_POST['_lp_course_result'] ) : '';
558 $passing_condition = isset( $_POST['_lp_passing_condition'] ) ? absint( wp_unslash( $_POST['_lp_passing_condition'] ) ) : 0;
559
560 // Update Final Quiz. - Nhamdv
561 if ( $evalution == 'evaluate_final_quiz' ) {
562 $items = $course->get_item_ids();
563
564 if ( $items ) {
565 foreach ( $items as $item ) {
566 if ( learn_press_get_post_type( $item ) === LP_QUIZ_CPT ) {
567 $final_quiz = $item;
568 }
569 }
570 }
571
572 if ( isset( $final_quiz ) ) {
573 update_post_meta( $post_id, '_lp_final_quiz', $final_quiz );
574 } else {
575 delete_post_meta( $post_id, '_lp_final_quiz' );
576 }
577 } else {
578 delete_post_meta( $post_id, '_lp_final_quiz' );
579 }
580
581 $author = isset( $_POST['_lp_course_author'] ) ? wp_unslash( $_POST['_lp_course_author'] ) : '';
582
583 if ( ! empty( $author ) ) {
584 global $wpdb;
585
586 $wpdb->update( $wpdb->posts, array( 'post_author' => $author ), array( 'ID' => $post_id ) );
587 }
588 }
589
590 private static function data_tabs_sort( $a, $b ) {
591 if ( ! isset( $a['priority'], $b['priority'] ) ) {
592 return - 1;
593 }
594
595 if ( $a['priority'] === $b['priority'] ) {
596 return 0;
597 }
598
599 return $a['priority'] < $b['priority'] ? - 1 : 1;
600 }
601
602 /**
603 * In child theme use metabox in v3,
604 * so need use for child theme.
605 * function in child: thim_add_course_meta.
606 *
607 * @return void
608 */
609 public static function eduma_child_metabox_v3( $meta_boxes ) {
610 if ( ! empty( $meta_boxes['fields'] ) ) {
611 foreach ( $meta_boxes['fields'] as $setting ) {
612 $field = wp_parse_args(
613 $setting,
614 array(
615 'id' => '',
616 'name' => '',
617 'desc' => '',
618 'std' => '',
619 )
620 );
621
622 switch ( $field['type'] ) {
623 case 'text':
624 case 'number':
625 lp_meta_box_text_input_field(
626 array(
627 'id' => $field['id'],
628 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
629 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
630 'type' => $field['type'],
631 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
632 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
633 )
634 );
635 break;
636
637 case 'textarea':
638 lp_meta_box_textarea_field(
639 array(
640 'id' => $field['id'],
641 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
642 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
643 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
644 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
645 )
646 );
647 break;
648
649 case 'checkbox':
650 lp_meta_box_checkbox_field(
651 array(
652 'id' => $field['id'],
653 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
654 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
655 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
656 )
657 );
658 break;
659
660 case 'duration':
661 lp_meta_box_duration_field(
662 array(
663 'id' => $field['id'],
664 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
665 'default_time' => $field['default_time'],
666 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
667 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
668 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
669 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
670 )
671 );
672 break;
673
674 case 'select':
675 lp_meta_box_select_field(
676 array(
677 'id' => $field['id'],
678 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
679 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
680 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
681 'options' => $field['options'],
682 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
683 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
684 )
685 );
686 break;
687
688 case 'select_advanced':
689 lp_meta_box_select_field(
690 array(
691 'id' => $field['id'],
692 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
693 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
694 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
695 'options' => $field['options'],
696 'multiple' => true,
697 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
698 'wrapper_class' => 'lp-select-2',
699 'style' => 'min-width: 200px',
700 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
701 )
702 );
703 break;
704 }
705 }
706 }
707 }
708
709 public static function save_eduma_child_metabox_v3( $post_id ) {
710 $general = apply_filters( 'learn_press_course_settings_meta_box_args', array( 'fields' => array() ) );
711
712 if ( ! empty( $general['fields'] ) ) {
713 foreach ( $general['fields'] as $field ) {
714 $value = isset( $_POST[ $field['id'] ] ) ? wp_unslash( $_POST[ $field['id'] ] ) : '';
715
716 update_post_meta( $post_id, $field['id'], $value );
717 }
718 }
719 }
720
721 /**
722 * Get instance
723 *
724 * @return LP_Meta_Box_Course
725 */
726 public static function instance(): LP_Meta_Box_Course {
727 if ( ! self::$instance ) {
728 self::$instance = new self();
729 }
730
731 return self::$instance;
732 }
733 }
734
735 LP_Meta_Box_Course::instance();
736