Fix media library attachment label for course/membership-protected files#3181
Open
faisalahammad wants to merge 1 commit into
Open
Fix media library attachment label for course/membership-protected files#3181faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Adds get_authorization_filter_name() to LLMS_Media_Protector so callers can identify which protection hook owns a file. Scopes llms_media_protection_attachment_field so it only runs for unprotected files or add-on-protected files, preventing add-ons like Assignments from overwriting the core course/membership label. Fixes gocodebox#3166
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.
Summary
When a file was protected by a course or membership via the File block lock icon, the WP Media Library attachment detail screen showed the Assignments add-on label "protected as an assignment submission" instead of the core label "Access is restricted to the selected course/membership."
The add-on hook
llms_media_protection_attachment_fieldwas running for every protected file, so any add-on could overwrite core labels. This scopes the filter to add-on-protected files only and exposes the authorization hook name so callers can identify who owns the protection.Fixes #3166
Changes
includes/class-llms-media-protector.phpBefore:
After:
Why: Add-ons and admin UI need a way to know which protection hook owns a file.
is_media_protected()only returns a boolean, so labels could not be matched to the correct protection type.includes/admin/class-llms-admin-media-protection-attachment-settings.phpBefore:
After:
Why: Files protected by core course/membership protection now show the correct label directly. The add-on filter still runs for its own files (different authorization hook name) and for unprotected files, so backwards compatibility is preserved.
Testing
Test 1: Course-protected file shows correct label
Result: Works as expected.