Skip to content

i18n: Localize label attribute of additional blocks#826

Open
bph wants to merge 1 commit into
trunkfrom
fix/i18n-block-attribute-coverage
Open

i18n: Localize label attribute of additional blocks#826
bph wants to merge 1 commit into
trunkfrom
fix/i18n-block-attribute-coverage

Conversation

@bph
Copy link
Copy Markdown
Contributor

@bph bph commented Apr 29, 2026

Summary

Extends the "Localize Text" feature so that the label attribute of five more core blocks is wrapped in esc_attr_e() on theme save:

  • core/navigation-link
  • core/navigation-submenu
  • core/home-link
  • core/social-link
  • core/categories

Each is added as a fall-through case in CBT_Theme_Locale::get_localizable_block_attributes() (includes/create-theme/theme-locale.php) alongside the existing label-only blocks. No new mechanism, no behavioural change for blocks already covered.

This continues the band-aid approach acknowledged in #776 — the architectural fix is tracked there.

Refs #825 (one part of it; core/file downloadButtonText / fileName will be a separate PR since those need rich-text/HTML handling).

Caveat for navigation blocks

Navigation menus stored as wp_navigation posts live outside templates and are not affected by this change. The fix only helps when a Navigation block contains inline navigation-link / navigation-submenu / home-link children in the template markup.

Test plan

  • npm run lint:php — clean
  • npm run test:unit:php — verified by CI (PHP 7.4 / 8.0 / 8.1 / 8.2 / 8.3, current and previous WP major).
  • Manual smoke in WordPress Studio: ran the production pipeline (parse_blocksescape_text_content_of_blocksserialize_blocksescape_block_attribute_strings) on hand-crafted markup for each of the five new blocks. All five produced the expected <?php esc_attr_e('<label>', '<theme-slug>');?> wrapping.

Adds Navigation Link, Navigation Submenu, Home Link, Social Link, and
Categories blocks to the list of blocks whose label attribute is
escaped for translation on theme save.

Continues the band-aid coverage approach tracked in #776.

Fixes #825.
@bph bph changed the title i18n: Localise label attribute of additional blocks i18n: Localize label attribute of additional blocks Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant