Skip to content

scaffold child-theme: add RTL stylesheet support via wp_style_add_data()#372

Merged
swissspidy merged 5 commits intomainfrom
copilot/add-loading-for-rtl-css
Mar 4, 2026
Merged

scaffold child-theme: add RTL stylesheet support via wp_style_add_data()#372
swissspidy merged 5 commits intomainfrom
copilot/add-loading-for-rtl-css

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

wp scaffold child-theme enqueued parent and child stylesheets but never registered RTL variants, leaving RTL language sites without proper stylesheet direction switching.

Changes

  • templates/child_theme_functions.mustache: Add wp_style_add_data( $handle, 'rtl', 'replace' ) after the child theme's wp_enqueue_style() call so WordPress automatically loads the -rtl.css variant when text direction is RTL. The parent theme's style is not given RTL data since its structure is unknown.

Generated functions.php now looks like:

function my_child_parent_theme_enqueue_styles() {
    wp_enqueue_style( 'parenttheme-style', get_template_directory_uri() . '/style.css', array(), '0.1.0' );
    wp_enqueue_style(
        'my-child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( 'parenttheme-style' ),
        '0.1.0'
    );
    wp_style_add_data( 'my-child-style', 'rtl', 'replace' );
}
  • features/scaffold.feature: Assert the wp_style_add_data call is present for the child theme style in the generated functions.php.
Original prompt

This section details on the original issue you should resolve

<issue_title>scaffold child-theme not added rtl.css</issue_title>
<issue_description>When I run wp scaffold child-theme the command add loading of style.css but not rtl.css.
rtl.css is very important for right to left languages.

please add loading of its.</issue_description>

<agent_instructions>use wp_style_add_data() for an rtl version</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add loading for rtl.css in child-theme scaffold scaffold child-theme: add RTL stylesheet support via wp_style_add_data() Mar 4, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy changed the title scaffold child-theme: add RTL stylesheet support via wp_style_add_data() scaffold child-theme: add RTL stylesheet support via wp_style_add_data() Mar 4, 2026
@swissspidy swissspidy added this to the 2.5.4 milestone Mar 4, 2026
@github-actions github-actions bot added command:scaffold-child-theme Related to 'scaffold child-theme' command scope:testing Related to testing labels Mar 4, 2026
@swissspidy swissspidy marked this pull request as ready for review March 4, 2026 09:41
@swissspidy swissspidy requested a review from a team as a code owner March 4, 2026 09:41
Copilot AI review requested due to automatic review settings March 4, 2026 09:41
Copy link
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 the wp scaffold child-theme output so generated child themes declare RTL support for their enqueued stylesheet via wp_style_add_data(), and adds a Behat assertion to ensure the generated functions.php includes that RTL metadata.

Changes:

  • Add wp_style_add_data( $child_handle, 'rtl', 'replace' ) to the child theme functions.php template.
  • Extend the scaffold Behat feature to assert the RTL metadata call is present in generated functions.php.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
templates/child_theme_functions.mustache Adds RTL metadata for the child theme stylesheet handle.
features/scaffold.feature Adds an acceptance assertion for the new RTL metadata line in generated functions.php.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy merged commit 322c75e into main Mar 4, 2026
59 checks passed
@swissspidy swissspidy deleted the copilot/add-loading-for-rtl-css branch March 4, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:scaffold-child-theme Related to 'scaffold child-theme' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scaffold child-theme not added rtl.css

3 participants