fix: get only enabled filters in filters arguments

This commit is contained in:
vnmedeiros 2024-07-19 15:07:09 -03:00 committed by mateuswetah
parent 514fe1381b
commit 3c29f8a020
1 changed files with 12 additions and 2 deletions

View File

@ -456,6 +456,14 @@ class REST_Items_Controller extends REST_Controller {
*/
private function prepare_filters_arguments ( $args, $collection_id = false, $ignore_filter_arguments = [] ) {
$filters_arguments = array();
if(!empty($collection_id)) {
$collection = $this->collections_repository->fetch($collection_id);
$order = $collection->get_filters_order();
$order = ( is_array( $order ) ) ? $order : unserialize( $order );
}
$meta_query = isset($args['meta_query']) ? $args['meta_query'] : [];
if(isset($meta_query['value'])) $meta_query = [$meta_query];
$tax_query = isset($args['tax_query']) ? $args['tax_query'] : [];
@ -531,7 +539,9 @@ class REST_Items_Controller extends REST_Controller {
], 'OBJECT'
);
if ( !empty($filter) ) {
$filter_id = empty($filter) ? false : $filter[0]->get_id();
$filter_order_index = array_search( $filter_id, array_column( $order, 'id' ) );
if ( !empty($filter_order_index) && $order[$filter_order_index]['enabled'] == true) {
$f = $filter[0]->_toArray();
$filter_type_component = $filter[0]->get_filter_type_object()->get_component();
$m = $f['metadatum'];