-
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
Adds suggestions for categories and formats to LinkControl #22600
Conversation
Size Change: +2.32 kB (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
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.
@draganescu I left a few minor notes but nothing big. You'll need to run this through a linter too to make travis happy. What worked for me in the past was npm run lint-php
. Overall this looks good and works so 👍
I think implementing this handling as a search handler makes a lot of sense, but I think the categories handler should be generic to any taxonomy, the same way We'll also want to implement links the same way the posts handler does but to the individual terms. |
Unit tests would be good here What about tags? |
Should this include all taxonomies and terms with show_in_rest = true as well as Authors/Users? |
Yes @rickalee I'm working on making the new endpoint generic for all terms :) |
I would suggest adding a Type chooser to the LinkControl that you can explicitly search for a Post (preselected), Term (Category, Tags or public Custom Post Types) and that developer can register their own Search Handler, and they will be shown in the LinkControl UI. You can get all types from I created a little Plugin as a Gist: https://gist.github.com/goaround/3a91ed216453bb19b9da69a9643468fa which registers a WP_REST_Taxonomy_Search_Handler and intercepts the search request if the query starts with |
I've changed the Category search handler into a Terms search handler that now looks for I still need to add tests to this PR. |
We'll also need to add links to |
68ba601
to
029c768
Compare
ed2a159
to
6d2cb57
Compare
adds a format search handler adds a category search handler hooks the new handlers in the search endpoint updates LinkControl's fetchLinkSuggestions to handle formats and categories as well
I've addressed all the feedback here and added unit tests. @TimothyBJacobs: Would you mind giving this another look? |
Thank you @noisysocks for taking this over, looks pretty good. Not merging before the OK from @TimothyBJacobs :) |
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.
Thanks for making those changes! I've left some more comments.
Possible to add author archives while building this? |
Right now I'm focused on only building out what's necessary for the new Navigation screen in Gutenberg. You're welcome to create a ticket in Trac for adding a new author archives search handler. You could copy and paste the code that's in this PR to get a head start on it. |
@TimothyBJacobs: Thanks for the great feedback! I addressed or responded to everything. |
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.
REST API wise everything looks good to me!
Description
Closes #20924 and closes #20165
How has this been tested?
Tested locally by:
a) having some categories setup
b) on a theme that supports post formats (twentyfourteen)
c) some posts saved as a post formats other than standard
Types of changes
PS
I don't know if this is the best way to implement this feature. However, because we need the link to the format index page, I can't see a better way to get it than from an API call. We could output formats in the bulk data which is rendered on load, but categories could be too many for this option.
cc @getdave - this updates indirectly
LinkControl
to show more types of suggestions. Suggestions welcome! :)