Skip to content

Commit

Permalink
Search: Add a hook on returning filters. (#10706)
Browse files Browse the repository at this point in the history
I recently had a use case where I wanted to add custom filters (i.e. not
a taxonomy, post type or date histogram) and found I could set the
filter no problem but get_filters would ignore it as it wasn't
supported.

I'd like to be able to easily support custom filters through a hook into
get_filters().
  • Loading branch information
jenkoian authored and jeherve committed Dec 19, 2018
1 parent 9069a68 commit cbd728c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/search/class.jetpack-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,20 @@ public function get_filters( WP_Query $query = null ) {
} // End foreach().
} // End foreach().

return $aggregation_data;
/**
* Modify the aggregation filters returned by get_filters().
*
* Useful if you are setting custom filters outside of the supported filters (taxonomy, post_type etc.) and
* want to hook them up so they're returned when you call `get_filters()`.
*
* @module search
*
* @since 6.9.0
*
* @param array $aggregation_data The array of filters keyed on label.
* @param WP_Query $query The WP_Query object.
*/
return apply_filters( 'jetpack_search_get_filters', $aggregation_data, $query );
}

/**
Expand Down

0 comments on commit cbd728c

Please sign in to comment.