-
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
Navigation: Add variations for custom post types and taxonomies #24814
Comments
It's worth noting that it's already possible for plugins to register block variations for the block themselves. |
WordPress has a specific API for this already. Block-based menus need to observe the https://developer.wordpress.org/reference/functions/register_taxonomy/ |
I can take a look at this one. |
Reserving this comment for some research notes: Current data availability in blocks:We already have reducers/selectors available in the core data store.
Client filtering or core rest updates neededThe customizer currently filters for post types and taxonomies with: $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' ); Internally each We also cannot filter by Post Types response doesn't expose show_in_nav_menusThe taxonomy rest response exposes Unless I'm reading this incorrectly, if we try proxying this off another prop I think we'll implement this incorrectly. I don't think we can rely on Next Steps
|
I don't think you can register those block variations on the server because they wouldn't get propagated to the client as of today. See fields that are shared from the server to the client: In the future, we are going to migrate to using preloaded REST API response for registered block types: Now that I said that, I think that you might register those block variations by calling |
Thanks @gziolo, it sounds like I should try to experiment with some REST API updates in that case 👍 |
I'd just like to add my comments on this. The code in #28892 assumes that $attributes['type'] is set.
This would lead to a Notice when WP_DEBUG is true. See bobbingwide/fizzie#52 for the scenario I experienced. |
Yes I missed an
Since it's already set in data, I think the exception here is okay. It's also probably more familiar to folks if they are trying to edit markup by hand. In my not yet merged PR, I try to clarify this further by providing |
I was using Gutenberg 10.0.2 and hadn't read further down the issues. I have a workaround until I upgrade.
That's assuming the user hasn't changed the permalink Tag base on Settings > Permalinks. Re your PR: It will be interesting to see how unwieldy the navigation blocks become with one variation per post type and taxonomy. I'm using at least a dozen CPTs, some of which have 3 taxonomies, and some of these taxonomies are shared between post types. Additionally, for my A to Z letter pagination menu(s) each link needs the post type as well as the taxonomy term. Not an immediate problem since these menus are generated programmatically. |
Should be fixed by #29095, WordPress/wordpress-develop#1015 https://core.trac.wordpress.org/ticket/52688 |
#24670 added a Post, Page, Tag and Category variation to the Link block. We should extend this so that there is a Link variation for all post types and taxonomies that are registered using
register_post_type()
andregister_taxonomy()
. This will allow users to insert links to their third party post types and taxonomies.This can probably be done by having
packages/block-library/src/navigation-link/index.js
fetch the post types and taxonomies from the REST API using@wordpress/core-data
. It would then dynamically callregisterBlockVariation()
oncore/navigation-link
.See discussion at #24670 (comment).
The text was updated successfully, but these errors were encountered: