Skip to content

[wp-block-themes]: document theme.json slug-normaliser bug class - #59

Merged
mikeyarce merged 3 commits into
trunkfrom
add/theme-json-slug-normaliser-gotcha
Jul 27, 2026
Merged

[wp-block-themes]: document theme.json slug-normaliser bug class#59
mikeyarce merged 3 commits into
trunkfrom
add/theme-json-slug-normaliser-gotcha

Conversation

@mikeyarce

Copy link
Copy Markdown
Contributor

Summary

Documents a silent failure in theme.json: WordPress hyphenates preset/custom slugs before emitting CSS vars, so a handwritten var() reference to the un-normalised slug resolves to nothing and quietly falls back. No error, layout looks roughly right — invisible without computed-style inspection.

Examples:

  • slug 3xl--wp--preset--font-size--3-xl
  • slug cardShadow--wp--custom--card-shadow

Under the hood, WP_Theme_JSON runs every slug through _wp_to_kebab_case(), which splits at digit/letter boundaries, camelCase transitions, and non-alphanumeric characters.

Changes

  • skills/wp-block-themes/references/theme-json.md — new "Slug normalisation gotcha" section with the explanation and a grep pattern for catching un-normalised references.
  • skills/wp-block-themes/references/debugging.md — new bullet under "Styles not applying" pointing at the gotcha section.

WordPress passes every preset/custom slug through _wp_to_kebab_case() before
emitting its CSS var, hyphenating at digit/letter boundaries and camelCase
transitions. Handwritten references to the un-normalised form silently fall
back, making the failure invisible without computed-style inspection.

Adds a "Slug normalisation gotcha" section to theme-json.md (with a grep
pattern for catching un-normalised references) and a cross-referenced bullet
under debugging.md § "Styles not applying".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mikeyarce <mikeyarce@git.wordpress.org>
Co-authored-by: karmatosed <karmatosed@git.wordpress.org>
Co-authored-by: bgrgicak <berislavgrgicak@git.wordpress.org>

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

@karmatosed
karmatosed self-requested a review July 6, 2026 10:59

@karmatosed karmatosed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to merge from me and in checking.
We do need 2 approvals though to commit, so let's get another.

@mikeyarce
mikeyarce requested a review from bgrgicak July 20, 2026 19:22
@mikeyarce
mikeyarce merged commit 120d309 into trunk Jul 27, 2026
3 checks passed
@mikeyarce
mikeyarce deleted the add/theme-json-slug-normaliser-gotcha branch July 27, 2026 14:44
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.

3 participants