-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Patterns: Refactor the findOrCreate term method #57655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…y already exist, and fix bug that allowed different cased labels that could then not be selected
|
Size Change: +19 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
… once in testing, but haven't been able to replicate, but no disadvantage in having this code just in case
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @glendaviesnz for picking this up and @ntsekouras for flagging the improvements 👍
The changes LGTM and test as advertised.
✅ Adding a new category that doesn't exist in the taxonomy or core works
✅ When adding a new category the endpoint is correctly called
✅ When adding a second pattern to the new category the endpoint is not called
✅ Creating a new pattern for the core Headers category does result in a user category with a header slug being created
✅ Assigning a new pattern to banners on a site without user categories results in the category being added as Banners matching the core category
ntsekouras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for handling this Glen! I left a small comment but this looks good.
What?
Refactors the findOrCreate term method to not call the API if the user category already exists, and fixes a bug that allowed different cased labels that could then not be selected.
Why?
How?
Testing Instructions
Horses/v2/wp_pattern_categoryendpoint was called and the category was added successfullyHorsescategory and check that/v2/wp_pattern_categorywas not called and the category was successfully assigned to the patternHeadersHeaderswas added with slug ofheaderbannerswith lower caseband check that the category is added asBannersto match the existing core category