-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Register Custom CPT's "Add New" Command in Command Pallete #70736
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
Register Custom CPT's "Add New" Command in Command Pallete #70736
Conversation
|
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. |
t-hamano
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 the PR!
The key point I think is to not use Dashicons, as it has been proposed to deprecate Dashicon strings: #43725
In other words, I believe we should accept that all post types render plus SVG icons for now as follows:
cc @WordPress/gutenberg-design
|
|
||
| // Filter to only include user-created custom post types | ||
| // Exclude system post types and core WordPress post types | ||
| const systemPostTypes = GLOBAL_SYSTEM_POST_TYPES; |
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.
Why do we need to consider so many post types?
I think the code below is sufficient:
const excludedPostTypes = [ 'post', 'page', 'attachment' ];See:
| const excludedPostTypes = [ 'attachment' ]; |
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.
got it, I will check it out.
|
I'd agree to avoid dashicons, and if need be fall back to the plus pending another icon being provided by the cpt. |
|
Hi @Mayank-Tripathi32, we decided to register menu commands based on the Menu API and implemented them in #71476. As a result, the custom CPT's commands are already registered now:
I'd like to close this PR, but thank you for your work! |

What?
Closes #70559
This PR enhances the WordPress Block Editor's Command Palette by adding dynamic "Add New" commands for custom post types (CPTs). Users can now quickly create new custom post types directly from the Command Palette, similar to how they can add new posts and pages.
Why?
Currently, the Command Palette only provides "Add new post" and "Add new page" commands. Users with custom post types need to navigate through the admin menu to create new content, which is inefficient. This enhancement improves the user experience by providing quick access to create any custom post type directly from the Command Palette.
How?
The implementation:
Testing Instructions
Custom Post Type Testing:
Edge Cases:
Testing Instructions for Keyboard
Screenshots
Before
After