PROD-9961: Fix Courses nav link when TutorLMS has a custom course permalink slug - #5048
Open
rezwan-buddyboss wants to merge 1 commit into
Open
PROD-9961: Fix Courses nav link when TutorLMS has a custom course permalink slug#5048rezwan-buddyboss wants to merge 1 commit into
rezwan-buddyboss wants to merge 1 commit into
Conversation
get_post_type_archive_link() expects the registered post type name, but bb_tutorlms_profile_courses_slug() returns TutorLMS's course_permalink_base option, which can be customized independently of the post type. When a custom slug is set, the two no longer match and the archive link resolves to empty. Use tutor()->course_post_type directly instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PROD link: https://buddyboss.atlassian.net/browse/PROD-9961
Issue
On a site running ReadyLaunch with TutorLMS, when a custom course permalink slug is configured in TutorLMS's own settings, the "Courses" link in the ReadyLaunch sidebar/menu has no URL. Clicking it does nothing — the page doesn't navigate anywhere, because the link's
hrefis empty. With TutorLMS's defaultcoursesslug, the link works fine; the bug only surfaces once that slug is changed.Root cause
class-bb-readylaunch.php:710built the Courses nav link withget_post_type_archive_link( bb_tutorlms_profile_courses_slug() ).get_post_type_archive_link()expects the registered post type name as its argument, butbb_tutorlms_profile_courses_slug()returns TutorLMS'scourse_permalink_baseoption — the post type's rewrite slug, which is a separate, independently-configurable value. The two happen to be identical (courses) under TutorLMS's defaults, which is why the bug is invisible until an admin changes the permalink setting. Once they diverge,get_post_type_archive_link()can't match the passed string to any registered post type and returns an empty string, leaving the nav item with no URL.The sibling
elseifbranch two lines down, for MemberPress Courses, already does this correctly — it passesmemberpress\courses\models\Course::$cpt, the actual registered CPT constant, not a slug.Fix
Changed the argument to
tutor()->course_post_type— TutorLMS's own registered CPT name, confirmed against TutorLMS'sPost_types.phpregistration code. This CPT name is fixed regardless of how the permalink slug is configured, soget_post_type_archive_link()resolves correctly either way, matching the same pattern the MemberPress branch already uses.