Opal-Estate-Pro/inc/property/class-opalestate-search.php

582 lines
18 KiB
PHP
Raw Normal View History

2019-09-10 06:27:33 +02:00
<?php
/**
2019-10-12 06:07:50 +02:00
* OpalEstate_Search
2019-09-10 06:27:33 +02:00
*
* @package opalestate
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class OpalEstate_Search {
/**
* Add action to ajax search to display query data results with json format.
*/
public static function init() {
add_action( 'wp_ajax_opalestate_ajx_get_properties', [ __CLASS__, 'get_search_json' ] );
add_action( 'wp_ajax_nopriv_opalestate_ajx_get_properties', [ __CLASS__, 'get_search_json' ] );
add_action( 'wp_ajax_opalestate_render_get_properties', [ __CLASS__, 'render_get_properties' ] );
add_action( 'wp_ajax_nopriv_opalestate_render_get_properties', [ __CLASS__, 'render_get_properties' ] );
}
/**
2019-10-12 06:07:50 +02:00
* Get Query Object to display collection of property with user request which submited via search form.
*
* @param int $limit Limit.
2019-09-10 06:27:33 +02:00
*/
public static function get_search_results_query( $limit = 9 ) {
global $wp_query;
2020-06-12 05:23:13 +02:00
$search_min_price = '';
$search_max_price = '';
if ( isset( $_GET['min_price'] ) || isset( $_GET['max_price'] ) ) {
$search_min_price = isset( $_GET['min_price'] ) ? sanitize_text_field( $_GET['min_price'] ) : '';
$search_max_price = isset( $_GET['max_price'] ) ? sanitize_text_field( $_GET['max_price'] ) : '';
} elseif ( isset( $_GET['range_price'] ) ) {
$range_price = explode( '-', sanitize_text_field( $_GET['range_price'] ) );
if ( isset( $range_price[0] ) && isset( $range_price[1] ) ) {
$search_min_price = 'min' !== $range_price[0] ? $range_price[0] : '';
$search_max_price = 'max' !== $range_price[1] ? $range_price[1] : '';
}
}
$search_min_area = '';
$search_max_area = '';
if ( isset( $_GET['min_area'] ) || isset( $_GET['max_area'] ) ) {
$search_min_area = isset( $_GET['min_area'] ) ? sanitize_text_field( $_GET['min_area'] ) : '';
$search_max_area = isset( $_GET['max_area'] ) ? sanitize_text_field( $_GET['max_area'] ) : '';
} elseif ( isset( $_GET['range_area'] ) ) {
$range_area = explode( '-', sanitize_text_field( $_GET['range_area'] ) );
if ( isset( $range_area[0] ) && isset( $range_area[1] ) ) {
$search_min_area = 'min' !== $range_area[0] ? $range_area[0] : '';
$search_max_area = 'max' !== $range_area[1] ? $range_area[1] : '';
}
}
2019-09-10 06:27:33 +02:00
2020-06-12 05:23:13 +02:00
$s = isset( $_GET['search_text'] ) ? sanitize_text_field( $_GET['search_text'] ) : null;
2019-09-10 06:27:33 +02:00
$posts_per_page = apply_filters( 'opalestate_search_property_per_page', opalestate_options( 'search_property_per_page', $limit ) );
2020-05-04 10:53:09 +02:00
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
2019-09-10 06:27:33 +02:00
$paged = isset( $wp_query->query['paged'] ) ? $wp_query->query['paged'] : $paged;
$paged = ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : $paged;
2020-05-04 10:53:09 +02:00
if ( isset( $_GET['paged'] ) && absint( $_GET['paged'] ) > 0 ) {
$paged = absint( $_GET['paged'] );
2019-09-10 06:27:33 +02:00
}
$args = [
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'post_type' => 'opalestate_property',
'post_status' => 'publish',
's' => $s,
];
$tax_query = [];
if ( isset( $_GET['location'] ) && $_GET['location'] != -1 ) {
2020-06-16 12:34:51 +02:00
if ( is_array( $_GET['location'] ) ) {
$tax_query[] = [
'taxonomy' => 'opalestate_location',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['location'] ),
];
} else {
$tax_query[] = [
'taxonomy' => 'opalestate_location',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['location'] ),
];
}
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['state'] ) && $_GET['state'] != -1 ) {
2020-05-04 10:53:09 +02:00
if ( is_array( $_GET['state'] ) ) {
$tax_query[] = [
'taxonomy' => 'opalestate_state',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['state'] ),
];
} else {
$tax_query[] = [
2019-09-10 06:27:33 +02:00
'taxonomy' => 'opalestate_state',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['state'] ),
];
2020-05-04 10:53:09 +02:00
}
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['city'] ) && $_GET['city'] != -1 ) {
2020-06-16 12:34:51 +02:00
if ( is_array( $_GET['city'] ) ) {
$tax_query[] = [
'taxonomy' => 'opalestate_city',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['city'] ),
];
} else {
$tax_query[] = [
'taxonomy' => 'opalestate_city',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['city'] ),
];
}
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['types'] ) && $_GET['types'] != -1 ) {
2020-05-04 10:53:09 +02:00
if ( is_array( $_GET['types'] ) ) {
$tax_query[] = [
'taxonomy' => 'opalestate_types',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['types'] ),
];
} else {
$tax_query[] = [
2019-09-10 06:27:33 +02:00
'taxonomy' => 'opalestate_types',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['types'] ),
];
2020-05-04 10:53:09 +02:00
}
2019-09-10 06:27:33 +02:00
}
2019-10-09 12:23:19 +02:00
if ( isset( $_GET['cat'] ) && $_GET['cat'] != -1 ) {
2020-05-04 10:53:09 +02:00
if ( is_array( $_GET['cat'] ) ) {
$tax_query[] = [
'taxonomy' => 'property_category',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['cat'] ),
];
} else {
$tax_query[] = [
2019-10-09 12:23:19 +02:00
'taxonomy' => 'property_category',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['cat'] ),
];
2020-05-04 10:53:09 +02:00
}
2019-10-09 12:23:19 +02:00
}
2019-09-10 06:27:33 +02:00
if ( isset( $_GET['status'] ) && $_GET['status'] != -1 ) {
2020-05-04 10:53:09 +02:00
if ( is_array( $_GET['status'] ) ) {
$tax_query[] = [
'taxonomy' => 'opalestate_status',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['status'] ),
];
} else {
$tax_query[] = [
2019-09-10 06:27:33 +02:00
'taxonomy' => 'opalestate_status',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['status'] ),
];
2020-05-04 10:53:09 +02:00
}
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['amenities'] ) && is_array( $_GET['amenities'] ) ) {
2020-05-04 10:53:09 +02:00
$tax_query[] = [
'taxonomy' => 'opalestate_amenities',
'field' => 'slug',
'terms' => opalestate_clean( $_GET['amenities'] ),
];
2019-09-10 06:27:33 +02:00
}
2020-06-16 12:34:51 +02:00
$tax_query = apply_filters( 'opalestate_search_results_tax_query', $tax_query );
2019-09-10 06:27:33 +02:00
if ( $tax_query ) {
$args['tax_query'] = [ 'relation' => 'AND' ];
$args['tax_query'] = array_merge( $args['tax_query'], $tax_query );
}
$args['meta_query'] = [ 'relation' => 'AND' ];
if ( isset( $_GET['info'] ) && is_array( $_GET['info'] ) ) {
$metaquery = [];
2019-10-12 06:07:50 +02:00
2019-09-10 06:27:33 +02:00
foreach ( $_GET['info'] as $key => $value ) {
if ( trim( $value ) ) {
if ( is_numeric( trim( $value ) ) ) {
$fieldquery = [
'key' => OPALESTATE_PROPERTY_PREFIX . $key,
'value' => sanitize_text_field( trim( $value ) ),
2019-10-12 06:07:50 +02:00
'compare' => apply_filters( 'opalestate_info_numeric_compare', '>=' ),
2019-09-10 06:27:33 +02:00
'type' => 'NUMERIC',
];
} else {
$fieldquery = [
'key' => OPALESTATE_PROPERTY_PREFIX . $key,
'value' => sanitize_text_field( trim( $value ) ),
'compare' => 'LIKE',
];
}
$sarg = apply_filters( 'opalestate_search_field_query_' . $key, $fieldquery );
$metaquery[] = $sarg;
}
}
2019-10-12 06:07:50 +02:00
2019-09-10 06:27:33 +02:00
$args['meta_query'] = array_merge( $args['meta_query'], $metaquery );
}
2019-10-29 08:25:28 +01:00
if ( $search_min_price != '' && $search_max_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) {
2019-09-10 06:27:33 +02:00
if ( $search_min_price ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'price',
'value' => [ $search_min_price, $search_max_price ],
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
} else {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
[
[
'key' => OPALESTATE_PROPERTY_PREFIX . 'price',
'compare' => 'NOT EXISTS',
],
'relation' => 'OR',
[
'key' => OPALESTATE_PROPERTY_PREFIX . 'price',
'value' => $search_max_price,
'compare' => '<=',
'type' => 'NUMERIC',
],
],
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
}
} elseif ( $search_min_price != '' && is_numeric( $search_min_price ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'price',
'value' => $search_min_price,
'compare' => '>=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
} elseif ( $search_max_price != '' && is_numeric( $search_max_price ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'price',
'value' => $search_max_price,
'compare' => '<=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
}
2019-10-29 08:25:28 +01:00
if ( $search_min_area != '' && $search_max_area != '' && is_numeric( $search_min_area ) && is_numeric( $search_max_area ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'areasize',
'value' => [ $search_min_area, $search_max_area ],
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
} elseif ( $search_min_area != '' && is_numeric( $search_min_area ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'areasize',
'value' => $search_min_area,
'compare' => '>=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
} elseif ( $search_max_area != '' && is_numeric( $search_max_area ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'areasize',
'value' => $search_max_area,
'compare' => '<=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['geo_long'] ) && isset( $_GET['geo_lat'] ) ) {
if ( $_GET['location_text'] && ( empty( $_GET['geo_long'] ) || empty( $_GET['geo_lat'] ) ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_PROPERTY_PREFIX . 'map_address',
'value' => sanitize_text_field( trim( $_GET['location_text'] ) ),
'compare' => 'LIKE',
'operator' => 'OR',
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
} elseif ( $_GET['geo_lat'] && $_GET['geo_long'] ) {
2020-06-18 06:09:45 +02:00
$radius_measure = isset( $_GET['radius_measure'] ) ? sanitize_text_field( $_GET['radius_measure'] ) : 'km';
$radius = isset( $_GET['geo_radius'] ) ? sanitize_text_field( $_GET['geo_radius'] ) : 10;
2020-06-25 05:00:06 +02:00
$post_ids = Opalestate_Query::filter_by_location( sanitize_text_field( $_GET['geo_lat'] ), sanitize_text_field( $_GET['geo_long'] ), $radius, $radius_measure );
2019-09-10 06:27:33 +02:00
$args['post__in'] = $post_ids;
}
}
$ksearchs = [];
if ( isset( $_REQUEST['opalsortable'] ) && ! empty( $_REQUEST['opalsortable'] ) ) {
2019-10-29 08:25:28 +01:00
$ksearchs = explode( '_', $_REQUEST['opalsortable'] );
2019-09-10 06:27:33 +02:00
} elseif ( isset( $_SESSION['opalsortable'] ) && ! empty( $_SESSION['opalsortable'] ) ) {
2019-10-29 08:25:28 +01:00
$ksearchs = explode( '_', $_SESSION['opalsortable'] );
2019-09-10 06:27:33 +02:00
}
if ( ! empty( $ksearchs ) && count( $ksearchs ) == 2 ) {
2019-12-11 09:59:02 +01:00
if ( 'featured' === $ksearchs[0] ) {
$args['orderby'] = [ 'meta_value' => 'DESC', 'date' => 'DESC' ];
$args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured';
} else {
$args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0];
$args['orderby'] = 'meta_value_num';
$args['order'] = $ksearchs[1];
}
2020-05-04 10:53:09 +02:00
} elseif ( 'on' === opalestate_options( 'show_featured_first', 'off' ) ) {
2019-12-11 09:59:02 +01:00
$args['orderby'] = [ 'meta_value' => 'DESC', 'date' => 'DESC' ];
2019-10-31 04:58:21 +01:00
$args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured';
2019-09-10 06:27:33 +02:00
}
2019-10-29 08:25:28 +01:00
$metas = Opalestate_Property_MetaBox::metaboxes_info_fields();
foreach ( $metas as $meta ) {
if ( $meta['id'] == OPALESTATE_PROPERTY_PREFIX . 'areasize' ) {
continue;
}
$request = str_replace( OPALESTATE_PROPERTY_PREFIX, '', $meta['id'] );
$setting_search_type = opalestate_options( $meta['id'] . '_search_type', 'select' );
if ( 'range' === $setting_search_type ) {
$min_request = isset( $_GET[ 'min_' . $request ] ) ? sanitize_text_field( $_GET[ 'min_' . $request ] ) : '';
$max_request = isset( $_GET[ 'max_' . $request ] ) ? sanitize_text_field( $_GET[ 'max_' . $request ] ) : '';
if ( $min_request != '' && $max_request != '' && is_numeric( $min_request ) && is_numeric( $max_request ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-10-29 08:25:28 +01:00
'key' => $meta['id'],
'value' => [ $min_request, $max_request ],
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-10-29 08:25:28 +01:00
} elseif ( $min_request != '' && is_numeric( $min_request ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-10-29 08:25:28 +01:00
'key' => $meta['id'],
'value' => $min_request,
'compare' => '>=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-10-29 08:25:28 +01:00
} elseif ( $max_request != '' && is_numeric( $max_request ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-10-29 08:25:28 +01:00
'key' => $meta['id'],
'value' => $max_request,
'compare' => '<=',
'type' => 'NUMERIC',
2020-05-04 10:53:09 +02:00
];
2019-10-29 08:25:28 +01:00
}
}
}
2019-09-10 06:27:33 +02:00
2019-10-29 08:25:28 +01:00
$args = apply_filters( 'opalestate_get_search_results_query_args', $args );
2019-09-10 06:27:33 +02:00
$query = new WP_Query( $args );
wp_reset_postdata();
return $query;
}
/**
* Get search query base on user request to filter collection of Agents
*/
public static function get_search_agents_query( $args = [] ) {
$min = opalestate_options( 'search_agent_min_price', 0 );
$max = opalestate_options( 'search_agent_max_price', 10000000 );
$search_min_price = isset( $_GET['min_price'] ) ? sanitize_text_field( $_GET['min_price'] ) : '';
$search_max_price = isset( $_GET['max_price'] ) ? sanitize_text_field( $_GET['max_price'] ) : '';
$search_min_area = isset( $_GET['min_area'] ) ? sanitize_text_field( $_GET['min_area'] ) : '';
$search_max_area = isset( $_GET['max_area'] ) ? sanitize_text_field( $_GET['max_area'] ) : '';
$s = isset( $_GET['search_text'] ) ? sanitize_text_field( $_GET['search_text'] ) : null;
$paged = ( get_query_var( 'paged' ) == 0 ) ? 1 : get_query_var( 'paged' );
$default = [
'post_type' => 'opalestate_agent',
'posts_per_page' => apply_filters( 'opalestate_agent_per_page', 12 ),
'paged' => $paged,
];
$args = array_merge( $default, $args );
$tax_query = [];
if ( isset( $_GET['location'] ) && $_GET['location'] != -1 ) {
$tax_query[] =
[
'taxonomy' => 'opalestate_location',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['location'] ),
];
}
if ( isset( $_GET['types'] ) && $_GET['types'] != -1 ) {
$tax_query[] =
[
'taxonomy' => 'opalestate_types',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['types'] ),
];
}
if ( $tax_query ) {
$args['tax_query'] = [ 'relation' => 'AND' ];
$args['tax_query'] = array_merge( $args['tax_query'], $tax_query );
}
$args['meta_query'] = [ 'relation' => 'AND' ];
if ( $search_min_price != $min && is_numeric( $search_min_price ) ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_AGENT_PREFIX . 'target_min_price',
'value' => $search_min_price,
'compare' => '>=',
// 'type' => 'NUMERIC'
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
}
if ( is_numeric( $search_max_price ) && $search_max_price != $max ) {
2020-05-04 10:53:09 +02:00
$args['meta_query'][] = [
2019-09-10 06:27:33 +02:00
'key' => OPALESTATE_AGENT_PREFIX . 'target_max_price',
'value' => $search_max_price,
'compare' => '<=',
// 'type' => 'NUMERIC'
2020-05-04 10:53:09 +02:00
];
2019-09-10 06:27:33 +02:00
}
return new WP_Query( $args );
}
/**
* Get search query base on user request to filter collection of Agents
*/
public static function get_search_agencies_query( $args = [] ) {
$s = isset( $_GET['search_text'] ) ? sanitize_text_field( $_GET['search_text'] ) : null;
$paged = ( get_query_var( 'paged' ) == 0 ) ? 1 : get_query_var( 'paged' );
$default = [
'post_type' => 'opalestate_agency',
'posts_per_page' => apply_filters( 'opalestate_agency_per_page', 12 ),
'paged' => $paged,
];
$args = array_merge( $default, $args );
$tax_query = [];
if ( isset( $_GET['location'] ) && $_GET['location'] != -1 ) {
2020-05-04 10:53:09 +02:00
$tax_query[] = [
'taxonomy' => 'opalestate_location',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['location'] ),
];
2019-09-10 06:27:33 +02:00
}
if ( isset( $_GET['types'] ) && $_GET['types'] != -1 ) {
2020-05-04 10:53:09 +02:00
$tax_query[] = [
'taxonomy' => 'opalestate_types',
'field' => 'slug',
'terms' => sanitize_text_field( $_GET['types'] ),
];
2019-09-10 06:27:33 +02:00
}
if ( $tax_query ) {
$args['tax_query'] = [ 'relation' => 'AND' ];
$args['tax_query'] = array_merge( $args['tax_query'], $tax_query );
}
$args['meta_query'] = [ 'relation' => 'AND' ];
return new WP_Query( $args );
}
public function filter_by_geolocations() {
}
/**
2019-10-10 04:09:06 +02:00
* Get_setting_search_fields.
2019-09-10 06:27:33 +02:00
*/
public static function get_setting_search_fields( $option = '' ) {
2019-10-10 04:09:06 +02:00
$default = apply_filters( 'opalestate_default_fields_setting', [
2019-09-10 06:27:33 +02:00
OPALESTATE_PROPERTY_PREFIX . 'bedrooms' => esc_html__( 'Bed Rooms', 'opalestate-pro' ),
OPALESTATE_PROPERTY_PREFIX . 'parking' => esc_html__( 'Parking', 'opalestate-pro' ),
OPALESTATE_PROPERTY_PREFIX . 'bathrooms' => esc_html__( 'Bath Rooms', 'opalestate-pro' ),
2019-10-10 04:09:06 +02:00
] );
2019-09-10 06:27:33 +02:00
2019-10-10 04:09:06 +02:00
$metas = Opalestate_Property_MetaBox::metaboxes_info_fields();
2019-09-10 06:27:33 +02:00
$esettings = [];
$found = false;
foreach ( $metas as $key => $meta ) {
$value = opalestate_options( $meta['id'] . '_opt' . $option );
if ( preg_match( "#areasize#", $meta['id'] ) ) {
continue;
}
2020-05-04 10:53:09 +02:00
if ( 'on' === $value ) {
2019-10-10 04:09:06 +02:00
$id = str_replace( OPALESTATE_PROPERTY_PREFIX, '', $meta['id'] );
2019-09-10 06:27:33 +02:00
$esettings[ $id ] = $meta['name'];
}
2019-10-10 04:09:06 +02:00
2019-09-10 06:27:33 +02:00
if ( $value == 0 ) {
$found = true;
}
}
if ( ! empty( $esettings ) ) {
return $esettings;
} elseif ( $found ) {
return [];
}
return $default;
}
/**
* Get Json data by action ajax filter
*/
public static function get_search_json() {
$query = self::get_search_results_query();
$output = [];
while ( $query->have_posts() ) {
$query->the_post();
$property = opalesetate_property( get_the_ID() );
$output[] = $property->get_meta_search_objects();
}
wp_reset_query();
echo json_encode( $output );
exit;
}
public static function render_get_properties() {
echo opalestate_load_template_path( 'shortcodes/ajax-map-search-result' );
die;
}
/**
* Render search property form in horizontal
*/
public static function render_horizontal_form( $atts = [] ) {
echo opalestate_load_template_path( 'search-box/search-form-h', $atts );
}
/**
* Render search property form in vertical
*/
public static function render_vertical_form( $atts = [] ) {
echo opalestate_load_template_path( 'search-box/search-form-v', $atts );
}
/**
*
*/
public static function render_field_price() {
}
/**
*
*/
public static function render_field_area() {
}
}
OpalEstate_Search::init();