<?php
if (!defined('ABSPATH'))
  exit;

global $wp;
include_once('eurostocks-public-display-options.php');
?>


<form id="es-module-form" class="import-module" method="GET" action="">
  <div class="euro-row">
    <div class="eurocol-md-3 filters es-pb-3">

      <div class="merk-model-filters">
        <h2 class="es-search-title es-text-white">
          <?php if ($diflang) {
            if (isset($options[$current_lang]['txt_srch']) && $options[$current_lang]['txt_srch'] != '') {
              echo wp_kses($options[$current_lang]['txt_srch'], $allowed_html);
            } else {
              echo wp_kses($options['txt_srch'], $allowed_html);
            }
          } else {
            echo wp_kses($options['txt_srch'], $allowed_html);
          }
          ?>
        </h2>
        <label>
        <?php 
        if($diflang && isset($options[esc_html($current_lang)]) && isset($options[esc_html($current_lang)]['txt_make']) && $options[esc_html($current_lang)]['txt_make'] != ""  ){ 
          echo esc_html($options[esc_html($current_lang)]['txt_make']); 
        }else{ 
           if (isset($options['txt_make']) && $options['txt_make'] != "") {
            echo esc_html($options['txt_make']);
          } else {
            esc_html_e("Make", 'eurostocks');
          } 
        }
        ?>

          <div class="eurofilters d-flex">

            <select id="make-select" class="form-control" name="make" <?php if (isset($car_options['live_models']) && $car_options['live_models'] == '1') {
                                                                        echo 'data-live-models="true"';
                                                                      } ?> <?php if(isset($car_options['make_only']) && $car_options['make_only'] != '2'){ ?> required <?php } ?>>
              <option disabled selected>
                <?php echo esc_html($select_make); ?>
              </option>

              <?php foreach ($makes as $eumake) {
                if (isset($car_options['live_models']) && $car_options['live_models'] == '1') {
                  $exists = true;
                } else {
                  $exists = false;
                  foreach ($models as $model) {
                    if (strpos($model, $eumake) !== false) {
                      $exists = true;
                      break;
                    }
                  }
                }
                if ($exists) {
                  unset($eumakeDescription);

                  if(is_array($makelist)) {
                    foreach($makelist as $make){
                      if(is_array($make) && isset($make['key']) && $make['key'] == $eumake){
                        $eumakeDescription = $make['description'];
                        break;
                      } elseif(is_string($make) && $make == $eumake){
                        $eumakeDescription = $make;
                        break;
                      }
                    }
                  }
                  if(!isset($eumakeDescription)){
                    $eumakeDescription = $eumake;
                  }
              ?>
                  <option <?php echo ((isset($_GET['make']) && $eumake == $_GET['make']) || (!isset($_GET['make']) && isset($atts['make']) && $atts['make'] == $eumake)) ? 'selected' : ''; ?>
                    value="<?php echo esc_html($eumake); ?>">
                    <?php echo esc_html($eumakeDescription); ?>
                  </option>
              <?php }
              } ?>
            </select>
          </div>
        </label>

        <label>
        <?php 
        if($diflang && isset($options[esc_html($current_lang)]) && isset($options[esc_html($current_lang)]['txt_model']) && $options[esc_html($current_lang)]['txt_model'] != ""  ){ 
          echo esc_html($options[esc_html($current_lang)]['txt_model']); 
        }else{ 
          if (isset($options['txt_model']) && $options['txt_model'] != "") {
            echo esc_html($options['txt_model']);
          } else {
            esc_html_e("Model", 'eurostocks');
          } 
        }
        ?>
          <div class="eurofilters d-flex">

            <select id="model-select" class="form-control " name="model" <?php if (isset($atts['allow_make_only']) || (isset($car_options['make_only']) && ($car_options['make_only'] == '1' || $car_options['make_only'] == '2'))) { echo 'data-allow-empty="true"';} ?>>
              <option selected disabled>
                <?php echo esc_html($select_model); ?>
              </option>
              <?php
              foreach ($models as $model) {
                $model_split = explode('|', $model);
                $app = (isset($model_split[2])) ? '|GROUP' : '';
                $model_c = $model_split[0];
                $getModel = '';
                if(isset($_GET['model'])) {
                   if (isset($_GET['model']) && $model_c . $app == stripcslashes(sanitize_text_field($_GET['model']))) {
                  $modelDescription = $model_split[0];
                  $getModel = $_GET['model'];
                  }
                }else{
                  if(isset($atts['model'])){
                    if($model_c . $app == $atts['model']){
                      $modelDescription = $model_split[0];
                      $getModel = $atts['model'];
                    }
                  } elseif (isset($atts['model_group'])) {
                    if($model_c . $app == $atts['model_group']){
                      $modelDescription = $model_split[0];
                      $getModel = $atts['model_group'];
                    }
                  }
                }
              ?>
                <option <?php echo (isset($getModel) && $model_c . $app == sanitize_text_field($getModel)) ? 'selected' : ''; ?>
                  data-make="<?php echo esc_html($model_split[1]); ?>"
                  value="<?php echo esc_html($model_c); ?><?php echo (isset($model_split[2])) ? '|GROUP' : ''; ?>">
                  <?php echo esc_html(str_replace('_', ' ', $model_split[0])); ?>
                </option>
              <?php
              } ?>
            </select>
          </div>
        </label>

        <button class="euro-btn euro-btn-primary euro-btn-block" type="submit" value="Filter">
          <?php esc_html_e('Search', 'eurostocks'); ?>
        </button>
      </div>
      <a href="#" class="es-hidden es-min-hidden" id="eurostocks-filter-toggle2">-
        <?php esc_html_e('More filters', 'eurostocks'); ?>
      </a>
      <div id="extra-filters" class="extra-filters es-min-hidden">
        <?php
        if (isset($options['hide_year']) && $options['hide_year'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Registration date', 'eurostocks'); ?>
              <div class="eurofilters euro-input-group d-flex">
                <select name="yearFrom" style="width: 100%;left: 0;">
                  <option value="" <?php echo (!isset($_GET['yearFrom']) || $_GET['yearFrom'] == "" ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('From', 'eurostocks'); ?>
                  </option>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2025) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2025)||(isset($atts['year_from']) && $atts['year_from'] == 2025)) ? 'selected="selected"' : ''; ?>
                      value="2025">2025</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2024) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2024)||(isset($atts['year_from']) && $atts['year_from'] == 2024)) ? 'selected="selected"' : ''; ?>
                      value="2024">2024</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2023) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2023)||(isset($atts['year_from']) && $atts['year_from'] == 2023)) ? 'selected="selected"' : ''; ?>
                      value="2023">2023</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2022) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2022)||(isset($atts['year_from']) && $atts['year_from'] == 2022)) ? 'selected="selected"' : ''; ?>
                      value="2022">2022</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2021) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2021)||(isset($atts['year_from']) && $atts['year_from'] == 2021)) ? 'selected="selected"' : ''; ?>
                      value="2021">2021</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2020) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2020)||(isset($atts['year_from']) && $atts['year_from'] == 2020)) ? 'selected="selected"' : ''; ?>
                      value="2020">2020</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2019) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2019)||(isset($atts['year_from']) && $atts['year_from'] == 2019)) ? 'selected="selected"' : ''; ?>
                      value="2019">2019</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2018) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2018)||(isset($atts['year_from']) && $atts['year_from'] == 2018)) ? 'selected="selected"' : ''; ?>
                      value="2018">2018</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2017) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2017)||(isset($atts['year_from']) && $atts['year_from'] == 2017)) ? 'selected="selected"' : ''; ?>
                      value="2017">2017</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2016) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2016)||(isset($atts['year_from']) && $atts['year_from'] == 2016)) ? 'selected="selected"' : ''; ?>
                      value="2016">2016</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2015) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2015)||(isset($atts['year_from']) && $atts['year_from'] == 2015)) ? 'selected="selected"' : ''; ?>
                      value="2015">2015</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2014) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2014)||(isset($atts['year_from']) && $atts['year_from'] == 2014)) ? 'selected="selected"' : ''; ?>
                      value="2014">2014</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2013) { ?>
                    <option <?php echo ((isset($_GET['yearFrom']) && $_GET['yearFrom'] == 2013)||(isset($atts['year_from']) && $atts['year_from'] == 2013)) ? 'selected="selected"' : ''; ?>
                      value="2013">2013</option>
                  <?php } ?>
                </select>

                <select name="yearTo" style="width: 100%;right: 0;">
                  <option value="" <?php echo (!isset($_GET['yearTo']) || $_GET['yearTo'] == "" ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('To', 'eurostocks'); ?>
                  </option>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2025) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2025) ? 'selected="selected"' : ''; ?>
                      value="2025">2025</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2024) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2024) ? 'selected="selected"' : ''; ?>
                      value="2024">2024</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2023) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2023) ? 'selected="selected"' : ''; ?>
                      value="2023">2023</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2022) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2022) ? 'selected="selected"' : ''; ?>
                      value="2022">2022</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2021) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2021) ? 'selected="selected"' : ''; ?>
                      value="2021">2021</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2020) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2020) ? 'selected="selected"' : ''; ?>
                      value="2020">2020</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2019) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2019) ? 'selected="selected"' : ''; ?>
                      value="2019">2019</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2018) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2018) ? 'selected="selected"' : ''; ?>
                      value="2018">2018</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2017) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2017) ? 'selected="selected"' : ''; ?>
                      value="2017">2017</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2016) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2016) ? 'selected="selected"' : ''; ?>
                      value="2016">2016</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2015) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2015) ? 'selected="selected"' : ''; ?>
                      value="2015">2015</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2014) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2014) ? 'selected="selected"' : ''; ?>
                      value="2014">2014</option>
                  <?php } ?>
                  <?php if (!isset($options['min_bouwjaar']) || intval($options['min_bouwjaar']) <= 2013) { ?>
                    <option <?php echo (isset($_GET['yearTo']) && $_GET['yearTo'] == 2013) ? 'selected="selected"' : ''; ?>
                      value="2013">2013</option>
                  <?php } ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_price']) && $options['hide_price'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Price', 'eurostocks'); ?>
              <div class="eurofilters euro-input-group d-flex">
                <select name="priceFrom" style="width: 100%;left: 0;">
                  <option value="" <?php echo (!isset($_GET['priceFrom']) || $_GET['priceFrom'] == "" ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('From', 'eurostocks'); ?>
                  </option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 5000) ? 'selected="selected"' : ''; ?> value="5000">€ 5.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 6000) ? 'selected="selected"' : ''; ?> value="6000">€ 6.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 7000) ? 'selected="selected"' : ''; ?> value="7000">€ 7.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 8000) ? 'selected="selected"' : ''; ?> value="8000">€ 8.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 9000) ? 'selected="selected"' : ''; ?> value="9000">€ 9.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 10000) ? 'selected="selected"' : ''; ?> value="10000">€ 10.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 12500) ? 'selected="selected"' : ''; ?> value="12500">€ 12.500</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 15000) ? 'selected="selected"' : ''; ?> value="15000">€ 15.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 17500) ? 'selected="selected"' : ''; ?> value="17500">€ 17.500</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 20000) ? 'selected="selected"' : ''; ?> value="20000">€ 20.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 25000) ? 'selected="selected"' : ''; ?> value="25000">€ 25.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 30000) ? 'selected="selected"' : ''; ?> value="30000">€ 30.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 40000) ? 'selected="selected"' : ''; ?> value="40000">€ 40.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 50000) ? 'selected="selected"' : ''; ?> value="50000">€ 50.000</option>
                  <option <?php echo (isset($_GET['priceFrom']) && $_GET['priceFrom'] == 75000) ? 'selected="selected"' : ''; ?> value="75000">€ 75.000</option>
                </select>

                <select name="priceTo" style="width: 100%;right: 0;">
                  <option value="" <?php echo (!isset($_GET['priceTo']) || $_GET['priceTo'] == "" ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('To', 'eurostocks'); ?>
                  </option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 5000) ? 'selected="selected"' : ''; ?> value="5000">€ 5.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 6000) ? 'selected="selected"' : ''; ?> value="6000">€ 6.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 7000) ? 'selected="selected"' : ''; ?> value="7000">€ 7.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 8000) ? 'selected="selected"' : ''; ?> value="8000">€ 8.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 9000) ? 'selected="selected"' : ''; ?> value="9000">€ 9.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 10000) ? 'selected="selected"' : ''; ?> value="10000">€ 10.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 12500) ? 'selected="selected"' : ''; ?> value="12500">€ 12.500</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 15000) ? 'selected="selected"' : ''; ?> value="15000">€ 15.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 17500) ? 'selected="selected"' : ''; ?> value="17500">€ 17.500</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 20000) ? 'selected="selected"' : ''; ?> value="20000">€ 20.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 25000) ? 'selected="selected"' : ''; ?> value="25000">€ 25.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 30000) ? 'selected="selected"' : ''; ?> value="30000">€ 30.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 40000) ? 'selected="selected"' : ''; ?> value="40000">€ 40.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 50000) ? 'selected="selected"' : ''; ?> value="50000">€ 50.000</option>
                  <option <?php echo (isset($_GET['priceTo']) && $_GET['priceTo'] == 75000) ? 'selected="selected"' : ''; ?> value="75000">€ 75.000</option>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_mileage']) && $options['hide_mileage'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Mileage', 'eurostocks'); ?>
              <div class="eurofilters euro-input-group d-flex">
                <select name="mileageFrom" style="width: 100%;right: 0;">
                  <option value="" <?php echo (!isset($_GET['mileageFrom']) || $_GET['mileageFrom'] == "" ? 'selected="selected"' : ''); ?>>
                    <?php esc_html_e('From', 'eurostocks'); ?>
                  </option>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 5000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 5000) ? 'selected="selected"' : ''; ?> value="5000">5.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 7500) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 7500) ? 'selected="selected"' : ''; ?> value="7500">7.500 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 10000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 10000) ? 'selected="selected"' : ''; ?> value="10000">10.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 15000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 15000) ? 'selected="selected"' : ''; ?> value="15000">15.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 20000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 20000) ? 'selected="selected"' : ''; ?> value="20000">20.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 30000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 30000) ? 'selected="selected"' : ''; ?> value="30000">30.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 40000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 40000) ? 'selected="selected"' : ''; ?> value="40000">40.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 50000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 50000) ? 'selected="selected"' : ''; ?> value="50000">50.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 60000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 60000) ? 'selected="selected"' : ''; ?> value="60000">60.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 70000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 70000) ? 'selected="selected"' : ''; ?> value="70000">70.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 80000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 80000) ? 'selected="selected"' : ''; ?> value="80000">80.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 90000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 90000) ? 'selected="selected"' : ''; ?> value="90000">90.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 100000) { ?>
                    <option <?php echo (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] == 100000) ? 'selected="selected"' : ''; ?> value="100000">100.000 KM</option>
                  <?php } ?>
                </select>
                <select name="mileageTo" style="width: 100%;right: 0;">
                  <option value="" <?php echo (!isset($_GET['mileageTo']) || $_GET['mileageTo'] == "" ? 'selected="selected"' : ''); ?>>
                    <?php esc_html_e('To', 'eurostocks'); ?>
                  </option>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 1000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 1000) ? 'selected="selected"' : ''; ?>
                      value="1000">1.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 2500) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 2500) ? 'selected="selected"' : ''; ?>
                      value="2500">2.500 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 5000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 5000) ? 'selected="selected"' : ''; ?>
                      value="5000">5.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 7500) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 7500) ? 'selected="selected"' : ''; ?>
                      value="7500">7.500 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 10000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 10000) ? 'selected="selected"' : ''; ?> value="10000">10.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 15000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 15000) ? 'selected="selected"' : ''; ?> value="15000">15.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 20000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 20000) ? 'selected="selected"' : ''; ?> value="20000">20.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 30000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 30000) ? 'selected="selected"' : ''; ?> value="30000">30.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 40000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 40000) ? 'selected="selected"' : ''; ?> value="40000">40.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 50000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 50000) ? 'selected="selected"' : ''; ?> value="50000">50.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 60000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 60000) ? 'selected="selected"' : ''; ?> value="60000">60.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 70000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 70000) ? 'selected="selected"' : ''; ?> value="70000">70.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 80000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 80000) ? 'selected="selected"' : ''; ?> value="80000">80.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 90000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 90000) ? 'selected="selected"' : ''; ?> value="90000">90.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 100000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 100000) ? 'selected="selected"' : ''; ?> value="100000">100.000 KM</option>
                  <?php } ?>
                  <?php if (!isset($options['max_kmstand']) || intval($options['max_kmstand']) >= 125000) { ?>
                    <option <?php echo (isset($_GET['mileageTo']) && $_GET['mileageTo'] == 125000) ? 'selected="selected"' : ''; ?> value="100000">125.000 KM</option>
                  <?php } ?>

                </select>
              </div>
            </label>
          </div>
        <?php
        }


        if (isset($options['hide_fuel_type']) && $options['hide_fuel_type'] == 1) {
          echo '';
        } else {

        ?>
          <div class="">
            <label>
              <?php esc_html_e('Fuel type', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="fuelType" class="">
                  <option value="" <?php echo (!isset($_GET['fuelType']) ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_fuel_types)) {
                    foreach ($eurostocks_fuel_types as $option) {

                      if(is_array($option) && isset($option['description'])) {
                        if ($option['description'] == "Hybride (benzine/elektrisch)") {
                          $fueltype = "Hybride benzine";
                        } elseif ($option['description'] == "Hybride (diesel/elektrisch)") {
                          $fueltype = "Hybride diesel";
                        } else {
                          $fueltype = $option['description'];
                        }
                        $optionKey = $option['key'];
                      } elseif(is_string($option)) {
                        $fueltype = $option;
                        $optionKey = $option;
                      } else {
                        continue;
                      }

                      echo "<option " . (isset($_GET['fuelType']) && $_GET['fuelType'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($fueltype) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_transmission']) && $options['hide_transmission'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Transmission', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="transmission" class="">
                  <option value="" <?php echo (!isset($_GET['transmission']) ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_transmissions)) {
                    foreach ($eurostocks_transmissions as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        if($option['key'] == "SEMIAUTOMATIC_GEAR"){
                          continue;
                        }
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'] == "Automatische transmissie" ? "Automaat" : $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue; // Skip invalid entries
                      }
                      echo "<option " . (isset($_GET['transmission']) && $_GET['transmission'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_drive_type']) && $options['hide_drive_type'] != 1) {

          $eurostocks_drive_types = array(
            'FRONT' => esc_html__('Front wheel drive', 'eurostocks'),
            'REAR' => esc_html__('Rear wheel drive', 'eurostocks'),
            'ALL_WHEEL' => esc_html__('All wheel drive', 'eurostocks'),
          );
          ?>

          <div class=""> 
            <label>
              <?php esc_html_e('Drive type', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="driveType" class="">
                  <option value="" <?php echo (!isset($_GET['driveType']) ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  foreach ($eurostocks_drive_types as $key => $label) {
                    echo "<option " . (isset($_GET['driveType']) && $_GET['driveType'] == $key ? 'selected' : '') . " value='" . esc_html($key) . "'>" . esc_html($label) . "</option>";
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>

          <?php
        }

        if (isset($options['hide_category']) && $options['hide_category'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Car body', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="carCategory" class="">
                  <option value="" <?php echo (!isset($_GET['carCategory']) ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_categories)) {
                    foreach ($eurostocks_categories as $option) {
                      if(is_array($option) && isset($option['Key']) && isset($option['Description'])) {
                        $optionKey = $option['Key'];
                        $optionDesc = $option['Description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['carCategory']) && $_GET['carCategory'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }
        ?>

        <?php
        if (isset($options['hide_filter_options']) && $options['hide_filter_options'] == 1) {
          echo '';
        } else {

          if (isset($_GET['options']) && is_array($_GET['options'])) {
            $getcaroptions = array_map('sanitize_key', $_GET['options']);
          } else {
            foreach ($caroptions as $k => $v) {
              if (isset($options['select_' . $k]) && $options['select_' . $k] == 1) {
                $getcaroptions[] = sanitize_text_field($k);
              }
            }
          }

          $options_not_set = true;
          foreach ($caroptions as $k => $v) {
            if (isset($options['fav_' . $k]) && $options['fav_' . $k] == 1) {
              $options_not_set = false;
            }
          }
        ?>
          <div class="">
            <label>
              <?php if (!isset($options['fav_opt_title']) || ((isset($options['fav_opt_title']) && $options['fav_opt_title'] == '')) || $options_not_set == true) {
                echo "<div>" . esc_html__("Options", "eurostocks") . "</div>";
              } else {

              ?>
                <div id="euro-fav-options">
                  <?php if (isset($options['fav_opt_title']) && $options['fav_opt_title'] != '') {
                    if ($diflang && isset($options[esc_html($current_lang)]) && isset($options[esc_html($current_lang)]['fav_opt_title']) && $options[esc_html($current_lang)]['fav_opt_title'] != '') {
                      echo "<div>" . esc_html($options[esc_html($current_lang)]['fav_opt_title']) . "</div>";
                    } else {
                      echo "<div>" . esc_html($options['fav_opt_title']) . "</div>";
                    }
                  } else { ?>
                    <div><?php esc_html_e('Most searched options', 'eurostocks'); ?></div>
                  <?php } ?>
                  <div class="eurofilters d-flex">
                    <div>
                     
                        <?php
                        foreach ($caroptions as $k => $v) {
                          if (isset($options['fav_' . $k]) && $options['fav_' . $k] == 1) {
                            echo "<label><input name='options[]' type='checkbox' " . ((isset($getcaroptions) && is_array($getcaroptions) && in_array(strtolower($k), $getcaroptions) || (!isset($_GET['options']) && isset($options['select_' . $k]) && $options['select_' . $k] == 1)) ? 'checked' : '') . " value='" . esc_html($k) . "'> " . esc_html($v) . "</label></br>";
                          }
                        }
                        ?>
                    

                    </div>
                  </div>
                </div>

                <div id="euro-nonfav-options">
                <?php if (isset($options['nonfav_opt_title']) && $options['nonfav_opt_title'] != '') {
                  if ($diflang && isset($options[esc_html($current_lang)]) && isset($options[esc_html($current_lang)]['nonfav_opt_title']) && $options[esc_html($current_lang)]['nonfav_opt_title'] != '') {
                    echo "<div>" . esc_html($options[esc_html($current_lang)]['nonfav_opt_title']) . "</div>";
                  } else {
                    echo "<div>" . esc_html($options['nonfav_opt_title']) . "</div>";
                  }
                } else { ?>
                  <div style="margin-top:12px;"><?php esc_html_e('Other options', 'eurostocks'); ?></div>
                <?php } ?>
              <?php } ?>
              <?php if($options_not_set == true){
                ?><div id='euro-nonfav-options'><?php 
              } ?>
              <div class="eurofilters d-flex">
                <div>
                  <div id="first-5-options">
                    <?php
                    $l = 0;

                    foreach ($caroptions as $k => $v) {
                      if (!isset($options['fav_' . $k]) || (isset($options['fav_' . $k]) && $options['fav_' . $k] == 0)) {
                        if (!isset($options['hide_' . $k]) || (isset($options['hide_' . $k]) && $options['hide_' . $k] == 0)) {
                          echo "<label><input name='options[]' type='checkbox' " . ((isset($getcaroptions) && is_array($getcaroptions) && in_array(strtolower($k), $getcaroptions) || (!isset($_GET['options']) && isset($options['select_' . $k]) && $options['select_' . $k] == 1)) ? 'checked' : '') . " value='" . esc_html($k) . "'> " . esc_html($v) . "</label></br>";
                          $l++;
                          if ($l == 5) { ?>
                            </div>
                            <a id='show-more-options' href='#'><?php esc_html_e("Show more options", "eurostocks"); ?></a>
                            <div id='more-5-options' class='euro-hidden'>
                            <?php }
                              }
                            }
                          }
                  ?>
                  </div>
                  <a id="show-less-options" href="#" class="euro-hidden"><?php esc_html_e("Show less options", "eurostocks"); ?></a>
                </div>
              </div>
                  </div>
                 
            </label>
          </div>
        <?php
        }



        if (isset($options['hide_filter_parking']) && $options['hide_filter_parking'] == 1) {
          echo '';
        } else {
        ?>
          <div id="euro-parkingsensors-filter">
            <label>
              <?php esc_html_e('Parkeersensoren', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <div>

                  <?php
                  $l = 0;
                  if (isset($_GET['parkingAssistant']) && is_array($_GET['parkingAssistant'])) {
                    $parkingAssistants = array_map('sanitize_key', $_GET['parkingAssistant']);
                  } else {
                    $parkingAssistants = array();
                  }

                  foreach ($parkingsensors as $k => $v) {
                    echo "<label class='euro-parkingsensor'><input name='parkingAssistant[]' type='checkbox' " . (isset($parkingAssistants) && is_array($parkingAssistants) && in_array(strtolower($k), $parkingAssistants) ? 'checked' : '') . " value='" . esc_html($k) . "'> " . esc_html($v) . "</label></br>";
                  }
                  ?>


                </div>
              </div>
            </label>
          </div>
        <?php }

        if (isset($options['hide_power']) && $options['hide_power'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('kW', 'eurostocks'); ?>
              <div class="eurofilters euro-input-group d-flex">
                <input
                  value="<?php echo (isset($_GET['powerFrom']) ? esc_html(sanitize_text_field($_GET['powerFrom'])) : ''); ?>"
                  class="" placeholder="<?php esc_html_e('From', 'eurostocks'); ?>" name="powerFrom" type="number">
                <input value="<?php echo (isset($_GET['powerTo']) ? esc_html(sanitize_text_field($_GET['powerTo'])) : ''); ?>"
                  class="" placeholder="<?php esc_html_e('To', 'eurostocks'); ?>" name="powerTo" type="number">
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_exterior_color']) && $options['hide_exterior_color'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Color', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="exteriorColor" class="">
                  <option <?php echo (!isset($_GET['exteriorColor']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_exterior_colors)) {
                    foreach ($eurostocks_exterior_colors as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue; 
                      }
                      echo "<option " . (isset($_GET['exteriorColor']) && $_GET['exteriorColor'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_seats']) && $options['hide_seats'] != 1) {

          $seats_count = array(
           2, 3, 4, 5, 6, 7, 8, 9
          );
          ?>

          <div class=""> 
            <label>
              <?php esc_html_e('Seats count', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="seatsCount" class="">
                  <option value="" <?php echo (!isset($_GET['seatsCount']) ? 'selected="selected"' : '') ?>>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  foreach ($seats_count as $key) {
                    echo "<option " . (isset($_GET['seatsCount']) && $_GET['seatsCount'] == $key ? 'selected' : '') . " value='" . esc_html($key) . "'>" . esc_html($key) . "</option>";
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>

          <?php
        }


        if (isset($options['hide_door_count']) && $options['hide_door_count'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Doors', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="doorCount" class="">
                  <option <?php echo (!isset($_GET['doorCount']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_door_counts)) {
                    foreach ($eurostocks_door_counts as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['doorCount']) && $_GET['doorCount'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_vat']) && $options['hide_vat'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <div class="eurofilters">
                <input type="checkbox" name="vat" <?php if (isset($_GET['vat']) && $_GET['vat'] == 'ja') {
                                                    echo 'checked=checked';
                                                  } ?> value='ja'>
                <?php esc_html_e('VAT deductible', 'eurostocks'); ?>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_interior_type']) && $options['hide_interior_type'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Interior', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="interiorType" class="">
                  <option <?php echo (!isset($_GET['interiorType']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_interior_types)) {
                    foreach ($eurostocks_interior_types as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['interiorType']) && $_GET['interiorType'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_speed_control']) && $options['hide_speed_control'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Speed control', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="speedControl" class="">
                  <option <?php echo (!isset($_GET['speedControl']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_speed_controls)) {
                    foreach ($eurostocks_speed_controls as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['speedControl']) && $_GET['speedControl'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

   

        if (isset($options['hide_climatisation']) && $options['hide_climatisation'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Climate control', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="climatisation" class="">
                  <option <?php echo (!isset($_GET['climatisation']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_climatisations)) {
                    foreach ($eurostocks_climatisations as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['climatisation']) && $_GET['climatisation'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        if (isset($options['hide_headlight_type']) && $options['hide_headlight_type'] == 1) {
          echo '';
        } else {
        ?>
          <div class="">
            <label>
              <?php esc_html_e('Headlights type', 'eurostocks'); ?>
              <div class="eurofilters d-flex">
                <select name="headlightType" class="">
                  <option <?php echo (!isset($_GET['headlightType']) ? 'selected="selected"' : '') ?> disabled>
                    <?php esc_html_e('Make a choice', 'eurostocks'); ?>
                  </option>
                  <?php
                  if(is_array($eurostocks_headlight_types)) {
                    foreach ($eurostocks_headlight_types as $option) {
                      if(is_array($option) && isset($option['key']) && isset($option['description'])) {
                        $optionKey = $option['key'];
                        $optionDesc = $option['description'];
                      } elseif(is_string($option)) {
                        $optionKey = $option;
                        $optionDesc = $option;
                      } else {
                        continue;
                      }
                      echo "<option " . (isset($_GET['headlightType']) && $_GET['headlightType'] == $optionKey ? 'selected' : '') . " value='" . esc_html($optionKey) . "'>" . esc_html($optionDesc) . "</option>";
                    }
                  }
                  ?>
                </select>
              </div>
            </label>
          </div>
        <?php
        }

        ?>
        <button class="euro-btn euro-btn-primary euro-btn-block es-mb-3" type="submit" value="Filter">
          <?php esc_html_e('Search', 'eurostocks'); ?>
        </button>
        <br>
      </div>

      <a href="#" class="es-hidden es-min-show" id="eurostocks-filter-toggle">+
        <?php esc_html_e('More filters', 'eurostocks'); ?>
      </a>
    </div>
    <div class="eurocol-md-9">

      <?php
      if (count($vehicles) > 0 || (isset($_GET['make']) && isset($_GET['model']))) {
      
        if(isset($atts['make'])) {
          if (is_array($makelist)) {
            foreach($makelist as $make) {
              if(is_array($make) && $make['key'] == $atts['make']) {
                $make_name = $make['description'];
              }
            }
          }
        }
        if(!isset($make_name) && isset($atts['make'])) {
          $make_name = $atts['make'];
        }else{
          $make_name = '';
        }
        ?>
        <?php
         if(isset($atts['model_group'])) {
          if ($diflang && isset($options[$current_lang]) && isset($options[$current_lang]['txt_search_title']) && $options[$current_lang]['txt_search_title'] != '') {
            echo '<h3>' . esc_html($this->eurostocks_replace_merk_model_aantal($options[$current_lang]['txt_search_title'], $make_name, str_replace('_', ' ', $atts['model_group']), $total)) . '</h3>';
          } else {
            if (isset($options['txt_search_title']) && $options['txt_search_title'] != '') {
              echo '<h3>' . esc_html($this->eurostocks_replace_merk_model_aantal($options['txt_search_title'], $make_name, str_replace('_', ' ', $atts['model_group']), $total)) . '</h3>';
            } else {
              echo '<h3>' . esc_html($total) . " " . esc_html($make_name) . " " . esc_html(str_replace('_', ' ', $atts['model_group'])) . " " . esc_html_e('cars found') . '</h3>';
            }
          }
        }else {
          if ($diflang && isset($options[$current_lang]) && isset($options[$current_lang]['txt_search_title']) && $options[$current_lang]['txt_search_title'] != '') {
            echo '<h3>' . esc_html($this->eurostocks_replace_merk_model_aantal($options[$current_lang]['txt_search_title'], $make_name, str_replace('_', ' ', $atts['model']), $total)) . '</h3>';
          } else {
            if(!isset($atts['model'])) {
              $model_name = '';
            }
            else {
              $model_name = $atts['model'];
            }
            if (isset($options['txt_search_title']) && $options['txt_search_title'] != '') {
              echo '<h3>' . esc_html($this->eurostocks_replace_merk_model_aantal($options['txt_search_title'], $make_name, str_replace('_', ' ', $model_name), $total)) . '</h3>';
            } else {
              echo '<h3>' . esc_html($total) . " " . esc_html($make_name) . " " . esc_html(str_replace('_', ' ', $model_name)) . " " . esc_html_e('cars found') . '</h3>';
            }
          }
        } 
        ?>
        <p>

          <?php
          if ($diflang && isset($options[esc_html($current_lang)]) && isset($options[esc_html($current_lang)]['txt_search'])) {
            echo wp_kses($options[$current_lang]['txt_search'], $allowed_html);
          } else {
            if (isset($options['txt_search'])) {
              echo wp_kses($options['txt_search'], $allowed_html);
            }
          }
          if (isset($options['txt_search_help_show']) && $options['txt_search_help_show'] == 1) { ?><span class="es-w-10" id="es-info-one"><img
                src="<?php echo esc_url(plugin_dir_url(__FILE__)); ?>../images/circle-info-regular-b.png" alt=""></span>
          <?php }
          ?>
        </p>

        <div class="es-divider es-srch-divider"></div>

        <div class="es-flex">
          <div class="euro-remove-filters">

            <?php if (isset($_GET['make']) && $_GET['make'] != "") {
              $remove_arg_url = add_query_arg(
                array(
                  'make' => '',
                  'model' => '',
                )
              );
              $getmake = sanitize_text_field($_GET['make']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($getmake); ?> <span>&times;</span>
              </a>
            <?php
            }
            
            if (isset($_GET['model']) && $_GET['model'] != "") {
              $remove_arg_url = add_query_arg('model', '');
              if(isset($atts['model']) && $atts['model'] != "") { ?>
                <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                    <?php echo esc_html(str_replace('_', ' ', $atts['model'])); ?> <span>&times;</span>
                </a>
              <?php } else { ?>
                <a class="euro-remove-filter">
                    <?php echo esc_html(str_replace('_', ' ', $atts['model_group'])); ?> <span>&times;</span>
                </a>
            <?php }
              }
            



            if ((isset($_GET['yearFrom']) && $_GET['yearFrom'] != "") || (isset($atts['year_from']) && $atts['year_from'] != "")) {
              $remove_arg_url = add_query_arg('yearFrom', '');
              if(isset($_GET['yearFrom']) && $_GET['yearFrom'] != ""){
                $yearfrom = sanitize_text_field($_GET['yearFrom']);
              } elseif(isset($atts['year_from']) && $atts['year_from'] != "") {
                $yearfrom = sanitize_text_field($atts['year_from']);
              }
              
            ?>
            <?php if(isset($_GET['yearFrom']) && $_GET['yearFrom'] != ""){ ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Min Registration date', 'eurostocks'); ?>
                <?php echo esc_html($yearfrom); ?> <span>&times;</span>
              </a>
              <?php }else{ ?>
                <a class="euro-remove-filter">
                <?php esc_html_e('Min Registration date', 'eurostocks'); ?>
                <?php echo esc_html($yearfrom); ?>
              </a>
              <?php } ?>
            <?php
            }
            if (isset($_GET['yearTo']) && $_GET['yearTo'] != "") {
              $remove_arg_url = add_query_arg('yearTo', '');
              $yearto = sanitize_text_field($_GET['yearTo']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Max registration date', 'eurostocks'); ?>
                <?php echo esc_html($yearto); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['mileageFrom']) && $_GET['mileageFrom'] != "") {
              $remove_arg_url = add_query_arg('mileageFrom', '');
              $mileagefrom = sanitize_text_field($_GET['mileageFrom']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('From Mileage', 'eurostocks'); ?>
                <?php echo esc_html($mileagefrom); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['mileageTo']) && $_GET['mileageTo'] != "") {
              $remove_arg_url = add_query_arg('mileageTo', '');
              $mileageto = sanitize_text_field($_GET['mileageTo']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('To Mileage', 'eurostocks'); ?>
                <?php echo esc_html($mileageto); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['powerFrom']) && $_GET['powerFrom'] != "") {
              $remove_arg_url = add_query_arg('powerFrom', '');
              $powerfrom = sanitize_text_field($_GET['powerFrom']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Min HP', 'eurostocks'); ?>
                <?php echo esc_html($powerfrom); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['powerTo']) && $_GET['powerTo'] != "") {
              $remove_arg_url = add_query_arg('powerTo', '');
              $powerto = sanitize_text_field($_GET['powerTo']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Max HP', 'eurostocks'); ?>
                <?php echo esc_html($powerto); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['priceFrom']) && $_GET['priceFrom'] != "") {
              $remove_arg_url = add_query_arg('priceFrom', '');
              $pricefrom = sanitize_text_field($_GET['priceFrom']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Min €', 'eurostocks'); ?>
                <?php echo esc_html($pricefrom); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['priceTo']) && $_GET['priceTo'] != "") {
              $remove_arg_url = add_query_arg('priceTo', '');
              $priceto = sanitize_text_field($_GET['priceTo']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php esc_html_e('Max €', 'eurostocks'); ?>
                <?php echo esc_html($priceto); ?> <span>&times;</span>
              </a>
            <?php
            }

            if (isset($_GET['fuelType']) && $_GET['fuelType'] != "") {
              $remove_arg_url = add_query_arg('fuelType', '');
              if (is_array($eurostocks_fuel_types)) {
                foreach ($eurostocks_fuel_types as $option) {
                  if (is_array($option) && $_GET['fuelType'] == $option['key']) {
                    if ($option['description'] == "Hybride (benzine/elektrisch)") {
                      $fueltype = "Hybride benzine";
                    } elseif ($option['description'] == "Hybride (diesel/elektrisch)") {
                      $fueltype = "Hybride diesel";
                    } else {
                      $fueltype = $option['description'];
                    }
                    $fueltypedescription = $fueltype;
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($fueltypedescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['transmission']) && $_GET['transmission'] != "") {
              $remove_arg_url = add_query_arg('transmission', '');
              if (is_array($eurostocks_transmissions)) {
                foreach ($eurostocks_transmissions as $option) {
                  if (is_array($option) && $_GET['transmission'] == $option['key']) {
                    $transmissiondescription = $option['description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($transmissiondescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['speedControl']) && $_GET['speedControl'] != "") {
              $remove_arg_url = add_query_arg('speedControl', '');
              $speedcontrol = sanitize_text_field($_GET['speedControl']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($speedcontrol); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['interiorType']) && $_GET['interiorType'] != "") {
              $remove_arg_url = add_query_arg('interiorType', '');
              if (is_array($eurostocks_interior_types)) {
                foreach ($eurostocks_interior_types as $option) {
                  if (is_array($option) && $_GET['interiorType'] == $option['key']) {
                    $interiorTypedescription = $option['description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($interiorTypedescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['trailerCoupling']) && $_GET['trailerCoupling'] != "") {
              $remove_arg_url = add_query_arg('trailerCoupling', '');
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html("Coupling"); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['climatisation']) && $_GET['climatisation'] != "") {
              $remove_arg_url = add_query_arg('climatisation', '');
              if (is_array($eurostocks_climatisations)) {
                foreach ($eurostocks_climatisations as $option) {
                  if (is_array($option) && $_GET['climatisation'] == $option['key']) {
                    $climatisationdescription = $option['description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($climatisationdescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['carCategory']) && $_GET['carCategory'] != "") {
              $remove_arg_url = add_query_arg('carCategory', '');
              if (is_array($eurostocks_categories)) {
                foreach ($eurostocks_categories as $option) {
                  if (is_array($option) && $_GET['carCategory'] == $option['Key']) {
                    $carCategorydescription = $option['Description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($carCategorydescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['headlightType']) && $_GET['headlightType'] != "") {
              $remove_arg_url = add_query_arg('headlightType', '');
              if (is_array($eurostocks_headlight_types)) {
                foreach ($eurostocks_headlight_types as $option) {
                  if (is_array($option) && $_GET['headlightType'] == $option['key']) {
                    $headlightTypedescription = $option['description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($headlightTypedescription); ?> <span>&times;</span>
              </a>
            <?php
            }
            if (isset($_GET['doorCount']) && $_GET['doorCount'] != "") {
              $remove_arg_url = add_query_arg('doorCount', '');
              $doorcount = sanitize_text_field($_GET['doorCount']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($doorcount); ?> <span>&times;</span>
              </a>
            <?php
            }

            if (isset($_GET['seatsCount']) && $_GET['seatsCount'] != "") {
              $remove_arg_url = add_query_arg('seatsCount', '');
              $seatscount = sanitize_text_field($_GET['seatsCount']);
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($seatscount) . ' ' . esc_html__('seats', 'eurostocks'); ?> <span>&times;</span>
              </a>
            <?php
            }


            if (isset($_GET['exteriorColor']) && $_GET['exteriorColor'] != "") {
              $remove_arg_url = add_query_arg('exteriorColor', '');
              if (is_array($eurostocks_exterior_colors)) {
                foreach ($eurostocks_exterior_colors as $option) {
                  if (is_array($option) && $_GET['exteriorColor'] == $option['key']) {
                    $exteriorColordescription = $option['description'];
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($exteriorColordescription); ?> <span>&times;</span>
              </a>
            <?php
            }

            if (isset($_GET['driveType']) && $_GET['driveType'] != "") {
              $remove_arg_url = add_query_arg('driveType', '');
              if (is_array($eurostocks_drive_types)) {
                foreach ($eurostocks_drive_types as $option => $label) {
                  if ($_GET['driveType'] == $option) {
                    $driveTypedescription = $label;
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($driveTypedescription); ?> <span>&times;</span>
              </a>
            <?php
            }

            if (isset($_GET['vat']) && $_GET['vat'] != "") {
              $remove_arg_url = add_query_arg('vat', '');
              if ($_GET['vat'] == 'ja') {
                $vatDescription = esc_html__('VAT deductible', 'eurostocks');
              }

            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($vatDescription); ?> <span>&times;</span>
              </a>
            <?php
            }


            if (isset($_GET['options']) && $_GET['options'] != "") {
              $remove_arg_url = add_query_arg('options', '');
              $optionsDescription = esc_html__('Options:', 'eurostocks') . ' ';
              $m = 0;
              $getcaroptions = array_map('sanitize_key', $_GET['options']);

              foreach ($caroptions as $k => $v) {
                foreach ($getcaroptions as $option) {

                  if (strtolower($option) == strtolower($k)) {
                    if ($m > 0) {
                      $optionsDescription .= ', ' . $v;
                    } else {
                      $optionsDescription .= $v;
                    }
                    $m++;
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($optionsDescription); ?> &times;
              </a>
            <?php
            }

            if (isset($_GET['parkingAssist']) && $_GET['parkingAssist'] != "") {
              $remove_arg_url = add_query_arg('parkingAssist', '');
              $optionsDescription = esc_html__('Options:', 'eurostocks') . ' ';
              $m = 0;
              $getassists = array_map('sanitize_key', $_GET['parkingAssist']);

              foreach ($parkingsensors as $k => $v) {
                foreach ($getassists as $option) {

                  if (strtolower($option) == strtolower($k)) {
                    if ($m > 0) {
                      $optionsDescription .= ', ' . $v;
                    } else {
                      $optionsDescription .= $v;
                    }
                    $m++;
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($optionsDescription); ?> &times;
              </a>
            <?php
            }


            if (isset($_GET['parkingAssistant']) && $_GET['parkingAssistant'] != "") {
              $remove_arg_url = add_query_arg('parkingAssistant', '');
              $optionsDescription = esc_html__('Parking sensors:', 'eurostocks') . ' ';
              $m = 0;
              $getcaroptions = array_map('sanitize_key', $_GET['parkingAssistant']);

              foreach ($parkingsensors as $k => $v) {
                foreach ($parkingAssistants as $option) {

                  if (strtolower($option) == strtolower($k)) {
                    if ($m > 0) {
                      $optionsDescription .= ', ' . $v;
                    } else {
                      $optionsDescription .= $v;
                    }
                    $m++;
                  }
                }
              }
            ?>
              <a class="euro-remove-filter" href="<?php echo esc_url($remove_arg_url); ?>">
                <?php echo esc_html($optionsDescription); ?> &times;
              </a>
            <?php
            }

            ?>
          </div>

          <?php if ((isset($options['hide_sort']) && $options['hide_sort'] == 1) || (isset($options['hide_sort_price']) && $options['hide_sort_price'] == 1) && (isset($options['hide_sort_mileage']) && $options['hide_sort_mileage'] == 1) && (isset($options['hide_sort_registration']) && $options['hide_sort_registration'] == 1) && (isset($options['hide_sort_creation']) && $options['hide_sort_creation'] == 1)) {
            echo '';
          } else { ?>
            <div class="eurofilters">
              <?php
              if (isset($_GET['sortOn'])) {
                $sorton = sanitize_text_field($_GET['sortOn']);
              } elseif (isset($atts['sortOn'])) {
                $sorton = sanitize_text_field($atts['sortOn']);
              } elseif (isset($options['default_sort'])) {
                $sorton = sanitize_text_field($options['default_sort']);
              } else {
                $sorton = 'creationDesc';
              }

              ?>
              <select class="es-inline-block es-input-c" name="sortOn">
                <option disabled="disabled">
                  <?php esc_html_e('Sort on', 'eurostocks'); ?>
                </option>
                <?php if (isset($options['hide_sort_price']) && $options['hide_sort_price'] == 1) {
              
                } else { ?>
                  <option <?php echo ($sorton == 'priceAsc' ? 'selected' : ''); ?> value="priceAsc">
                    <?php esc_html_e('Price low - high', 'eurostocks'); ?>
                  </option>
                  <option <?php echo ($sorton == 'priceDesc' ? 'selected' : ''); ?> value="priceDesc">
                    <?php esc_html_e('Price high - low', 'eurostocks'); ?>
                  </option>
                <?php } ?>
                <?php if (isset($options['hide_sort_mileage']) && $options['hide_sort_mileage'] == 1) {
               
                } else { ?>
                  <option <?php echo ($sorton == 'mileageAsc' ? 'selected' : ''); ?> value="mileageAsc">
                    <?php esc_html_e('Mileage low - high', 'eurostocks'); ?>
                  </option>
                  <option <?php echo ($sorton == 'mileageDesc' ? 'selected' : ''); ?> value="mileageDesc">
                    <?php esc_html_e('Mileage high - low', 'eurostocks'); ?>
                  </option>
                <?php } ?>
                <?php if (isset($options['hide_sort_registration']) && $options['hide_sort_registration'] == 1) {
              
                } else { ?>
                  <option <?php echo ($sorton == 'registrationAsc' ? 'selected' : ''); ?> value="registrationAsc">
                    <?php esc_html_e('Registration date old - new', 'eurostocks'); ?>
                  </option>
                  <option <?php echo ($sorton == 'registrationDesc' ? 'selected' : ''); ?> value="registrationDesc">
                    <?php esc_html_e('Registration date new - old', 'eurostocks'); ?>
                  </option>
                <?php } ?>
                <?php if (isset($options['hide_sort_creation']) && $options['hide_sort_creation'] == 1) {
              
                } else { ?>
                  <option <?php echo ($sorton == 'creationAsc' ? 'selected' : ''); ?> value="creationAsc">
                    <?php esc_html_e('Date added old - new', 'eurostocks'); ?>
                  </option>
                  <option <?php echo ($sorton == 'creationDesc' ? 'selected' : ''); ?> value="creationDesc">
                    <?php esc_html_e('Date added new - old', 'eurostocks'); ?>
                  </option>
                <?php } ?>
              </select>
            </div>
          <?php } ?>

        </div>

        <div>
          <?php if (isset($options['griddisplay']) && $options['griddisplay'] == '1') {
            include_once('eurostocks-public-display-grid.php');
          } else { 
            include_once('eurostocks-public-display-list.php');

            if (count($vehicles) > 0 || (isset($_GET['make']) && isset($_GET['model']))) {
              if (isset($options['replacement_img']) && $options['replacement_img'] != '') {
                $replacement_img = wp_get_attachment_image_url($options['replacement_img'], 'full'); ?>
                <a href="<?php if (isset($options['cta_url']) && $options['cta_url'] != '') {
                            echo esc_html($options['cta_url']);
                          } else {
                            echo '#';
                          } ?>" <?php if (isset($options['cta_url']) && $options['cta_url'] != '') {
                                  echo 'target="_blank" data-cta="a" ';
                                } else {
                                  echo 'data-cta="b" data-modal="es-contact" ';
                                } ?>
                  class="estocks eurocol-12 eurocol-sm-6 eurocol-lg-4 es-cta-action"
                  style="background-image: url('<?php echo esc_url($replacement_img); ?>'); min-height:220px; min-width:100%; width:100%;">
                </a>
          <?php
              }
            }
          }
         } ?>

        <?php
        if (isset($_GET['pagenumber'])) {
          $pagenumber = esc_html(sanitize_text_field($_GET['pagenumber']));
        } else {
          $pagenumber = 1;
        }
        ?>
        <div class="estocks-pagination">
          <?php if ($pagenumber > 1) {
          ?>
            <a class="btn" href="<?php echo esc_html(add_query_arg('pagenumber', esc_html($pagenumber) - 1)); ?>">
              <svg height="14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512">
                <path
                  d="M9.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l128-128c9.2-9.2 22.9-11.9 34.9-6.9s19.8 16.6 19.8 29.6l0 256c0 12.9-7.8 24.6-19.8 29.6s-25.7 2.2-34.9-6.9l-128-128z" />
              </svg>
            </a>
          <?php
          }
          $i = 1;
          if ($total_pages > 49) {
            $total_pages = 50;
          }

          if ($pagenumber - 4 > 1 && $pagenumber > 8) {
            echo "<a class='btn " . ($pagenumber == 1 ? 'active' : '') . "' href='" . esc_url(add_query_arg('pagenumber', 1)) . "'>1</a> ";
            echo "<a class='btn " . ($pagenumber == 1 + 1 ? 'active' : '') . "' href='" . esc_url(add_query_arg('pagenumber', 1 + 1)) . "'>" . '...' . "</a> ";
          }
          while ($i <= $total_pages) {

            $current_url = add_query_arg('pagenumber', $i); ?>

          <?php
            if ($total_pages > 8) {
              if ($i > $pagenumber - 4 && $i < $pagenumber + 4 && $i != $total_pages) {
                echo "<a class='btn " . ($pagenumber == $i ? 'active' : '') . "' href='" . esc_url($current_url) . "'>" . esc_html($i) . "</a> ";
              }
            } else {
              echo "<a class='btn " . ($pagenumber == $i ? 'active' : '') . "' href='" . esc_url($current_url) . "'>" . esc_html($i) . "</a> ";
            }
            $i++;
          }
          if ($total_pages > 8) {
            if ($pagenumber + 4 < $total_pages) {
              echo "<a class='btn " . ($pagenumber == $total_pages - 1 ? 'active' : '') . "' href='" . esc_url(add_query_arg('pagenumber', esc_html($total_pages) - 1)) . "'>" . '...' . "</a> ";
            }
            echo "<a class='btn " . ($pagenumber == $total_pages ? 'active' : '') . "' href='" . esc_url(add_query_arg('pagenumber', esc_html($total_pages))) . "'>" . esc_html($total_pages) . "</a> ";
          }
          ?>

          <?php if ($pagenumber < $total_pages) { ?>
            <a class="btn" href="<?php echo esc_url(add_query_arg('pagenumber', esc_html($pagenumber) + 1)); ?>">
              <svg height="14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512">
                <path
                  d="M246.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9s-19.8 16.6-19.8 29.6l0 256c0 12.9 7.8 24.6 19.8 29.6s25.7 2.2 34.9-6.9l128-128z" />
              </svg>
            </a>
          <?php } ?>
        </div>

</form>
</div>
</div>
</div>

<script>
  <?php
  if ($diflang && isset($options[$current_lang]) && isset($options[$current_lang]['txt_search_help']) && $options[$current_lang]['txt_search_help'] != '') {
    $txt_search_help = $options[$current_lang]['txt_search_help'];
  } else {
    $txt_search_help = $options['txt_search_help'];
  } ?>
  jQuery(document).ready(function($) {
    tippy('#es-info-one', {
      content: '<?php echo wp_kses($txt_search_help, $allowed_html); ?>',
      allowHTML: true,
    });
  });
</script>

<?php if (isset($options['show_powered_by']) && $options['show_powered_by'] == 1) { ?>
  <div class="eurocol-12">
    <a href="https://www.eurostocks.com/nl-nl/cms/onze-diensten/importsoftware" target="_blank" rel="noopener noreferrer" class="es-float-right es-poweredby-dark">
      <small style="float:left; color: #333; margin-right:8px;"><?php esc_html_e('Powered by', 'eurostocks'); ?></small> <img class="poweredby poweredby-dark es-float-right"
        src="<?php echo esc_url(plugin_dir_url(__FILE__)) . '../images/eurostocks.png'; ?>" alt="Powered By Eurostocks" loading="lazy" />
    </a>
  </div>
<?php } elseif (isset($options['show_powered_by']) && $options['show_powered_by'] == 2) { ?>
  <div class="eurocol-12">
    <a href="https://www.eurostocks.com/nl-nl/cms/onze-diensten/importsoftware" target="_blank" rel="noopener noreferrer" class="es-float-right">
      <small style="float:left; color: #b4b4b4; margin-right:8px;"><?php esc_html_e('Powered by', 'eurostocks'); ?></small> <img
        class="poweredby es-float-right"
        src="<?php echo esc_url(plugin_dir_url(__FILE__)) . '../images/eurostocks-w.png'; ?>"
        alt="Powered By Eurostocks" loading="lazy" />
    </a>
  </div>

<?php } ?>

<div class="euro-modal" id="es-contact">
  <div class="euro-modal-bg euro-modal-exit"></div>
  <div class="euro-modal-container">
    <h3>
      <?php esc_html_e('Contact opnemen', 'eurostocks'); ?>
    </h3>
    <form method="POST" action="" class="euro-contact-form" id="car-contact-form">
      <?php wp_nonce_field('car_contact_form', 'car_contact_form_nonce'); ?>
      <label>
        <?php esc_html_e('Naam', 'eurostocks'); ?><br>
        <input type="text" name="name" required>
      </label>
      <?php
      global $wp;
      $current_url = home_url(add_query_arg(array(), $wp->request));
      ?>
      <label class="euro-hidden">
        <?php esc_html_e('Auto', 'eurostocks'); ?> <br>
        <input class="euro-car-id" type="text" value="<?php echo esc_url($current_url); ?>" name="car">
      </label>

      <label>
        <?php esc_html_e('Phone number', 'eurostocks'); ?> <br>
        <input type="tel" name="tel" required>
      </label>

      <label class="euro-hidden">
        <input class="" type="text" value="a" name="form_id">
      </label>

      <label>
        <?php esc_html_e('E-mail', 'eurostocks'); ?><br>
        <input type="email" name="email" required>
      </label>

      <label>
        <?php esc_html_e('Message', 'eurostocks'); ?><br>
        <textarea rows="5" name="message" required></textarea>
      </label>


      <button type="submit" class="euro-btn euro-btn-primary euro-contactform-submit"
        value="<?php esc_html_e("Send", 'eurostocks'); ?>">
        <?php esc_html_e('Send', 'eurostocks'); ?>
      </button>
    </form>
    <button class="euro-modal-close euro-modal-exit">X</button>
  </div>
</div>
