| @@ -489,9 +489,24 @@ | ||
| 489 | 489 | public static function getCourseCategories() |
| 490 | 490 | { |
| 491 | 491 | $terms = Term::whereHas('base_spaces', function ($q) { |
| 492 | 492 | $q->where('type', 'course'); |
| 493 | - })->get(); | |
| 493 | + })->orderBy('title', 'ASC')->get(); | |
| 494 | + // Respect the admin-defined order (settings.serial) | |
| 495 | + $terms = $terms->sort(function ($a, $b) { | |
| 496 | + $serialA = Arr::get($a->settings, 'serial'); | |
| 497 | + $serialB = Arr::get($b->settings, 'serial'); | |
| 498 | + if ($serialA === null && $serialB === null) { | |
| 499 | + return 0; | |
| 500 | + } | |
| 501 | + if ($serialA === null) { | |
| 502 | + return 1; | |
| 503 | + } | |
| 504 | + if ($serialB === null) { | |
| 505 | + return -1; | |
| 506 | + } | |
| 507 | + return (int) $serialA <=> (int) $serialB; | |
| 508 | + })->values(); | |
| 494 | 509 | |
| 495 | 510 | $formattedTerms = []; |
| 496 | 511 | |
| 497 | 512 | foreach ($terms as $term) { |
| @@ -540,15 +555,21 @@ | ||
| 540 | 555 | |
| 541 | 556 | $inlineCss = ''; |
| 542 | 557 | if ($parseContent && $canViewLesson) { |
| 543 | 558 | $content = $lesson->message_rendered; |
| 544 | - if (!$content && $lesson->message) { | |
| 545 | - $content = apply_filters('the_content', $lesson->message); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 546 | - if (function_exists('wp_style_engine_get_stylesheet_from_context')) { | |
| 547 | - $core_styles_keys = array('block-supports'); | |
| 548 | - // Adds comment if code is prettified to identify core styles sections in debugging. | |
| 549 | - foreach ($core_styles_keys as $style_key) { | |
| 550 | - $inlineCss .= wp_style_engine_get_stylesheet_from_context($style_key, []); | |
| 559 | + | |
| 560 | + // message_rendered still holding block markup never went through the_content | |
| 561 | + if (!$content || has_blocks($content)) { | |
| 562 | + $source = $lesson->message ?: $content; | |
| 563 | + | |
| 564 | + if ($source) { | |
| 565 | + $content = apply_filters('the_content', $source); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 566 | + if (function_exists('wp_style_engine_get_stylesheet_from_context')) { | |
| 567 | + $core_styles_keys = array('block-supports'); | |
| 568 | + // Adds comment if code is prettified to identify core styles sections in debugging. | |
| 569 | + foreach ($core_styles_keys as $style_key) { | |
| 570 | + $inlineCss .= wp_style_engine_get_stylesheet_from_context($style_key, []); | |
| 571 | + } | |
| 551 | 572 | } |
| 552 | 573 | } |
| 553 | 574 | } |
| 554 | 575 | |
| @@ -594,8 +615,11 @@ | ||
| 594 | 615 | |
| 595 | 616 | $newLessonMeta = $newLesson->meta; |
| 596 | 617 | $newLessonMeta['document_lists'] = []; |
| 597 | 618 | foreach ($lesson->media as $media) { |
| 619 | + if (!$media->is_active) { | |
| 620 | + continue; | |
| 621 | + } | |
| 598 | 622 | $newMedia = $media->replicate(); |
| 599 | 623 | $newMedia->feed_id = $newLesson->id; |
| 600 | 624 | $newMedia->save(); |
| 601 | 625 | if ($media->object_source == 'lesson_document') { |
| @@ -602,12 +626,10 @@ | ||
| 602 | 626 | $newLessonMeta['document_lists'][] = $newMedia->getPrivateFileMeta(); |
| 603 | 627 | } |
| 604 | 628 | } |
| 605 | 629 | |
| 606 | - if (!empty($newLessonMeta['document_lists'])) { | |
| 607 | - $newLesson->meta = $newLessonMeta; | |
| 608 | - $newLesson->save(); | |
| 609 | - } | |
| 630 | + $newLesson->meta = $newLessonMeta; | |
| 631 | + $newLesson->save(); | |
| 610 | 632 | } |
| 611 | 633 | |
| 612 | 634 | public static function getAccessMessage($course, $lesson, $config) |
| 613 | 635 | { |