fix(media): use correct media type labels for block protection toolbar#3182
Open
faisalahammad wants to merge 1 commit into
Open
fix(media): use correct media type labels for block protection toolbar#3182faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Replace hardcoded 'Protect Image' labels with dynamic labels based on block type. - Add getMediaTypeLabel() helper for image, audio, video, and file blocks. - Add translatable strings for dynamic protection labels via the existing JS l10n filter. Fixes gocodebox#3165
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
The media protection toolbar button and modal always said "Protect Image" even when the selected block was a file, video, or audio block. This change makes the label match the actual media type.
Fixes #3165
Changes
src/js/admin-media-protection-block-protect.jsBefore:
After:
Why:
core/image,core/video,core/audio, andcore/fileare all supported, but the labels were hardcoded for images. A newgetMediaTypeLabel()helper returns the correct noun for each block type.includes/admin/class.llms.admin.assets.phpBefore:
Core did not provide the translatable strings used by the new dynamic labels, so the toolbar would fall back to the literal English strings.
After:
Core now adds the needed strings via the existing
lifterlms_js_l10n_adminfilter:Why: This keeps the change inside the existing
LLMS.l10nsystem instead of introducing a newwp-i18ndependency for one script.Testing
Test 1: File block label
Result: toolbar tooltip and modal button say "Protect File", and the select label says "Select a Course or Membership to protect this file:".
Test 2: Video and Audio blocks
Result: labels say "Protect Video" and "Protect Audio" respectively.
Test 3: Image block remains unchanged
Result: labels still say "Protect Image".