Opened 17 months ago
Last modified 15 months ago
#58887 new enhancement
Add a Pattern menu item to the "+ New" menu in the WP admin toolbar
Reported by: | poena | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Toolbar | Keywords: | has-patch has-testing-info has-screenshots 2nd-opinion |
Focuses: | Cc: |
Description
The WP admin toolbar has a menu with the text "New" and a dropdown with
links to adding a new post, media, page and user.
Consider adding a link to the patterns creation interface to this menu.
The new menu item should only be visible for users with the correct permissions.
Attachments (4)
Change History (20)
#1
@
17 months ago
- Milestone changed from Awaiting Review to 6.4
- Version trunk deleted
Moving for 6.4 consideration.
This ticket was mentioned in PR #5001 on WordPress/wordpress-develop by @khokansardar.
16 months ago
#2
- Keywords has-patch added
Trac ticket: #58887
#4
@
16 months ago
Thanks for the patch! This Pattern link is available for Authors and Editors but not Contributors or Subscribers (requires publish_posts
capability). However, I think it still needs to have a condition.
The link appears even when using the Disable Gutenberg plugin or when disabling blocks for all users with the Classic Editor plugin. New patterns usually would not be appropriate without the block editor (unless a JS error renders the editor unusable and a pattern needs correcting before the editor can be fixed). A conditional statement could check whether the block editor is in use and/or whether a pattern exists already.
#5
@
16 months ago
- Keywords needs-testing added
@sabernhardt yes you are right, we need to check conditional statement also. So, I have updated the patch. Now it should work with all condition. Thanks.
This ticket was mentioned in PR #5018 on WordPress/wordpress-develop by @khokansardar.
16 months ago
#6
Trac ticket: https://core.trac.wordpress.org/ticket/58887
#7
@
16 months ago
Test Report
Patch tested: https://core.trac.wordpress.org/attachment/ticket/58887/58887.1.diff
Env
- WordPress - 6.4-alpha-20230817.203813
- Web Server: Nginx
- Chrome Version - 115
- OS - macOS
- Theme: Twenty Twenty-Three
- PHP - 7.4.0
- Active Plugin - Tested with/without "Disable Gutenberg"
Test result
The test focused on assessing the availability and functionality of the 'Pattern' option in the Nav Bar under various scenarios. The results indicate the following:
- With the 'Disable Gutenberg' plugin active and the Block Editor disabled site-wide, the Pattern option correctly does not appear in the Nav Bar. ✅
- When the Block Editor is active, the Pattern option is appropriately displayed in the Nav Bar. ✅
- Clicking on 'Pattern' under the "+ New" tab successfully reveals the Pattern Tab. ✅
- Clicking on 'Pattern' leads to the expected redirection to the create Pattern Screen. ✅
- The Pattern option is appropriately available to users with the 'publish_posts' capability. ✅
✅ Suggested Enhancement works with patch.
After the patch-
Please note that I have examined all possible scenarios based on my understanding. If there are any additional scenarios that need to be confirmed or checked, please do let me know. Thank you!
#9
@
16 months ago
Pinging @richtabor @jameskoster @joen in case you have any input about adding admin toolbar shortcut to the pattern creation screen.
Also, I am not sure core should be making changes to support the classic editor plugin. Should it not be up to the plugin to remove the menu items it does not support? The block editor is the default.
#10
@
16 months ago
I do not like tacking on another item that those plugins would need to remove, but adding something like the following code to a plugin is probably easier than the removal of some stylesheets or the duotone SVGs has been for them.
function wptrac_remove_toolbar_pattern_link_node( $wp_admin_bar ) { $wp_admin_bar->remove_node( 'new-wp_block' ); } function wptrac_revise_new_content_menu() { add_action( 'admin_bar_menu', 'wptrac_remove_toolbar_pattern_link_node', 70 ); } add_action( 'add_admin_bar_menus', 'wptrac_revise_new_content_menu' );
Then the first patch might be fine.
#11
@
16 months ago
Thanks for the ping! I'm not sure the use case for this; when I create a new post, the action is clearly benefitting from an empty canvas, however a new pattern I nearly always create first in the block editor and then save as a pattern after the fact. In that light, I'd be reluctant to adding this, honestly.
#12
@
16 months ago
If you already know what kind of pattern you need, it is not intuitive or fast to create a new post or page, add the blocks, select the "create pattern" toolbar option, complete the options, and then trash the page.
#13
@
16 months ago
That would just be the in-the-flow bonus way to do it, though. The main way to create a pattern is to go into the site editor, into Patterns, then click the "add new" button. To that end it still makes sense to me to have just that, the site editor, as the central destination linked from the toolbar, and otherwise keep it lean. To me it's about balancing how often you do each of those actions; new post or new page you'd presumably do very often, whereas new patterns I would think a rarity. Having it in that dropdown would — not by a lot, mind you — but still add just that nanosecond of extra thinking, "which button do I click", and even afford you a mis-click.
The current menu in the WP admin toolbar