-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: JavaScript error when pattern category is unregistered #67063
Conversation
Because the wp_pattern_category taxonomy can be unregistered, it needs to be used conditionally in the JavaScript code, or there may be JavaScript errors.
This is a follow up to #66945 #66889 Also, while it does not break the editors in a way that make them unusable, it is not correct and a strange user experience that it is still possible to enter a custom category name during pattern creation, even if the taxonomy is unregistered. |
Size Change: +2 B (0%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
From my own search through the code, I think you've found all the occurrences. LGTM, but please see my inline comment about adding an extra guard.
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.
LGTM, thanks!
What?
Because the wp_pattern_category taxonomy can be unregistered, it needs to be used conditionally in the JavaScript code, or there may be JavaScript errors.
Closes #67060
Testing Instructions
Unregister the wp_pattern_category taxonomy.
For example, copy the following to functions.php in your active theme:
Please test the following and watch for any regressions or JavaScript errors:
Repeat and create 3 more patterns:
Synced with custom category
Unsynced without category
Unsycned with custom category
Go to the pattern dataviews page (Appearance > Editor > Patterns or Appearance > Patterns depending on your theme)
Create the different patterns using the "Add New Pattern" button.
Confirm that the custom category you created when creating patterns is not listed in the sidebar with the other pattern categories.