fix: render line breaks in admin bar upgrade message#1043
Open
faisalahammad wants to merge 1 commit intowp-media:developfrom
Open
fix: render line breaks in admin bar upgrade message#1043faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad wants to merge 1 commit intowp-media:developfrom
Conversation
The upgrade message text contains a <br> tag which was being escaped by esc_html(), causing it to be visible as literal text. Using wp_kses() with a narrow allowlist fixes the rendering. Fixes wp-media#1033
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
This PR fixes the admin bar “upgrade” message rendering when credits are exhausted by allowing the hard-coded <br> tag (generated in classes/Admin/AdminBar.php) to be rendered as an actual line break instead of being shown as literal text.
Changes:
- Replace
esc_html( $data['text'] )withwp_kses( $data['text'], [ 'br' => [] ] )to allow only<br>in the message. - Maintain output safety by using a narrow KSES allowlist rather than allowing arbitrary HTML.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
remyperona
approved these changes
May 4, 2026
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
Fixes a visual bug where the
<br>tag was visible as literal text in the admin bar upgrade message when credits are exhausted. This occurred because the message was being escaped byesc_html()in the template.Fixes #1033
Changes
views/admin/admin-bar-status.php
Before:
After:
Why: The
$textvalue is built inAdminBar.phpwith hardcoded<br>tags. Switching towp_kses()with a narrow allowlist forbrensures the line break renders correctly while maintaining security.Testing
Test 1: Admin Bar Profile
<br>tag.Result: Works as expected