*/ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } /** * Render field template. * * @param string $field Field. * @param string $label Label. * @param string $type Type. */ function opalestate_property_render_field_template( $field, $label, $type = 'select' ) { $qvalue = isset( $_GET['info'][ $field ] ) ? sanitize_text_field( $_GET['info'][ $field ] ) : ''; $template = apply_filters( 'opalestate_property_render_search_field_template', $field, $label ); $template = apply_filters( 'opalestate_property_' . $field . '_field_template', $template ); if ( $template == $field ) { $template = ''; } $input_default_value = apply_filters( 'opalestate_search_form_input_type_default_value', 0 ); if ( empty( $template ) ) { switch ( $type ) { case 'input': ?>
' . esc_html( $label ) . ''; $template .= ''; $template = sprintf( $template, $field, $label ); } elseif ( $display_type_search == 'text' ) { $option_values = opalestate_options( $setting_search_default_text, '' ); $qvalue = $qvalue ? $qvalue : $option_values; $template = ''; $template .= ''; $template = sprintf( $template, $field, $qvalue ); } elseif ( $display_type_search == 'range' ) { $min_name = 'min_' . $field; $max_name = 'max_' . $field; $search_min = (int) isset( $_GET[ $min_name ] ) ? $_GET[ $min_name ] : opalestate_options( $setting_search_min_range, 0 ); $search_max = (int) isset( $_GET[ $max_name ] ) ? $_GET[ $max_name ] : opalestate_options( $setting_search_max_range, 1000 ); $data = [ 'id' => $field, 'unit' => '', 'ranger_min' => opalestate_options( $setting_search_min_range, 0 ), 'ranger_max' => opalestate_options( $setting_search_max_range, 1000 ), 'input_min' => $search_min, 'input_max' => $search_max, 'unit_thousand' => apply_filters( 'opalestate_search_range_unit_thousand', opalestate_options( $setting_search_unit_thousand ), $field ), ]; ob_start(); opalesate_property_slide_ranger_template( __( $label . ": ", 'opalestate-pro' ), $data ); $template = ob_get_contents(); ob_end_clean(); } else { $template = ''; $template .= ''; $template = sprintf( $template, $field, $label ); } break; } } echo $template; // WPCS: XSS OK. } /** * Render area size field. */ function opalestate_property_areasize_field_template( $template = '' ) { $search_min = isset( $_GET['min_area'] ) ? sanitize_text_field( $_GET['min_area'] ) : opalestate_options( 'search_min_area', 0 ); $search_max = isset( $_GET['max_area'] ) ? sanitize_text_field( $_GET['max_area'] ) : opalestate_options( 'search_max_area', 1000 ); $measurement_units = opalestate_get_measurement_units(); $unit = opalestate_options( 'measurement_unit', 'sqft' ); if ( isset( $measurement_units[ $unit ] ) ) { $unit = $measurement_units[ $unit ]; } $data = [ 'id' => 'area', 'unit' => $unit . ' ', 'ranger_min' => opalestate_options( 'search_min_area', 0 ), 'ranger_max' => opalestate_options( 'search_max_area', 1000 ), 'input_min' => $search_min, 'input_max' => $search_max, 'unit_thousand' => apply_filters( 'opalestate_areasize_unit_thousand', ',' ), ]; opalesate_property_slide_ranger_template( esc_html__( 'Area', 'opalestate-pro' ), $data ); return; } add_filter( 'opalestate_property_areasize_field_template', 'opalestate_property_areasize_field_template' ); /** * Render slider ranger template. * * @param $label * @param $data */ function opalesate_property_slide_ranger_template( $label, $data ) { $default = [ 'id' => 'price', 'unit' => '', 'decimals' => 0, 'ranger_min' => 0, 'ranger_max' => 1000, 'input_min' => 0, 'input_max' => 1000, 'unit_position' => 'postfix', 'unit_thousand' => ',', 'mode' => 2, 'start' => '', 'step' => 1, ]; $data = array_merge( $default, $data ); extract( $data ); ?>