2019-09-10 06:27:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Search field templates.
|
|
|
|
*
|
|
|
|
* @package opalestate
|
|
|
|
* @author Opal Team <info@wpopal.com >
|
|
|
|
*/
|
|
|
|
|
|
|
|
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 = '';
|
|
|
|
}
|
|
|
|
|
2020-03-17 04:14:59 +01:00
|
|
|
$input_default_value = apply_filters( 'opalestate_search_form_input_type_default_value', 0 );
|
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
if ( empty( $template ) ) {
|
|
|
|
switch ( $type ) {
|
|
|
|
case 'input': ?>
|
|
|
|
<label class="opalestate-label opalestate-label--<?php echo sanitize_html_class( $field ); ?>"><?php echo esc_html( $label ); ?></label>
|
|
|
|
<div class="input-group-number">
|
2019-09-28 08:37:40 +02:00
|
|
|
<i class="<?php echo opalestate_get_property_meta_icon( $field ); ?>"></i>
|
2020-03-17 04:14:59 +01:00
|
|
|
<input class="form-control" value="<?php echo $qvalue ? $qvalue : $input_default_value; ?>" type="text" name="info[<?php echo $field; ?>]" placeholder="<?php echo esc_attr(
|
2020-03-24 05:39:25 +01:00
|
|
|
$label ); ?>"/>
|
2019-09-10 06:27:33 +02:00
|
|
|
<div class="btn-actions">
|
|
|
|
<span class="btn-minus"><i class="fa fa-minus"></i></span>
|
|
|
|
<span class="btn-plus"><i class="fa fa-plus"></i></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-26 11:36:18 +02:00
|
|
|
<?php
|
|
|
|
break;
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
default:
|
2020-02-20 04:39:15 +01:00
|
|
|
$setting_search_type = 'opalestate_ppt_' . $field . '_search_type';
|
|
|
|
$setting_search_type_options = 'opalestate_ppt_' . $field . '_options_value';
|
|
|
|
$setting_search_min_range = 'opalestate_ppt_' . $field . '_min_range';
|
|
|
|
$setting_search_max_range = 'opalestate_ppt_' . $field . '_max_range';
|
|
|
|
$setting_search_unit_thousand = 'opalestate_ppt_' . $field . '_unit_thousand';
|
|
|
|
$setting_search_default_text = 'opalestate_ppt_' . $field . '_default_text';
|
2019-10-26 11:36:18 +02:00
|
|
|
|
|
|
|
$display_type_search = opalestate_options( $setting_search_type, 'select' );
|
|
|
|
|
|
|
|
if ( $display_type_search == 'select' ) {
|
|
|
|
|
|
|
|
$option_values = (array) explode( ',', opalestate_options( $setting_search_type_options, '1,2,3,4,5,6,7,8,9,10' ) );
|
2020-02-20 04:39:15 +01:00
|
|
|
$template = '<label class="opalestate-label opalestate-label--' . sanitize_html_class( $label ) . '">' . esc_html( $label ) . '</label>';
|
|
|
|
$template .= '<select class="form-control" name="info[%s]"><option value="">%s</option>';
|
2019-10-26 11:36:18 +02:00
|
|
|
|
|
|
|
foreach ( $option_values as $value ) {
|
|
|
|
$selected = $value == $qvalue ? 'selected="selected"' : '';
|
|
|
|
$template .= '<option ' . $selected . ' value="' . $value . '">' . $value . '</option>';
|
|
|
|
}
|
|
|
|
$template .= '</select>';
|
|
|
|
$template = sprintf( $template, $field, $label );
|
|
|
|
|
|
|
|
} elseif ( $display_type_search == 'text' ) {
|
|
|
|
$option_values = opalestate_options( $setting_search_default_text, '' );
|
|
|
|
$qvalue = $qvalue ? $qvalue : $option_values;
|
2020-02-20 04:39:15 +01:00
|
|
|
$template = '<label class="opalestate-label opalestate-label--' . sanitize_html_class( $label ) . '">' . esc_html( $label ) . '</label>';
|
|
|
|
$template .= '<input class="form-control" type="text" name="info[%s]" value="%s"/>';
|
2019-10-26 11:36:18 +02:00
|
|
|
|
|
|
|
$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 = [
|
2020-02-20 04:39:15 +01:00
|
|
|
'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 ),
|
2019-10-26 11:36:18 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
|
|
|
|
opalesate_property_slide_ranger_template( __( $label . ": ", 'opalestate-pro' ), $data );
|
|
|
|
$template = ob_get_contents();
|
|
|
|
|
|
|
|
ob_end_clean();
|
|
|
|
} else {
|
|
|
|
$template = '<label class="opalestate-label opalestate-label--' . sanitize_html_class( $label ) . '">' . esc_html( $label ) . '</label>';
|
|
|
|
|
|
|
|
$template .= '<select class="form-control" name="info[%s]"><option value="">%s</option>';
|
|
|
|
for ( $i = 1; $i <= 10; $i++ ) {
|
|
|
|
$selected = $i == $qvalue ? 'selected="selected"' : '';
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-10-26 11:36:18 +02:00
|
|
|
$template .= '<option ' . $selected . ' value="' . $i . '">' . $i . '</option>';
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-10-26 11:36:18 +02:00
|
|
|
$template .= '</select>';
|
|
|
|
$template = sprintf( $template, $field, $label );
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $template; // WPCS: XSS OK.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render area size field.
|
|
|
|
*/
|
|
|
|
function opalestate_property_areasize_field_template( $template = '' ) {
|
2020-02-20 04:39:15 +01:00
|
|
|
$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 );
|
2019-11-27 04:29:09 +01:00
|
|
|
$measurement_units = opalestate_get_measurement_units();
|
|
|
|
$unit = opalestate_options( 'measurement_unit', 'sqft' );
|
|
|
|
if ( isset( $measurement_units[ $unit ] ) ) {
|
|
|
|
$unit = $measurement_units[ $unit ];
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
$data = [
|
2019-10-12 05:48:34 +02:00
|
|
|
'id' => 'area',
|
2019-11-27 04:29:09 +01:00
|
|
|
'unit' => $unit . ' ',
|
2019-10-12 05:48:34 +02:00
|
|
|
'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', ',' ),
|
2019-09-10 06:27:33 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
opalesate_property_slide_ranger_template( esc_html__( 'Area', 'opalestate-pro' ), $data );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-12 05:48:34 +02:00
|
|
|
add_filter( 'opalestate_property_areasize_field_template', 'opalestate_property_areasize_field_template' );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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',
|
2019-10-12 05:48:34 +02:00
|
|
|
'unit_thousand' => ',',
|
2019-09-10 06:27:33 +02:00
|
|
|
'mode' => 2,
|
|
|
|
'start' => '',
|
2020-03-24 05:39:25 +01:00
|
|
|
'step' => 1,
|
2019-09-10 06:27:33 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
$data = array_merge( $default, $data );
|
|
|
|
|
|
|
|
extract( $data );
|
|
|
|
?>
|
|
|
|
<label class="opalestate-label opalestate-label--<?php echo sanitize_title( $label ); ?>"><?php echo esc_html( $label ); ?></label>
|
2020-03-24 05:39:25 +01:00
|
|
|
<div class="opal-slide-ranger" data-unit="<?php echo esc_attr( $unit ); ?>" data-unitpos="<?php echo esc_attr( $unit_position ); ?>" data-decimals="<?php echo esc_attr( $decimals ); ?>"
|
|
|
|
data-thousand="<?php echo esc_attr( $unit_thousand ); ?>" data-step="<?php echo esc_attr( $step ); ?>">
|
2019-09-10 06:27:33 +02:00
|
|
|
<label class="slide-ranger-label">
|
|
|
|
<span class="slide-ranger-min-label"></span>
|
|
|
|
<?php echo ( $mode == 2 ) ? '<i>-</i>' : ''; ?>
|
|
|
|
<span class="slide-ranger-max-label"></span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<div class="slide-ranger-bar" data-min="<?php echo $ranger_min; ?>" data-max="<?php echo $ranger_max; ?>" data-mode="<?php echo $mode; ?>" data-start="<?php echo $start; ?>"></div>
|
|
|
|
|
|
|
|
<?php if ( $mode == 1 ) : ?>
|
|
|
|
<input type="hidden" class="slide-ranger-min-input ranger-<?php echo $id; ?>" name="<?php echo $id; ?>" autocomplete="off" value="<?php echo (int) $input_min; ?>"/>
|
|
|
|
<?php else : ?>
|
|
|
|
<input type="hidden" class="slide-ranger-min-input ranger-<?php echo $id; ?>" name="min_<?php echo $id; ?>" autocomplete="off" value="<?php echo (int) $input_min; ?>"/>
|
|
|
|
<input type="hidden" class="slide-ranger-max-input ranger-<?php echo $id; ?>" name="max_<?php echo $id; ?>" autocomplete="off" value="<?php echo (int) $input_max; ?>"/>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|