Latest Posts: Don't remove transparent background color style #39488
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.
Fix: #39402
What?
This PR prevents the transparent background color style from being removed in the rendering of the content.
Why?
In RichText, when an inline text color is specified, a transparent background color style (
background-color:rgba(0, 0, 0, 0)
) is generated at the same time.This is to disable the browser's default style (
yellow
for Chrome), since highlighted text is wrapped with amark
tag.However, this background color is sanitized by wp_kes_post, and the browser's default style is restored.
This is because parentheses are not allowed as CSS values inside wp_kses_post, except for
calc
andvar
.This part:
https://github.com/WordPress/wordpress-develop/blob/34d46cd5013c6433bb0e4d2b447abe162e6521d1/src/wp-includes/kses.php#L2514-L2521
How?
This PR temporarily hooks
safecss_filter_attr_allow_css
filter and adds a transparent background color as valid CSS.If you know of any other appropriate methods, please advise me.
Testing Instructions
Screenshots or screencast
2e8162561c11e839c356556496c04d0b.mp4