-
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 a home link that always points to home_url() #30975
Conversation
Size Change: +194 B (0%) Total Size: 1.46 MB
ℹ️ View Unchanged
|
Took this for a spin, and I'm used to recording GIFs, but you did such an excellent job already, I can only confirm I'm seeing the same. And give or take a few considerations, this feels like a good solution in that it's fairly basic and uses existing interfaces (block inserter) to accomplish it. It also seems like, if we solve #29423, then converting the Page List to manual menu items will map very well to this approach. Two considerations, none of which I feel are necessary to solve here to land this:
Number 2 is a more general thought about the quick inserter, and solutions should be looked at in context of all blocks, not just the navigation block. Reducing the frecency (making it change less often), and perhaps allowing a scrollbar or might help indicate that more blocks are available to insert. Ultimately that means I think this approach feels like the safest and smallest path forward, with few downsides. |
I actually prefer the implementation at #30926. A variation doesn't make a lot of sense to me given the block doesn't need editing of the url at all, nor nesting. By making it a variation the result is an increase in the complexity of the navigation link (by introducing |
Just wondering how we might consider this mapping to the wp menu items in the Navigation Editor. For example, if I'm using the Navigation Editor and I add the AFAIK the current menus system doesn't support the concept of a dynamic "Home" link. Therefore we might need to store this with some special meta data to ensure the Editor and the Nav Block know how to parse it back into a |
@getdave This is what I see when testing too. Using the customzier, adding a front page link is a custom link and does not get automatically updated when the static front page is changed. This means we have some flexibility in how this is used. If it's possible we could enhance the menu data to also support this dynamic link, or we can have it fallback to using the url value of whatever home_url was at the time of serialization. I do think we'd end up needing some sort of meta value for MenuData -> NavigationLink, possibly a type of home or something similar? |
To reduce confusion I'm also closing this PR for now in favor of #30926 which I'm still working on. |
Fixes #20542 Alternative to #30926
This PR adds a new navigation link variations that renders a link, backed by
home_url()
. While editing, this is auto-updated for a user. Note that it's entirely possible for this url value to get out of sync with what home_url(). Two simple examples are:Regardless of how someone may alter block attributes, the render_callback will ignore the url attribute in favor of
home_url()
. Updating this value in the editor is mainly to give the user a good experience for knowing where home_url currently points to.Areas that might need a bit of iteration is the new argument on LinkControl to avoid allowing users to edit a url.
homevariation.mp4
Testing Instructions
Depending on what version of WP we're using, variations provided to the NavigationLink are either defined in a fallback JS variations file, or in the server block registration.
WP 5.7.1 and below
WordPress Develop Master
ln -s your-gutenberg-checkout-path your-wordpress-local-path/wp-content/plugins/gutenberg
. Runnpm run build
in your gutenberg checkoutVerify that there are no errors in console or in the server error log.