-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Better navigation link variations for post types / taxonomies #56100
Better navigation link variations for post types / taxonomies #56100
Conversation
@draganescu This is a follow up to #54801 which fixes some code documentation but also handles post-type/taxonomy unregistration. Maybe you could have a look at this as well (sorry for spamming you 😅). |
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.
Good follow-up. Given how we add the variations this seems to be the logical way to remove them 👍🏻
@gaambo can you rebase and push this again, maybe we convince the tests to be green. If after doing this (I can't push to your repo) the auto merge still doesnt kick in I'll manually merge it. |
Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
Head branch was pushed to by a user without write access
58fa98d
to
bf6cc96
Compare
@draganescu thank you 🙏 I just rebased and pushed. |
Thank you @gaambo I merged the PR. |
@youknowriad this PR changes |
For me if the code is maintained in Gutenberg, the test should be as well and this is the case for the block library code so yeah, no need for backport. |
Added |
@draganescu This PR will not require a manual backport. Thank you. |
✅ I updated the PHP Sync Tracking Issue to note this PR does not require a backport. |
Changing the function name of |
I renamed the function to be more in line with the newly added |
@jonnynews I think what @gaambo explained is good, are we wrong? The function was barely added in a previous PR. |
What?
This is a follow up to #54801
It adds the following things:
show_in_nav_menus
set to false)Since the original PR was just merged into trunk and not released yet, I think renaming those functions is not a breaking change.
Why?
#54801 worked, but I missed some minor errors in code documentation and function naming.
Also @obache pointed out that unregistering of post types/taxonomies was not handled.
How?
Similar to registering the variations, it hooks into
unregistered_post_type
andunregistered_taxonomy
to unregister the variations. Since there is no server-side API for (un)registering variations, this is done directly by searching through the variations array of the registered block type - not ideal, but I see no other way atm.Testing Instructions
Testing unregistering
Post Type
Important: Set the item_link label or the block variation is called Post Link.
Important: change add_action priority to something higher than 10 (eg 11) - when using something lower it already works in trunk.
2. Unregister the custom post type after the navigation link block is registered and the variation is created:
Taxonomy
Important: Set the item_link label or the block variation is called Post Link.
Important: change add_action priority to something higher than 10 (eg 11) - when using something lower it already works in trunk.
2. Unregister the custom taxonomy after the navigation link block is registered and the variation is created:
Automated testing
Run
npm run test:unit:php:base -- --filter Block_Navigation_Link_Variations_Test
Testing Instructions for Keyboard
Screenshots or screencast