Skip to content

Introduce sniff to ensure theme pattern's filename and slug string match#348

Merged
kadamwhite merged 1 commit into
mainfrom
add-pattern-filename-slug-match-sniff
Jul 10, 2026
Merged

Introduce sniff to ensure theme pattern's filename and slug string match#348
kadamwhite merged 1 commit into
mainfrom
add-pattern-filename-slug-match-sniff

Conversation

@kadamwhite

Copy link
Copy Markdown
Collaborator

This guards against several classes of errors

  • Agent-generated patterns have sometimes included non-- separators (using en-dashes, etc), which cause a warning within WP because a pattern's slug must be basic ASCII even if the filename itself is correct. Forcing the pattern name to match the filename reduces the chance this slips through codereview unnoticed.
  • Avoids accidentally "shadowing" one pattern with another (two patterns with the same slug) because filenames must be unique. Shadowing a pattern doesn't cause an error but has caused confusion when references to the expected (filename-matching) slug of the pattern in a <!-- wp:pattern call then fail silently, because one of the two patterns isn't registered and the other might not have the expected content.

It also makes it straightforward to jump to / find the pattern file in your IDE if you know the slug from the Editor's code view.

…the pattern's slug

This guards against several classes of errors

- Agent-generated patterns have sometimes included non-`-` separators (using en-dashes, etc), which cause a warning within WP because a pattern's slug must be basic ASCII even if the filename itself is correct. Forcing the pattern name to match the filename reduces the chance this slips through codereview unnoticed.
- Avoids accidentally "shadowing" one pattern with another (two patterns with the same slug) because filenames must be unique. Shadowing a pattern doesn't cause an error but _has_ caused confusion when references to the _expected_ (filename-matching) slug of the pattern in a `<!-- wp:pattern` call then fail silently, because one of the two patterns isn't registered and the other might not have the expected content.

It also makes it straightforward to jump to / find the pattern file in your IDE if you know the slug from the Editor's code view.
@kadamwhite kadamwhite requested review from joeleenk and roborourke July 9, 2026 17:53
@kadamwhite kadamwhite merged commit a22e869 into main Jul 10, 2026
3 checks passed
@kadamwhite kadamwhite deleted the add-pattern-filename-slug-match-sniff branch July 10, 2026 15:56
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.

2 participants