| 1 |
<?php |
| 2 |
/** |
| 3 |
* The Template for displaying filter range. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/filters/range.php |
| 6 |
* |
| 7 |
* $filter - array, with the Filter parameters |
| 8 |
* $url_manager - object, of the UrlManager PHP class |
| 9 |
* $terms - array, with objects of all filter terms except excluded |
| 10 |
* |
| 11 |
* @see https://filtereverything.pro/resources/templates-overriding/ |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( ! defined('ABSPATH') ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
?> |
| 19 |
<div class="<?php echo flrt_filter_class( $filter ); // Already escaped ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>"> |
| 20 |
<?php flrt_filter_header( $filter, $terms ); // Safe, escaped ?> |
| 21 |
<div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>"> |
| 22 |
<div class="wpc-filters-range-inputs"> |
| 23 |
<?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ): |
| 24 |
|
| 25 |
if( $view_args['ask_to_select_parent'] !== false ) { ?> |
| 26 |
<div><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></div> |
| 27 |
<?php } else { |
| 28 |
|
| 29 |
$minName = flrt_range_input_name( $filter['slug'] ); |
| 30 |
$maxName = flrt_range_input_name( $filter['slug'], 'max' ); |
| 31 |
$absMin = $absMax = 0; |
| 32 |
$hasSliderClass = ( $filter['range_slider'] === 'yes' ) ? 'wpc-form-has-slider' : 'wpc-form-without-slider'; |
| 33 |
|
| 34 |
foreach ( $terms as $term ) { |
| 35 |
|
| 36 |
foreach( $terms as $term ) { |
| 37 |
if( isset($term->min) ) { |
| 38 |
$absMin = $term->min; |
| 39 |
} |
| 40 |
if( isset( $term->max ) ) { |
| 41 |
$absMax = $term->max; |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
$max = isset( $filter['values']['max'] ) ? $filter['values']['max'] : $absMax; |
| 47 |
$min = isset( $filter['values']['min'] ) ? $filter['values']['min'] : $absMin; |
| 48 |
|
| 49 |
?> |
| 50 |
<form action="<?php echo esc_url( $url_manager->getFormActionOrFullPageUrl() ); ?>" method="GET" class="wpc-filter-range-form <?php echo esc_attr( $hasSliderClass ); ?>" id="wpc-filter-range-form-<?php echo esc_attr($filter['ID']); ?>"> |
| 51 |
<div class="wpc-filters-range-wrapper"> |
| 52 |
<div class="wpc-filters-range-column wpc-filters-range-min-column"> |
| 53 |
<?php // if there are value in $_GET we have to put it into field ?> |
| 54 |
<?php // attr step should be configured in options ?> |
| 55 |
<input type="number" class="wpc-filters-range-min" name="<?php echo esc_attr( $minName ); ?>" value="<?php echo esc_attr( $min ); ?>" step="<?php echo esc_attr( $filter['step'] ); ?>" data-min="<?php echo esc_attr( $absMin ); ?>" /> |
| 56 |
<button class="wpc-range-clear" type="button" title="<?php esc_html_e('Reset', 'filter-everything' ) ?>"> |
| 57 |
<span class="wpc-search-clear-icon">×</span> |
| 58 |
</button> |
| 59 |
</div> |
| 60 |
<div class="wpc-filters-range-column wpc-filters-range-max-column"> |
| 61 |
<input type="number" class="wpc-filters-range-max" name="<?php echo esc_attr( $maxName ); ?>" value="<?php echo esc_attr( $max ); ?>" step="<?php echo esc_attr( $filter['step'] ); ?>" data-max="<?php echo esc_attr( $absMax ); ?>" /> |
| 62 |
<button class="wpc-range-clear" type="button" title="<?php esc_html_e('Reset', 'filter-everything' ) ?>"> |
| 63 |
<span class="wpc-search-clear-icon">×</span> |
| 64 |
</button> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
<?php |
| 68 |
/** |
| 69 |
* @bug if $absMin === $absMax slider freezes |
| 70 |
*/ |
| 71 |
?> |
| 72 |
<?php if( $filter['range_slider'] === 'yes' ): ?> |
| 73 |
<div class="wpc-filters-range-slider-wrapper"> |
| 74 |
<div class="wpc-filters-range-slider-control wpc-slider-control-<?php echo esc_attr( $filter['ID'] ); ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>"></div> |
| 75 |
</div> |
| 76 |
<?php else: ?> |
| 77 |
<div class="wpc-filters-range-values-wrapper"> |
| 78 |
<p><?php echo esc_html( sprintf( __( '%s: %d — %d' ), $filter['label'], $absMin, $absMax ) ); ?></p> |
| 79 |
</div> |
| 80 |
<?php endif; ?> |
| 81 |
<?php |
| 82 |
flrt_query_string_form_fields( |
| 83 |
flrt_get_query_string_parameters(), |
| 84 |
[$minName, $maxName] |
| 85 |
); |
| 86 |
?> |
| 87 |
</form> |
| 88 |
<?php } ?> |
| 89 |
<?php else: ?> |
| 90 |
<?php esc_html_e('There are no posts with such filtering criteria on this site.', 'filter-everything' ); ?> |
| 91 |
<?php endif; ?> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
|
| 96 |
|