Skip to content

fix: output dir="ltr" attribute for LTR languages#329

Merged
fabiankaegy merged 3 commits intotrunkfrom
fix/ltr-language-attribute-174
May 6, 2026
Merged

fix: output dir="ltr" attribute for LTR languages#329
fabiankaegy merged 3 commits intotrunkfrom
fix/ltr-language-attribute-174

Conversation

@fabiankaegy
Copy link
Copy Markdown
Member

@fabiankaegy fabiankaegy commented May 5, 2026

Summary

  • Adds a language_attributes filter to both 10up-theme and 10up-block-theme that appends dir="ltr" when is_rtl() is false.
  • 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 this, LTR-scoped rules never match.

Fixes #174

Test plan

  • Load a page on a default LTR site and confirm <html> includes dir="ltr".
  • Switch the site to an RTL locale (e.g. ar) and confirm <html> includes dir="rtl" (and not both).
  • Verify CSS rules generated by postcss-logical under html[dir="ltr"] now apply on LTR sites.
  • Repeat the above for both 10up-theme and 10up-block-theme.

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]>
Copilot AI review requested due to automatic review settings May 5, 2026 08:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_attributes filter during theme setup in both themes.
  • Add a ThemeCore::add_ltr_language_attribute() method that appends dir="ltr" when is_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.

Comment thread themes/10up-theme/src/ThemeCore.php Outdated
Comment thread themes/10up-block-theme/src/ThemeCore.php Outdated
@fabiankaegy fabiankaegy self-assigned this May 5, 2026
fabiankaegy and others added 2 commits May 5, 2026 10:17
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown
Collaborator

@claytoncollie claytoncollie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@fabiankaegy fabiankaegy merged commit be78652 into trunk May 6, 2026
8 checks passed
@fabiankaegy fabiankaegy deleted the fix/ltr-language-attribute-174 branch May 6, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix support for CSS logical properties

3 participants