Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Localize Text skips text that starts or ends on a new line

Open Beginner friendly
#868 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php

Research direction

Start in includes/create-theme/theme-locale.php, especially get_text_replacement_patterns_for_html() around lines 217-262. Check the affected HTML patterns against multiline headings and paragraphs; done means localized text is wrapped in esc_html_e() with surrounding whitespace trimmed, and templates with no other localized PHP are still moved into a pattern.

Written by the indexing model from the issue text.

Description

What happens

"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:

https://github.com/WordPress/create-block-theme/blob/5524f195e8/includes/create-theme/theme-locale.php#L217-L262

For example, this heading (from WooCommerce's Related Products markup) is exported unchanged:

<h2 class="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.

Dominant language
JavaScript
Stars
418
Forks
66
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/create-block-theme

All issues in WordPress/create-block-theme

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.