Skip to content
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

Fix: Term search in admin panel for non-public taxonomies #2988

Merged
merged 3 commits into from
Sep 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix: Term search in admin panel for non public taxonomies
  • Loading branch information
burhandodhy committed Sep 6, 2022
commit 0580f7c8d1df2311a2c1b601416cee48c06c33fa
18 changes: 18 additions & 0 deletions includes/classes/Indexable/Term/QueryIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function maybe_filter_query( $results, WP_Term_Query $query ) {
return $results;
}

if ( ! $this->is_indexable_taxonomies( $query ) ) {
return $results;
}

$new_terms = apply_filters( 'ep_wp_query_cached_terms', null, $query );

if ( null === $new_terms ) {
Expand Down Expand Up @@ -333,4 +337,18 @@ protected function format_hits_as_names( $terms, $new_terms ) {
return $new_terms;
}

/**
* Determine if all taxonomies are indexable.
*
* @param \WP_Term_Query $query The WP_Term_Query object.
* @return boolean
*/
protected function is_indexable_taxonomies( $query ) {

$taxonomies = $query->query_vars['taxonomy'];
$indexable_taxonomies = Indexables::factory()->get( 'term' )->get_indexable_taxonomies();

return empty( array_diff( $taxonomies, $indexable_taxonomies ) );
}

}