Register Custom CPT's "Add New" Command in Command Pallete #70736
Register Custom CPT's "Add New" Command in Command Pallete #70736Mayank-Tripathi32 wants to merge 1 commit intoWordPress:trunkfrom
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.
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.
Why do we need to consider so many post types?
I think the code below is sufficient:
const excludedPostTypes = [ 'post', 'page', 'attachment' ];See:
There was a problem hiding this comment.
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! |
|
Thanks for letting me know, Just catching up on previous PR's 😄 |

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