PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.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 All 140 releases
← All changes | inc/admin/views/meta-boxes/course/settings.php +320 -205 4.1.7.3.2 → 4.4.9 View file →
@@ -1,6 +1,12 @@
1 1 <?php
2 2
3 +use LearnPress\Helpers\Config;
4 +use LearnPress\Models\CourseModel;
5 +use LearnPress\Models\CoursePostModel;
6 +use LearnPress\TemplateHooks\Course\AdminEditCurriculumTemplate;
7 +use LearnPress\TemplateHooks\TemplateAJAX;
8 +
3 9 class LP_Meta_Box_Course extends LP_Meta_Box {
4 10 /**
5 11 * Instance
6 12 *
@@ -9,10 +15,39 @@
9 15 private static $instance = null;
10 16
11 17 public $post_type = LP_COURSE_CPT;
12 18
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' );
19 + /**
20 + * @param WP_Post $post
21 + *
22 + * @return void
23 + */
24 + public function add_meta_boxes( $post ) {
25 + $course = CourseModel::find( $post->ID, true );
26 + $is_enable_offline_course = false;
27 + if ( $course instanceof CourseModel ) {
28 + $is_enable_offline_course = $course->get_meta_value_by_key( CoursePostModel::META_KEY_OFFLINE_COURSE, 'no' ) === 'yes';
29 + }
30 +
31 + add_meta_box(
32 + 'course-settings',
33 + esc_html__( 'Course Settings', 'learnpress' ),
34 + array( $this, 'output' ),
35 + $this->post_type,
36 + 'normal',
37 + 'high'
38 + );
39 +
40 + if ( ! $is_enable_offline_course ) {
41 + add_meta_box(
42 + 'course-editor',
43 + esc_html__( 'Curriculum', 'learnpress' ),
44 + array( $this, 'admin_editor' ),
45 + $this->post_type,
46 + 'normal',
47 + 'high'
48 + );
49 + }
15 50 }
16 51
17 52 public function metabox( $post_id ) {
18 53 $tabs = apply_filters(
@@ -24,8 +59,15 @@
24 59 'icon' => 'dashicons-admin-tools',
25 60 'priority' => 10,
26 61 'content' => $this->general( $post_id ),
27 62 ),
63 + 'offline' => array(
64 + 'label' => esc_html__( 'Offline Course', 'learnpress' ),
65 + 'target' => 'offline_course_data',
66 + 'icon' => 'dashicons-welcome-view-site',
67 + 'priority' => 10,
68 + 'content' => $this->tab_offline( $post_id ),
69 + ),
28 70 'price' => array(
29 71 'label' => esc_html__( 'Pricing', 'learnpress' ),
30 72 'target' => 'price_course_data',
31 73 'icon' => 'dashicons-cart',
@@ -52,8 +94,15 @@
52 94 'icon' => 'dashicons-businessman',
53 95 'priority' => 50,
54 96 'content' => $this->author( $post_id ),
55 97 ),
98 + 'material' => array(
99 + 'label' => esc_html__( 'Downloadable Materials', 'learnpress' ),
100 + 'target' => 'downloadable_material_data',
101 + 'icon' => 'dashicons-download',
102 + 'priority' => 60,
103 + 'content' => $this->lp_material( $post_id ),
104 + ),
56 105 )
57 106 );
58 107
59 108 $tabs = apply_filters( 'learnpress/course/metabox/tabs', $tabs, $post_id );
@@ -62,13 +111,45 @@
62 111
63 112 return $tabs;
64 113 }
65 114
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.' ) );
115 + public function general( $post_id ) {
116 + $course = CourseModel::find( $post_id, true );
117 + $repurchase_option_desc = sprintf(
118 + '1. %s',
119 + __(
120 + 'Reset course progress: The course progress and results of student will be removed.',
121 + 'learnpress'
122 + )
123 + );
124 + $repurchase_option_desc .= '<br/>' . sprintf(
125 + '2. %s',
126 + __(
127 + 'Keep course progress: The course progress and results of student will remain.',
128 + 'learnpress'
129 + )
130 + );
131 + $repurchase_option_desc .= '<br/>' . sprintf(
132 + '3. %s',
133 + __(
134 + 'Open popup: The student can decide whether their course progress will be reset with the confirm popup.',
135 + 'learnpress'
136 + )
137 + );
138 + $max_students_desc = esc_html__(
139 + 'The maximum number of students that can join a course. Set 0 for unlimited.',
140 + 'learnpress'
141 + );
142 + $max_students_desc .= '<br/>' . esc_html__( 'Not apply for case "No enroll requirement".', 'learnpress' );
70 143
144 + $is_enable_allow_course_repurchase = false;
145 + if ( $course instanceof CourseModel ) {
146 + $is_enable_allow_course_repurchase = $course->get_meta_value_by_key( CoursePostModel::META_KEY_ALLOW_COURSE_REPURCHASE, 'no' ) === 'yes';
147 + }
148 +
149 + $fake_students_desc = esc_html__( 'Fake students enrolled for the course.', 'learnpress' );
150 + $fake_students_desc .= '<br>' . esc_html__( 'It only to display, not calculate', 'learnpress' );
151 +
71 152 return apply_filters(
72 153 'lp/course/meta-box/fields/general',
73 154 array(
74 155 '_lp_duration' => new LP_Meta_Box_Duration_Field(
@@ -73,9 +154,9 @@
73 154 array(
74 155 '_lp_duration' => new LP_Meta_Box_Duration_Field(
75 156 esc_html__( 'Duration', 'learnpress' ),
76 157 esc_html__( 'Set to 0 for the lifetime access.', 'learnpress' ),
77 - '10',
158 + '10 week',
78 159 array(
79 160 'default_time' => 'week',
80 161 'custom_attributes' => array(
81 162 'min' => '0',
@@ -94,9 +175,9 @@
94 175 'yes'
95 176 ),
96 177 '_lp_allow_course_repurchase' => new LP_Meta_Box_Checkbox_Field(
97 178 __( 'Allow Repurchase', 'learnpress' ),
98 - esc_html__( 'Allow users to repurchase this course after it has been finished or blocked (Do not apply to free courses).', 'learnpress' ),
179 + esc_html__( 'Allow users to repurchase this course after it has been finished or blocked (Do not apply to free courses or Create Order manual).', 'learnpress' ),
99 180 'no'
100 181 ),
101 182 '_lp_course_repurchase_option' => new LP_Meta_Box_Select_Field(
102 183 esc_html__( 'Repurchase action', 'learnpress' ),
@@ -102,20 +183,24 @@
102 183 esc_html__( 'Repurchase action', 'learnpress' ),
103 184 $repurchase_option_desc,
104 185 'reset',
105 186 array(
106 - 'options' => array(
187 + 'options' => array(
107 188 'reset' => esc_html__( 'Reset course progress', 'learnpress' ),
108 189 'keep' => esc_html__( 'Keep course progress', 'learnpress' ),
109 190 'popup' => esc_html__( 'Open popup', 'learnpress' ),
110 191 ),
111 - 'show' => array( '_lp_allow_course_repurchase', '=', 'yes' ), // use 'show' or 'hide'
192 + 'dependency' => [
193 + 'name' => '_lp_allow_course_repurchase',
194 + 'is_disable' => ! $is_enable_allow_course_repurchase,
195 + ],
196 + //'show' => array( '_lp_allow_course_repurchase', '=', 'yes' ), // use 'show' or 'hide'
112 197 )
113 198 ),
114 199 '_lp_level' => new LP_Meta_Box_Select_Field(
115 200 esc_html__( 'Level', 'learnpress' ),
116 201 esc_html__( 'Choose a difficulty level.', 'learnpress' ),
117 - '',
202 + 'all',
118 203 array(
119 204 'options' => lp_course_level(),
120 205 )
121 206 ),
@@ -120,9 +205,9 @@
120 205 )
121 206 ),
122 207 '_lp_students' => new LP_Meta_Box_Text_Field(
123 208 esc_html__( 'Fake Students Enrolled', 'learnpress' ),
124 - esc_html__( 'How many students have taken this course?', 'learnpress' ),
209 + $fake_students_desc,
125 210 0,
126 211 array(
127 212 'type_input' => 'number',
128 213 'custom_attributes' => array(
@@ -133,9 +218,9 @@
133 218 )
134 219 ),
135 220 '_lp_max_students' => new LP_Meta_Box_Text_Field(
136 221 esc_html__( 'Max student', 'learnpress' ),
137 - esc_html__( 'The maximum number of students that can join a course. Set 0 for unlimited.', 'learnpress' ),
222 + $max_students_desc,
138 223 0,
139 224 array(
140 225 'type_input' => 'number',
141 226 'custom_attributes' => array(
@@ -179,21 +264,94 @@
179 264 array(
180 265 '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 266 )
182 267 ),
183 - )
268 + ),
269 + $post_id
184 270 );
185 271 }
186 272
187 273 /**
274 + * Tab setting offline course
275 + *
276 + * @param $post_id
277 + *
278 + * @return array
279 + * @since 4.2.7
280 + * @version 1.0.0
281 + */
282 + public function tab_offline( $post_id ): array {
283 + $course = CourseModel::find( $post_id, true );
284 +
285 + $is_offline_course = false;
286 + if ( $course instanceof CourseModel ) {
287 + $is_offline_course = $course->is_offline();
288 + }
289 +
290 + return apply_filters(
291 + 'lp/course/meta-box/fields/offline',
292 + array(
293 + CoursePostModel::META_KEY_OFFLINE_COURSE => new LP_Meta_Box_Checkbox_Field(
294 + esc_html__( 'Enable offline course', 'learnpress' ),
295 + esc_html__(
296 + 'When you enable the offline course feature, the system will disable certain online course functions, such as curriculum, finish button, re-take course, block content, repurchase. After checking the checkbox, make sure to click the "Update" button to apply the changes successfully.',
297 + 'learnpress'
298 + ),
299 + 'no'
300 + ),
301 + CoursePostModel::META_KEY_OFFLINE_LESSON_COUNT => new LP_Meta_Box_Text_Field(
302 + esc_html__( 'Lessons', 'learnpress' ),
303 + esc_html__( 'Total lessons of the course.', 'learnpress' ),
304 + 10,
305 + [
306 + 'type_input' => 'number',
307 + 'custom_attributes' => array(
308 + 'min' => '0',
309 + 'step' => '1',
310 + ),
311 + 'dependency' => [
312 + 'name' => '_lp_offline_course',
313 + 'is_disable' => ! $is_offline_course,
314 + ],
315 + ]
316 + ),
317 + CoursePostModel::META_KEY_DELIVER => new LP_Meta_Box_Select_Field(
318 + esc_html__( 'Delivery Type', 'learnpress' ),
319 + esc_html__( 'How your content is conveyed to students.', 'learnpress' ),
320 + 'private_1_1',
321 + [
322 + 'options' => Config::instance()->get( 'course-deliver-type' ),
323 + 'dependency' => [
324 + 'name' => '_lp_offline_course',
325 + 'is_disable' => ! $is_offline_course,
326 + ],
327 + ]
328 + ),
329 + CoursePostModel::META_KEY_ADDRESS => new LP_Meta_Box_Text_Field(
330 + esc_html__( 'Address', 'learnpress' ),
331 + esc_html__( 'You can enter the physical address of your class or specify the meeting method (e.g., Zoom, Google Meet, etc.).', 'learnpress' ),
332 + '',
333 + [
334 + 'dependency' => [
335 + 'name' => '_lp_offline_course',
336 + 'is_disable' => ! $is_offline_course,
337 + ],
338 + ]
339 + ),
340 + ),
341 + $post_id
342 + );
343 + }
344 +
345 + /**
188 346 * Setting course price
189 347 *
190 348 * @param $post_id
191 349 *
192 - * @author tungnx
350 + * @return array
193 351 * @since 4.1.5
194 352 * @version 1.0.0
195 - * @return array
353 + * @author tungnx
196 354 */
197 355 public function lp_price( $post_id ): array {
198 356 $key_exists = LP_Database::getInstance()->check_key_postmeta_exists( $post_id, '_lp_regular_price' );
199 357 $price = get_post_meta( $post_id, '_lp_price', true );
@@ -199,8 +357,10 @@
199 357 $price = get_post_meta( $post_id, '_lp_price', true );
200 358 $regular_price = $key_exists ? get_post_meta( $post_id, '_lp_regular_price', true ) : $price;
201 359 $sale_price = get_post_meta( $post_id, '_lp_sale_price', true );
202 360
361 + $is_enable_no_required_enroll = get_post_meta( $post_id, '_lp_no_required_enroll', true ) === 'yes' ? 1 : 0;
362 +
203 363 return apply_filters(
204 364 'lp/course/meta-box/fields/price',
205 365 array(
206 366 '_lp_regular_price' => new LP_Meta_Box_Text_Field(
@@ -212,10 +372,14 @@
212 372 'custom_attributes' => array(
213 373 'min' => '0',
214 374 'step' => '0.01',
215 375 ),
216 - 'style' => 'width: 70px;',
376 + 'style' => 'width: 150px;',
217 377 'class' => 'lp_meta_box_regular_price',
378 + 'dependency' => [
379 + 'name' => '_lp_no_required_enroll',
380 + 'is_disable' => $is_enable_no_required_enroll,
381 + ],
218 382 )
219 383 ),
220 384 '_lp_sale_price' => new LP_Meta_Box_Text_Field(
221 385 esc_html__( 'Sale price', 'learnpress' ),
@@ -226,10 +390,14 @@
226 390 'custom_attributes' => array(
227 391 'min' => '0',
228 392 'step' => '0.01',
229 393 ),
230 - 'style' => 'width: 70px;',
394 + 'style' => 'width: 150px;',
231 395 'class' => 'lp_meta_box_sale_price',
396 + 'dependency' => [
397 + 'name' => '_lp_no_required_enroll',
398 + 'is_disable' => $is_enable_no_required_enroll,
399 + ],
232 400 )
233 401 ),
234 402 '_lp_sale_start' => new LP_Meta_Box_Date_Field(
235 403 esc_html__( 'Sale start dates', 'learnpress' ),
@@ -237,8 +405,12 @@
237 405 '',
238 406 array(
239 407 'wrapper_class' => 'lp_sale_start_dates_fields',
240 408 'placeholder' => _x( 'From&hellip;', 'placeholder', 'learnpress' ),
409 + 'dependency' => [
410 + 'name' => '_lp_no_required_enroll',
411 + 'is_disable' => $is_enable_no_required_enroll,
412 + ],
241 413 )
242 414 ),
243 415 '_lp_sale_end' => new LP_Meta_Box_Date_Field(
244 416 esc_html__( 'Sale end dates', 'learnpress' ),
@@ -247,16 +419,31 @@
247 419 array(
248 420 'wrapper_class' => 'lp_sale_end_dates_fields',
249 421 'placeholder' => _x( 'To&hellip;', 'placeholder', 'learnpress' ),
250 422 'cancel' => true,
423 + 'dependency' => [
424 + 'name' => '_lp_no_required_enroll',
425 + 'is_disable' => $is_enable_no_required_enroll,
426 + ],
251 427 )
252 428 ),
429 + '_lp_price_prefix' => new LP_Meta_Box_Text_Field(
430 + esc_html__( 'Price prefix', 'learnpress' ),
431 + esc_html__( 'Show additional information placed before the price such as: Only, From, Up to...', 'learnpress' ),
432 + ''
433 + ),
434 + '_lp_price_suffix' => new LP_Meta_Box_Text_Field(
435 + esc_html__( 'Price Suffix', 'learnpress' ),
436 + esc_html__( 'Show additional information placed after the price such as: Included Tax, Per Hour, (Per Week)...', 'learnpress' ),
437 + ''
438 + ),
253 439 '_lp_no_required_enroll' => new LP_Meta_Box_Checkbox_Field(
254 440 esc_html__( 'There is no enrollment requirement', 'learnpress' ),
255 441 esc_html__( 'Students can see the content of all course items and take the quiz without logging in.', 'learnpress' ),
256 442 'no'
257 443 ),
258 - )
444 + ),
445 + $post_id
259 446 );
260 447 }
261 448
262 449 public function author( $thepostid ) {
@@ -261,35 +448,69 @@
261 448
262 449 public function author( $thepostid ) {
263 450 $post = get_post( $thepostid );
264 451
265 - $author = $post ? $post->post_author : get_current_user_id();
452 + $author_id = $post ? $post->post_author : get_current_user_id();
266 453
267 454 $options = array();
268 - $role = array( 'administrator', 'lp_teacher' );
455 + // Code old only use for addon Frontend Editor v4.0.4
456 + // Code old only use for addon Co-Instructor v4.0.2
457 + $can_get_options_users = false;
458 + if ( class_exists( 'LP_Addon_Frontend_Editor_Preload' )
459 + && defined( 'LP_ADDON_FRONTEND_EDITOR_VER' )
460 + && version_compare( LP_ADDON_FRONTEND_EDITOR_VER, '4.0.5', '<' ) ) {
461 + $can_get_options_users = true;
462 + }
269 463
270 - $role = apply_filters( 'learn_press_course_author_role_meta_box', $role );
464 + if ( $can_get_options_users ) {
465 + $author_roles = array( ADMIN_ROLE, LP_TEACHER_ROLE );
466 + $author_roles = apply_filters( 'learn_press_course_author_role_meta_box', $author_roles );
467 + $authors = get_users( [ 'role__in' => $author_roles ] );
271 468
272 - foreach ( $role as $_role ) {
273 - $users_by_role = get_users( array( 'role' => $_role ) );
274 -
275 - if ( $users_by_role ) {
276 - foreach ( $users_by_role as $user ) {
277 - $options[ $user->get( 'ID' ) ] = $user->user_login;
278 - }
469 + /**
470 + * @var WP_User $author
471 + */
472 + foreach ( $authors as $author ) {
473 + $options[ $author->ID ] = $author->display_name . ' (#' . $author->ID . ')';
279 474 }
280 475 }
476 + // Code old only use for addon Frontend Editor v4.0.4
281 477
478 + $data_struct = [
479 + 'urlApi' => get_rest_url( null, 'lp/v1/admin/tools/search-user' ),
480 + 'dataSendApi' => [
481 + 'role_in' => ADMIN_ROLE . ',' . LP_TEACHER_ROLE,
482 + ],
483 + 'dataType' => 'users',
484 + 'keyGetValue' => [
485 + 'value' => 'ID',
486 + 'text' => '{{display_name}}(#{{ID}})',
487 + 'key_render' => [
488 + 'display_name' => 'display_name',
489 + 'user_email' => 'user_email',
490 + 'ID' => 'ID',
491 + ],
492 + ],
493 + 'setting' => [
494 + 'plugins' => array(),
495 + ],
496 + ];
497 +
282 498 return apply_filters(
283 499 'lp/course/meta-box/fields/author',
284 500 array(
285 - '_lp_course_author' => new LP_Meta_Box_Select_Field(
501 + // Not use key 'post_author' on single edit course, it special key of WP, Gutenberg save will not submit this key.
502 + '_post_author' => new LP_Meta_Box_Select_Field(
286 503 esc_html__( 'Author', 'learnpress' ),
287 504 '',
288 - $author,
505 + $author_id,
289 506 array(
290 - 'options' => $options,
291 - 'style' => 'min-width:200px;',
507 + 'options' => $options,
508 + 'style' => 'min-width:200px;',
509 + 'tom_select' => true,
510 + 'custom_attributes' => [
511 + 'data-struct' => htmlentities2( json_encode( $data_struct ) ),
512 + ],
292 513 )
293 514 ),
294 515 )
295 516 );
@@ -294,8 +515,17 @@
294 515 )
295 516 );
296 517 }
297 518
519 + public function lp_material( $thepostid ) {
520 + return apply_filters(
521 + 'lp/course/meta-box/fields/material',
522 + array(
523 + '_lp_course_material' => new LP_Meta_Box_Material_Fields(),
524 + )
525 + );
526 + }
527 +
298 528 public function assessment( $thepostid ) {
299 529 $post = get_post( $thepostid );
300 530
301 531 $course_result_desc = '';
@@ -301,8 +531,12 @@
301 531 $course_result_desc = '';
302 532 $course_results = get_post_meta( $thepostid, '_lp_course_result', true );
303 533
304 534 $course_result_desc .= __( 'The method of evaluating a student\'s performance in a course.', 'learnpress' );
535 + $course_result_desc .= sprintf(
536 + '<br/><i style="color: red">%s</i>',
537 + __( 'Note: changing the evaluation type will affect the assessment results of student learning.', 'learnpress' )
538 + );
305 539
306 540 if ( $course_results == 'evaluate_final_quiz' && ! get_post_meta( $thepostid, '_lp_final_quiz', true ) ) {
307 541 $course_result_desc .= __( '<br /><strong>Note! </strong>There is no final quiz in the course. Please add a final quiz.', 'learnpress' );
308 542 }
@@ -317,10 +551,24 @@
317 551 $final_quiz = $course->get_final_quiz();
318 552
319 553 if ( $final_quiz ) {
320 554 $passing_grade = get_post_meta( $final_quiz, '_lp_passing_grade', true );
555 + if ( '' === (string) $passing_grade ) {
556 + $quiz_model = \LearnPress\Models\QuizPostModel::find( absint( $final_quiz ), true );
557 + if ( $quiz_model ) {
558 + $passing_grade = $quiz_model->get_passing_grade();
559 + } else {
560 + $passing_grade = 80;
561 + }
562 + }
321 563
322 564 $url = get_edit_post_link( $final_quiz ) . '#_lp_passing_grade';
565 + $url = apply_filters(
566 + 'learn-press/course/meta-box/assessment/final-quiz/edit-link',
567 + $url,
568 + $final_quiz,
569 + $thepostid
570 + );
323 571
324 572 $final_quizz_passing = '
325 573 <div class="lp-metabox-evaluate-final_quiz">
326 574 <div class="lp-metabox-evaluate-final_quiz__message">'
@@ -351,9 +599,9 @@
351 599 array(
352 600 'type_input' => 'number',
353 601 'custom_attributes' => array(
354 602 'min' => '0',
355 - 'step' => '1',
603 + 'step' => '0.01',
356 604 'max' => '100',
357 605 ),
358 606 'style' => 'width: 60px;',
359 607 )
@@ -391,74 +639,36 @@
391 639 }
392 640
393 641 public function output( $post ) {
394 642 parent::output( $post );
395 - ?>
396 643
397 - <div class="lp-meta-box lp-meta-box--course">
398 - <div class="lp-meta-box__inner">
399 - <div class="lp-meta-box__course-tab">
400 - <ul class="lp-meta-box__course-tab__tabs">
401 - <?php
402 - foreach ( $this->metabox( $post->ID ) as $key => $tab ) {
403 - if ( $key === 'author' && ! is_super_admin() ) {
404 - continue;
405 - }
644 + $course_id = $post->ID;
645 + $courseModel = CourseModel::find( $course_id, true );
646 + if ( ! $courseModel instanceof CourseModel ) {
647 + return;
648 + }
406 649
407 - $class_tab = '';
650 + do_action( 'learn-press/admin/course/edit-setting/layout', $courseModel->ID );
651 + }
408 652
409 - if ( isset( $tab['class'] ) ) {
410 - $class_tab = implode( ' ', (array) $tab['class'] );
411 - }
412 - ?>
413 - <li class="<?php echo esc_attr( $key ); ?>_options <?php echo esc_attr( $key ); ?>_tab <?php echo esc_attr( $class_tab ); ?>">
414 - <a href="#<?php echo esc_attr( $tab['target'] ); ?>">
415 - <?php if ( isset( $tab['icon'] ) ) : ?>
416 - <i class="<?php echo esc_attr( $tab['icon'] ); ?>"></i>
417 - <?php endif; ?>
418 - <span><?php echo esc_html( $tab['label'] ); ?></span>
419 - </a>
420 - </li>
421 - <?php } ?>
422 - </ul>
653 + /**
654 + * Template Editor Curriculum.
655 + *
656 + * @return void
657 + */
658 + public function admin_editor() {
659 + global $post;
423 660
424 - <div class="lp-meta-box__course-tab__content">
425 - <?php foreach ( $this->metabox( $post->ID ) as $key => $tab_content ) { ?>
426 - <?php
427 - if ( $key === 'author' && ! is_super_admin() ) {
428 - continue;
429 - }
430 - ?>
431 - <?php if ( isset( $tab_content['content'] ) ) { ?>
432 - <div id="<?php echo esc_attr( $tab_content['target'] ); ?>" class="lp-meta-box-course-panels">
433 - <?php
434 - do_action( 'learnpress/course-settings/before-' . $key );
661 + $course_id = $post->ID;
662 + $courseModel = CourseModel::find( $course_id, true );
663 + if ( ! $courseModel instanceof CourseModel ) {
664 + return;
665 + }
435 666
436 - foreach ( $tab_content['content'] as $meta_key => $object ) {
437 - if ( is_a( $object, 'LP_Meta_Box_Field' ) ) {
438 - $object->id = $meta_key;
439 - echo wp_kses_post( $object->output( $post->ID ) );
440 - }
441 - }
442 -
443 - do_action( 'learnpress/course-settings/after-' . $key );
444 - ?>
445 - </div>
446 - <?php
447 - }
448 - }
449 -
450 - do_action( 'lp_course_data_setting_tab_content', $post );
451 - ?>
452 - </div>
453 - </div>
454 - </div>
455 - </div>
456 -
457 - <?php
667 + do_action( 'learn-press/admin/edit-curriculum/layout', $courseModel );
458 668 }
459 669
460 - public function save( $post_id ) {
670 + /*public function save( $post_id ) {
461 671 if ( ! empty( $this->metabox( $post_id ) ) ) {
462 672 foreach ( $this->metabox( $post_id ) as $key => $tab_content ) {
463 673 if ( isset( $tab_content['content'] ) ) {
464 674 foreach ( $tab_content['content'] as $meta_key => $object ) {
@@ -472,13 +682,26 @@
472 682 }
473 683
474 684 $course = learn_press_get_course( $post_id );
475 685
476 - $evalution = isset( $_POST['_lp_course_result'] ) ? LP_Helper::sanitize_params_submitted( $_POST['_lp_course_result'] ) : '';
477 - $passing_condition = isset( $_POST['_lp_passing_condition'] ) ? absint( wp_unslash( $_POST['_lp_passing_condition'] ) ) : 0;
686 + // Check price is valid.
687 + $price_regular = LP_Request::get( '_lp_regular_price', 0, 'float' );
688 + $price_sale = LP_Request::get( '_lp_sale_price', 0, 'float' );
689 + if ( $price_regular <= 0 ) {
690 + $price_sale = 0;
691 + update_post_meta( $post_id, '_lp_regular_price', '' );
692 + }
478 693
694 + if ( $price_sale >= $price_regular || $price_sale < 0 ) {
695 + update_post_meta( $post_id, '_lp_sale_price', '' );
696 + }
697 + // End check price.
698 +
699 + $evaluation = LP_Request::get_param( '_lp_course_result', '', 'text', 'post' );
700 + //$passing_condition = isset( $_POST['_lp_passing_condition'] ) ? absint( wp_unslash( $_POST['_lp_passing_condition'] ) ) : 0;
701 +
479 702 // Update Final Quiz. - Nhamdv
480 - if ( $evalution == 'evaluate_final_quiz' ) {
703 + if ( $evaluation == 'evaluate_final_quiz' ) {
481 704 $items = $course->get_item_ids();
482 705
483 706 if ( $items ) {
484 707 foreach ( $items as $item ) {
@@ -497,15 +720,14 @@
497 720 delete_post_meta( $post_id, '_lp_final_quiz' );
498 721 }
499 722
500 723 $author = isset( $_POST['_lp_course_author'] ) ? wp_unslash( $_POST['_lp_course_author'] ) : '';
501 -
502 724 if ( ! empty( $author ) ) {
503 725 global $wpdb;
504 726
505 727 $wpdb->update( $wpdb->posts, array( 'post_author' => $author ), array( 'ID' => $post_id ) );
506 728 }
507 - }
729 + }*/
508 730
509 731 private static function data_tabs_sort( $a, $b ) {
510 732 if ( ! isset( $a['priority'], $b['priority'] ) ) {
511 733 return - 1;
@@ -515,115 +737,8 @@
515 737 return 0;
516 738 }
517 739
518 740 return $a['priority'] < $b['priority'] ? - 1 : 1;
519 - }
520 -
521 - /**
522 - * In child theme use metabox in v3,
523 - * so need use for child theme.
524 - * function in child: thim_add_course_meta.
525 - *
526 - * @return void
527 - */
528 - public static function eduma_child_metabox_v3( $meta_boxes ) {
529 - if ( ! empty( $meta_boxes['fields'] ) ) {
530 - foreach ( $meta_boxes['fields'] as $setting ) {
531 - $field = wp_parse_args(
532 - $setting,
533 - array(
534 - 'id' => '',
535 - 'name' => '',
536 - 'desc' => '',
537 - 'std' => '',
538 - )
539 - );
540 -
541 - switch ( $field['type'] ) {
542 - case 'text':
543 - case 'number':
544 - lp_meta_box_text_input_field(
545 - array(
546 - 'id' => $field['id'],
547 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
548 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
549 - 'type' => $field['type'],
550 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
551 - 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
552 - )
553 - );
554 - break;
555 -
556 - case 'textarea':
557 - lp_meta_box_textarea_field(
558 - array(
559 - 'id' => $field['id'],
560 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
561 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
562 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
563 - 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
564 - )
565 - );
566 - break;
567 -
568 - case 'checkbox':
569 - lp_meta_box_checkbox_field(
570 - array(
571 - 'id' => $field['id'],
572 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
573 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
574 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
575 - )
576 - );
577 - break;
578 -
579 - case 'duration':
580 - lp_meta_box_duration_field(
581 - array(
582 - 'id' => $field['id'],
583 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
584 - 'default_time' => $field['default_time'],
585 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
586 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
587 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
588 - 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
589 - )
590 - );
591 - break;
592 -
593 - case 'select':
594 - lp_meta_box_select_field(
595 - array(
596 - 'id' => $field['id'],
597 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
598 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
599 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
600 - 'options' => $field['options'],
601 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
602 - 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
603 - )
604 - );
605 - break;
606 -
607 - case 'select_advanced':
608 - lp_meta_box_select_field(
609 - array(
610 - 'id' => $field['id'],
611 - 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
612 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
613 - 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
614 - 'options' => $field['options'],
615 - 'multiple' => true,
616 - 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
617 - 'wrapper_class' => 'lp-select-2',
618 - 'style' => 'min-width: 200px',
619 - 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
620 - )
621 - );
622 - break;
623 - }
624 - }
625 - }
626 741 }
627 742
628 743 public static function save_eduma_child_metabox_v3( $post_id ) {
629 744 $general = apply_filters( 'learn_press_course_settings_meta_box_args', array( 'fields' => array() ) );