You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Localize Text skips text that starts or ends on a new line #868
"Localize Text" skips text that starts or ends on a new line. The HTML patterns in get_text_replacement_patterns_for_html() have no s modifier, so . doesn't match a newline:
For example, this heading (from WooCommerce's Related Products markup) is exported unchanged:
<h2class="wp-block-heading has-x-large-font-size">
Related products </h2>
The same happens to a paragraph like <p>\n\tNo products were found matching your selection.</p>. It affects every block type in that list, not just headings.
A side effect: when nothing in a template gets localized, the template isn't moved into a pattern either, because paternize_template() only runs when PHP was added.
Expected
The text is wrapped in esc_html_e(), with the surrounding whitespace trimmed.
Suggested fix
Add the s modifier to these patterns and trim the captured text before escaping it.
Drafted with AI assistance, verified by me against a theme exported with Create Block Theme and the source.
Activity