#55606 closed enhancement (fixed)
Add 'ajax_term_search_results' filter
Reported by: | grandeljay | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Taxonomy | Keywords: | has-screenshots has-patch needs-dev-note |
Focuses: | Cc: |
Description
I want to create a plugin which suggests existing tags, if they are similar to existing tags. For this I want to hook into the term results, but it seems there is no way to. This filter should solve that.
Attachments (2)
Change History (18)
This ticket was mentioned in PR #2620 on WordPress/wordpress-develop by grandeljay.
2 years ago
#1
#2
@
2 years ago
- Keywords changes-requested needs-unit-tests added
- Milestone changed from Awaiting Review to 6.1
- Severity changed from trivial to normal
- Version changed from trunk to 3.1
Hi @grandeljay, welcome to Trac and thanks for the PR!
I have added some thoughts in my review.
#3
@
2 years ago
Thanks @costdev!
I've added my replies (not sure if you get notifications for those).
grandeljay commented on PR #2620:
2 years ago
#4
I think I figured out what went wrong with the unit test. It should work now 👍🏼
#5
@
2 years ago
- Keywords needs-testing needs-testing-info added; changes-requested needs-unit-tests removed
Referenced PR 2620 resolved dev reviewer feedback and includes unit tests. Tagged to move forward with testing.
#6
@
2 years ago
PR tested using the following snippet:
function append_kokomo_tags( $results, $tax, $s ) { $kokomo = array( 'aruba', 'bermuda', 'key largo', 'montego' ); $results = array_merge( $results, $kokomo ); return $results; } add_filter( 'wp_after_tag_search', 'append_kokomo_tags', 10, 3 );
Works fine.
#7
@
2 years ago
- Keywords needs-testing needs-testing-info removed
- Owner set to audrasjb
- Status changed from new to accepted
#10
follow-up:
↓ 11
@
2 years ago
- Keywords changes-requested added; commit removed
For consistency with the existing term_search_min_chars
filter just a few lines above in the same function, I think term_search_results
would be a better name for this filter. (Starting them both with ajax_term_search_*
, or ajax_tag_search_*
to match the function name, would perhaps have been even better, but that ship has sailed.)
Generally, it appears that core uses the *_after_*
wording for actions, not for filters.
#11
in reply to:
↑ 10
@
2 years ago
Replying to SergeyBiryukov:
For consistency with the existing
term_search_min_chars
filter just a few lines above in the same function, I thinkterm_search_results
would be a better name for this filter.
Thinking about this some more, that seems a bit too generic :) Maybe ajax_term_search_results
? Though it does not exactly align with the existing filter, I think it might be helpful to be more specific here.
2 years ago
#15
Committed in https://core.trac.wordpress.org/changeset/53781
https://core.trac.wordpress.org/ticket/55606
I want to create a plugin which suggests existing tags, if they are similar to existing tags. For this I want to hook into the term results, but it seems there is no way to. This filter should solve that.