Formatting: Add strip_html_newlines() function#11450
Formatting: Add strip_html_newlines() function#11450himanshupathak95 wants to merge 8 commits intoWordPress:trunkfrom
strip_html_newlines() function#11450Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
… in specific HTML elements
3d36f58 to
60920d2
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Trac ticket: https://core.trac.wordpress.org/ticket/5678
This PR adds
strip_html_newlines()towp-includes/formatting.php, a function that strips unnecessary newlines from text nodes in fully marked-up HTML while preserving newlines insidepre,code,kbd,script, andstyleelements (maybe we can fix the hardcoding and think of something better later but keeping this simple for now)This is useful for cleaning up imported HTML content before it is processed by
wpautop(), which would otherwise convert superfluous newlines into unwanted<br />elements.Testing
Refreshing and inspired by the patch - https://core.trac.wordpress.org/attachment/ticket/5678/5678.r6633.diff
Props @hansengel