diff --git a/inc/api/functions.php b/inc/api/functions.php index 84e996d5..ede19273 100644 --- a/inc/api/functions.php +++ b/inc/api/functions.php @@ -139,10 +139,21 @@ function opalestate_api_get_property_data( $property_info ) { $property['labels'] = $data->get_labels(); $property['locations'] = $data->get_locations(); $property['facilities'] = $data->get_facilities(); - $property['amenities'] = $data->get_amenities(); - $property['types'] = $data->get_types_tax(); - $property['author_type'] = $data->get_author_type(); - $property['author_data'] = $data->get_author_link_data(); + + $amenities = $data->get_amenities(); + $amenities_result = []; + if ( $amenities ) { + foreach ( $amenities as $amenity ) { + $value = has_term( $amenity->term_id, 'opalestate_amenities', $property_info->ID ); + $amenity->value = $value; + $amenities_result[] = $amenity; + } + } + + $property['amenities'] = $amenities_result; + $property['types'] = $data->get_types_tax(); + $property['author_type'] = $data->get_author_type(); + $property['author_data'] = $data->get_author_link_data(); $limit = opalestate_get_option( 'single_views_statistics_limit', 8 ); $stats = new Opalestate_View_Stats( $data->get_id(), $limit ); diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index 9f6365e5..46933060 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -114,7 +114,7 @@ class OpalEstate_Search { [ 'taxonomy' => 'opalestate_amenities', 'field' => 'slug', - 'terms' => sanitize_text_field( $_GET['amenities'] ), + 'terms' => ( $_GET['amenities'] ), ]; } @@ -153,7 +153,6 @@ class OpalEstate_Search { if ( $search_min_price != '' && $search_max_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) { if ( $search_min_price ) { - array_push( $args['meta_query'], [ 'key' => OPALESTATE_PROPERTY_PREFIX . 'price', 'value' => [ $search_min_price, $search_max_price ],