| @@ -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 | |