Skip to content

fix(php-transformer): stop WordPress body classes inheriting source frames - #1863

Merged
chubes4 merged 1 commit into
trunkfrom
fix/wordpress-body-class-author-collision
Sep 16, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/wordpress-body-class-author-collision

Conversation

@chubes4

@chubes4 chubes4 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Problem

body_class() stamps template names onto <body>: page, home, search, single, and friends. A source stylesheet that centers an element of the same name therefore styles the document body too.

On the academic CV fixture the author rule is:

.page { max-width: var(--measure); margin: 0 auto; padding: 5rem var(--gutter-x) 6rem }

WordPress renders <body class="home ... page page-id-5"> and the source <main class="page">, so the frame is paid twice:

source imported
h1 width 652px 584px
dd width 469px 401px
page height @1280 8673px 9438px

Text content is identical; the extra 765px is line rewrapping inside a column that lost one horizontal gutter pair.

Fix

Emit a bounded compatibility rule beside the existing body-owned rules in WordPressCompatCss. When a source stylesheet gives a bare reserved template class frame geometry, reset only those properties on body:

body.page { max-width:none!important;width:auto!important;padding-inline:0!important;margin-inline:0!important }

The element keeps its own rule. Paint is untouched. Unreserved classes, element-qualified selectors (main.page), descendant selectors, and non-frame declarations are all left alone.

Validation

  • php php-transformer/tests/unit/wordpress-body-class-collision.php (13 assertions, registered in composer test:unit)
  • php php-transformer/tests/unit/admin-bar-accommodation.php, author-cascade-layer-order.php, artifact-author-stylesheet-projection.php
  • composer validate --strict

AI assistance

  • Model: grok-4.6
  • Tool: OpenCode
  • Used for: Measured the source/import geometry drift on a Studio import, traced it to the duplicated .page frame, implemented the compat rule, and wrote the coverage.

…rames

body_class() stamps template names such as page, home, and search onto the document body. A source stylesheet that centers a same-named element then applies its max-width and gutters twice, narrowing every line box and stretching the page.

Neutralize the frame properties on body for the reserved template names only, next to the existing body-owned compatibility rules.
@chubes4
chubes4 merged commit 639f69d into trunk Sep 16, 2026
10 checks passed
@chubes4
chubes4 deleted the fix/wordpress-body-class-author-collision branch September 16, 2026 21:14
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