i18n: Localize label attribute of additional blocks#826
Open
bph wants to merge 1 commit into
Open
Conversation
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Extends the "Localize Text" feature so that the
labelattribute of five more core blocks is wrapped inesc_attr_e()on theme save:core/navigation-linkcore/navigation-submenucore/home-linkcore/social-linkcore/categoriesEach is added as a fall-through case in
CBT_Theme_Locale::get_localizable_block_attributes()(includes/create-theme/theme-locale.php) alongside the existinglabel-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/filedownloadButtonText/fileNamewill be a separate PR since those need rich-text/HTML handling).Caveat for navigation blocks
Navigation menus stored as
wp_navigationposts live outside templates and are not affected by this change. The fix only helps when a Navigation block contains inlinenavigation-link/navigation-submenu/home-linkchildren in the template markup.Test plan
npm run lint:php— cleannpm run test:unit:php— verified by CI (PHP 7.4 / 8.0 / 8.1 / 8.2 / 8.3, current and previous WP major).parse_blocks→escape_text_content_of_blocks→serialize_blocks→escape_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.