#52569 Create post-terms block variations for custom taxonomies in editor#52576
Closed
gaambo wants to merge 1 commit intoWordPress:trunkfrom
Closed
#52569 Create post-terms block variations for custom taxonomies in editor#52576gaambo wants to merge 1 commit intoWordPress:trunkfrom
gaambo wants to merge 1 commit intoWordPress:trunkfrom
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
This is a first try at fixing #52569.
I try to create the variations of the post-terms block for all custom taxonomies in the editor instead of on the server side.
Why?
See #52569 - server side function runs too early to make sure it gets all custom taxonomies by plugins, themes etc.
How?
I have to get the taxonomies from the rest api - and the results of them may come in async - therefore I have to use subscribe and unsubscribe. That's the only way I know right now how to get this kind of data (post types, taxonomies) on the "start" of the editor outside of react. If anyone has a better approach, I'm very happy to change this.
Therefore I'm using
registerBlockVariationas soon as the data is available and I can't use theblocks.registerBlockTypefilter as in the previous code.Some caveats:
_builtinproperty of taxonomies is not output via REST API. But by default the builtin taxonomies are registered first and therefore output first (and therefore added as a variation first).Testing Instructions
How to create custom taxonomy:
I've used the example code from developer.wordpress.org and put it in a simple plugin which I have mapped to load into gutenberg.
in
.wp-env.jsonadd:In this case i've added the sample plugin in a directory named "test-taxonomy" one level above the gutenberg directory.
TODO:
Screenshots or screencast