Allow UTF-8 Encodings for SVGs in add_menu_page #8304
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.
Trac Ticket: https://core.trac.wordpress.org/ticket/55543
Allow Additional Encodings for SVGs in
add_menu_page
This PR improves the handling of SVGs in
add_menu_page
by allowing additional encoding formats beyond Base64. Previously, the function only checked fordata:image/svg+xml;base64,
, but SVGs don’t need to be Base64-encoded. This update introduces support fordata:image/svg+xml;utf8,
encoding and provides a more flexible approach to validating and sanitizing SVGs.Changes Introduced
Extended Encoding Support:
data:image/svg+xml;utf8,
SVG encoding.Enhanced SVG Sanitization:
<g>
,<path>
,<circle>
,<text>
, and gradients.wp_kses_allowed_html( 'post' )
as the base and extends it with the new SVG attributes.Improved Rendering & Styling:
<div class="inline-svg-container">
to encapsulate the inline SVGs.Why This Change?
More Efficient & Flexible SVG Handling:
Security & Compatibility:
wp_kses
) ensures safe and controlled rendering of inline SVGs.Potential Impact & Compatibility