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/Ajax/CourseBuilder/CourseBuilderAjax.php +32 -1 4.4.3 → 4.4.9 View file →
@@ -1396,10 +1396,13 @@
1396 1396 }
1397 1397
1398 1398 /**
1399 1399 * Save Lesson Settings
1400 + * @throws Exception
1400 1401 */
1401 1402 protected function save_lesson_settings_to_model( LessonPostModel $lessonModel, array $data ) {
1403 + $must_save = 0;
1404 +
1402 1405 if ( isset( $data['_lp_duration'] ) ) {
1403 1406 $duration = ! empty( $data['_lp_duration'] ) ? str_replace( ',', ' ', $data['_lp_duration'] ) : '0 minute';
1404 1407 $explode = explode( ' ', $duration );
1405 1408 $number = (float) $explode[0] < 0 ? 0 : absint( $explode[0] );
@@ -1404,15 +1407,32 @@
1404 1407 $explode = explode( ' ', $duration );
1405 1408 $number = (float) $explode[0] < 0 ? 0 : absint( $explode[0] );
1406 1409 $unit = $explode[1] ?? 'minute';
1407 1410
1408 - $lessonModel->save_meta_value_by_key( '_lp_duration', $number . ' ' . $unit );
1411 + $lessonModel->set_meta_value_by_key( $lessonModel::META_KEY_DURATION, $number . ' ' . $unit );
1412 + $must_save = 1;
1409 1413 }
1410 1414
1411 1415 if ( isset( $data['_lp_preview'] ) ) {
1412 1416 $enable = $data['_lp_preview'] === 'yes';
1413 1417 $lessonModel->set_preview( $enable );
1418 + $must_save = 1;
1414 1419 }
1420 +
1421 + if ( $must_save ) {
1422 + $lessonModel->save();
1423 + }
1424 +
1425 + /**
1426 + * Allow addons to persist their own lesson settings fields added to the
1427 + * settings metabox tabs when saving from Course Builder.
1428 + *
1429 + * @param LessonPostModel $lessonModel Lesson model being saved.
1430 + * @param array $data Submitted settings data.
1431 + *
1432 + * @since 4.3.8
1433 + */
1434 + do_action( 'learn-press/course-builder/save-lesson-settings', $lessonModel, $data );
1415 1435 }
1416 1436
1417 1437 /**
1418 1438 * Save Quiz Settings to QuizPostModel
@@ -1464,8 +1484,19 @@
1464 1484 }
1465 1485 $quizModel->save_meta_value_by_key( $key, $value );
1466 1486 }
1467 1487 }
1488 +
1489 + /**
1490 + * Allow addons to persist their own quiz settings fields added to the
1491 + * settings metabox tabs when saving from Course Builder.
1492 + *
1493 + * @param QuizPostModel $quizModel Quiz model being saved.
1494 + * @param array $data Submitted settings data.
1495 + *
1496 + * @since 4.3.8
1497 + */
1498 + do_action( 'learn-press/course-builder/save-quiz-settings', $quizModel, $data );
1468 1499 }
1469 1500
1470 1501 /**
1471 1502 * Update Quiz from Course Builder.