fix: output dir="ltr" attribute for LTR languages#329
Merged
fabiankaegy merged 3 commits intotrunkfrom May 6, 2026
Merged
Conversation
WordPress core only emits a `dir` attribute on `<html>` for RTL sites, but `postcss-logical` scopes generated rules to both `html[dir="ltr"]` and `html[dir="rtl"]`. Without an explicit `dir="ltr"`, the LTR rules never match. Add a `language_attributes` filter in both themes that appends `dir="ltr"` when `is_rtl()` is false. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates both the classic (10up-theme) and block (10up-block-theme) ThemeCore setup to ensure the <html> element includes an explicit dir="ltr" attribute on LTR sites, aligning markup with CSS output generated by postcss-logical (which scopes rules to html[dir="ltr"] / html[dir="rtl"]).
Changes:
- Hook the
language_attributesfilter during theme setup in both themes. - Add a
ThemeCore::add_ltr_language_attribute()method that appendsdir="ltr"whenis_rtl()is false.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| themes/10up-theme/src/ThemeCore.php | Adds a language_attributes filter and callback to emit dir="ltr" for LTR sites. |
| themes/10up-block-theme/src/ThemeCore.php | Mirrors the same language_attributes filter and callback behavior for the block theme. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
claytoncollie
approved these changes
May 6, 2026
Collaborator
claytoncollie
left a comment
There was a problem hiding this comment.
I personally don't like the js_detection, scrollbar_detection or this language_attribute, BUT I know they are valuable and you have a good reason to include them. APPROVED!
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
language_attributesfilter to both10up-themeand10up-block-themethat appendsdir="ltr"whenis_rtl()is false.dirattribute on<html>for RTL sites, butpostcss-logicalscopes generated rules to bothhtml[dir="ltr"]andhtml[dir="rtl"]. Without this, LTR-scoped rules never match.Fixes #174
Test plan
<html>includesdir="ltr".ar) and confirm<html>includesdir="rtl"(and not both).postcss-logicalunderhtml[dir="ltr"]now apply on LTR sites.10up-themeand10up-block-theme.