Skip to content

Conversation

@asadister
Copy link

@asadister asadister commented Nov 6, 2025

Adds support for loading ltr.css and style-ltr.css in RTL-based multilingual WordPress sites, mirroring the existing rtl.css and style-rtl.css behavior.

This enhancement enables WordPress to automatically detect and load an ltr.css file when available, ensuring proper layout and direction handling for left-to-right content within otherwise RTL environments.

Details:

  • Introduces wp_style_add_data( $handle, 'ltr', 'replace' ) and 'suffix' modes
  • Uses extra['ltr'] and _css_href() for consistent file resolution
  • Applies style_loader_tag filter for extensibility
  • Ensures compatibility with single-file enqueue behavior in WordPress Core

Includes:

  • Core logic to detect and enqueue LTR variants of stylesheets
  • Unit tests covering both metadata registration and HTML output rendering

Props asadister.

Trac ticket: https://core.trac.wordpress.org/ticket/64193


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

asadister and others added 3 commits November 4, 2025 12:56
### Summary
Adds support for loading `ltr.css` in RTL-based multilingual WordPress sites, mirroring the existing `rtl.css` behavior.

### Details
- Introduces `wp_style_add_data( $handle, 'ltr', 'replace' )` and `'suffix'` modes
- Uses `extra['ltr']` and `_css_href()` for consistent file resolution
- Applies `style_loader_tag` filter for extensibility
- Ensures compatibility with single-file enqueue behavior in WordPress Core

### Trac Ticket
See: https://core.trac.wordpress.org/ticket/64193
remove trailing whitespace on line 274
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props asadister.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Replaced short array syntax `[]` with `array()` to meet WordPress Coding Standards.
@asadister asadister changed the title Add LTR CSS support for multilingual RTL sites Add ltr.css support for RTL-based multilingual sites Nov 6, 2025
Adds unit tests verifying LTR stylesheet support in wp_register_style() and wp_print_styles().

- Confirms that `wp_style_add_data()` correctly stores 'ltr' data (replace/suffix modes).
- Ensures LTR stylesheets are printed after their main styles in HTML output.
- Covers both RTL and LTR locale cases.
- Marks `print_emoji_styles` as expected deprecated to prevent false failures.

Props asadister.
See [#64193](https://core.trac.wordpress.org/ticket/64193).
…rint_styles().

Implements comprehensive PHPUnit tests for verifying LTR stylesheet support.

These tests cover:
- Proper registration of LTR data using `wp_style_add_data()`.
- Behavior differences between LTR and RTL locales.
- Ensuring that LTR variants are correctly printed in HTML output via `wp_print_styles()`.
- Verification of stylesheet order to confirm that the LTR stylesheet appears after its main counterpart.

Includes handling for the deprecation of `print_emoji_styles` to ensure compatibility with WordPress 6.4+.

Props asadister.
See [#64193](https://core.trac.wordpress.org/ticket/64193).
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