Introduce sniff to ensure theme pattern's filename and slug string match#348
Merged
Merged
Conversation
…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.
rmccue
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This guards against several classes of errors
-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.<!-- wp:patterncall 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.