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

class RsAdminController {

    public static function resalesConfig() {
        include plugin_dir_path(__DIR__) . 'views/admin/page-resales.php';
    }

    public static function rsCustomizeProperties() {
        include plugin_dir_path(__DIR__) . 'views/admin/page-customize-properties-display.php';
    }

    public static function rsCustomizeFilters() {
        include plugin_dir_path(__DIR__) . 'views/admin/page-customize-filters.php';
    }
    public static function rsCustomizeDetails(){
        include plugin_dir_path(__DIR__) . 'views/admin/page-customize-property-details.php';
    }
    public static function resalesSettingsView(){
        include plugin_dir_path(__DIR__) . 'views/admin/page-resales-admin-settings.php';
    }

    public static function rsRegisterSettings() {
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_custom_route');

        register_setting('rs_zoddak_resales_group', 'rs_zoddak_api_url');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_api_token',[
            'sanitize_callback' => ['RsApiController', 'rsValidateApiToken']
        ]);
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_items_per_page');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_show_mls_properties');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_restrict_admins');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_contact_shortcode');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_show_language_selector');
        register_setting('rs_zoddak_resales_group', 'rs_zoddak_google_maps_api');
        add_settings_section(
            'rs_zoddak_resales_section',
            T_('Properties Display Settings'),
            function() {
                echo '<p>'. T_('Configure your custom path and API key to display properties from the external API.') . '</p>';
            },
            'rs_zoddak_resales_page'
        );
        add_settings_field(
            'rs_zoddak_custom_route',
            T_('Custom Routes'),
            function() {
                $route = get_option('rs_zoddak_custom_route', 'resales');
                echo '<div class="route-row">';
                echo '<input type="text" name="rs_zoddak_custom_route" value="' . esc_attr($route) . '" class="regular-text zoddak-route-input" placeholder="/ruta" style="margin-right:10px;">';
                echo '</div>';
            },
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );


        add_settings_field(
            'rs_zoddak_api_url',
            T_('API URL'),
            function() {
                $apiUrl = esc_attr(get_option('rs_zoddak_api_url', RS_API_URL . '/properties/get_properties_for_wp'));
                echo '<input type="text" readonly name="rs_zoddak_api_url" value="' . RS_API_URL . '/properties/get_properties_for_wp' . '" class="regular-text">';
                echo '<p class="description">' . T_('This is the base URL of the API endpoint: ') . ' <code>' . RS_API_URL . '/properties/get_properties_for_wp </code>.</p>';
            }, 
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );

        add_settings_field(
            'rs_zoddak_api_token',
            T_('API Token'),
            function() {
                $token = esc_attr(get_option('rs_zoddak_api_token', ''));
                echo '<input type="password" id="rs_zoddak_api_token" name="rs_zoddak_api_token" value="' . $token . '" class="regular-text">';
                echo '<button type="button" class="button" onclick="toggleApiToken()">👁️</button>';
                echo '<p class="description">' . T_('Enter your API key to access property data. Click the eye icon to show/hide.'). '</p>';
                echo '<script>
                    function toggleApiToken() {
                        const input = document.getElementById("rs_zoddak_api_token");
                        input.type = (input.type === "password") ? "text" : "password";
                    }
                </script>';
            },
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );
        add_settings_field(
            'rs_zoddak_show_mls_properties',
            T_('Show MLS Properties'),
            function() {
                $checked = checked(1, get_option('rs_zoddak_show_mls_properties', 0), false);
                echo '<label><input type="checkbox" name="rs_zoddak_show_mls_properties" value="1" ' . $checked . '>'. T_(' Show MLS properties in the list.') . '</label>';
                echo '<p class="description">' . T_('If enabled, MLS properties will be displayed in the list of properties.') . '</p>';
            },
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );
        add_settings_field(
            'rs_zoddak_restrict_admins',
            T_('Restrict to Administrators'),
            function() {
                $checked = checked(1, get_option('rs_zoddak_restrict_admins', 0), false);
                echo '<label><input type="checkbox" name="rs_zoddak_restrict_admins" value="1" ' . $checked . '>'. T_(' Only administrators can access property paths.') . '</label>';
                echo '<p class="description">' . T_('If enabled, only administrators will be able to access the custom path and property details.') . '</p>';
            },
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );

        add_settings_field(
            'rs_zoddak_contact_shortcode',
            T_('Contact Form Shortcode'),
            function() {
                $shortcode = esc_attr(get_option('rs_zoddak_contact_shortcode', '[contact-form-7 id="123" title="Contacto"]'));
                echo '<input type="text" name="rs_zoddak_contact_shortcode" value="' . $shortcode . '" class="regular-text">';
                echo '<p class="description">' . T_('Enter the Contact Form 7 shortcode, for example:') . ' <code>[contact-form-7 id="123" title="Contacto"]</code>.</p>';
            }, 
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );
        add_settings_field(
            'rs_zoddak_google_maps_api',
            'Google Maps API',
            function(){
                $gMapsApi = get_option('rs_zoddak_google_maps_api');
                echo '<input type="password" name="rs_zoddak_google_maps_api" value="' . $gMapsApi . '" class="regular-text">';
                echo '<p class="description">' . T_('Do you have a Google Maps API key? Paste it here and Google Map will appear automatically on every property details page. Otherwise, default map will be displayed ') . '</p>'; 
            },
            'rs_zoddak_resales_page',
            'rs_zoddak_resales_section'
        );
    }

   public static function registerPropertyDisplaySettings() 
   {
    // === REGISTRO DE TODOS LOS CAMPOS ===
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_property_layout');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_card_size');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_page_width');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_card_bg_color');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_border_rounded');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_color_button_details');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_type_property_btn_color');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_type_property_txt_color');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_color_horizontal_line');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_text_color');
    // register_setting('rs_zoddak_property_display_group', 'rs_rs_zoddak_hover_color');
    register_setting('rs_zoddak_property_display_group', 'rs_zoddak_current_page_color');
    // register_setting('rs_zoddak_property_display_group', 'rs_zoddak_text_size');
    add_settings_section(
        'rs_zoddak_custom_page',
        'Personalizacion del layout',
        null,
        'rs_zoddak_property_display_page'
    );

    add_settings_field(
        'rs_zoddak_page_width',
        T_('Page width'),
        function() {
            $currentWidth = esc_attr(get_option('rs_zoddak_page_width', '960px'));
            echo '<select name="rs_zoddak_page_width">
                    <option value="960px" ' . selected($currentWidth, '960px', false) . '>'. T_('Stretch') .' (960px)</option>
                    <option value="1200px" ' . selected($currentWidth, '1200px', false) . '>'. T_('Medium') . ' (1200px)</option>
                    <option value="1400px" ' . selected($currentWidth, '1400px', false) . '> ' . T_('Wide') .'(1400px)</option>
                    <option value="100%" ' . selected($currentWidth, '100%', false) . '>' . T_('Total width') .' (100%)</option>
                </select>
                <p class="description">' . T_('Select the overall page size.').'</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_custom_page'
    );
    add_settings_field(
        'rs_zoddak_property_layout',
        T_('Property Card Design'),
        function() {
            $layout = esc_attr(get_option('rs_zoddak_property_layout', 'horizontal'));
            echo '<select name="rs_zoddak_property_layout">
                    <option value="horizontal" ' . selected($layout, 'horizontal', false) . '>'. T_('Horizontal (Image on the left)') .'</option>
                    <option value="vertical" ' . selected($layout, 'vertical', false) . '>' . T_('Vertical (Image above)') . '</option>
                </select>
                <p class="description">'. T_('Select the design style for the property cards.').'</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_custom_page'
    );
    add_settings_field(
        'rs_zoddak_card_size',
        T_('Card size'),
        function() {
            $size = esc_attr(get_option('rs_zoddak_card_size', 'small'));
            echo '<select name="rs_zoddak_card_size">
                    <option value="small" ' . selected($size, 'small', false) . '>'.T_('Small').'</option>
                    <option value="medium" ' . selected($size, 'medium', false) . '>'.T_('Medium').'</option>
                    <option value="large" ' . selected($size, 'large', false) . '>'.T_('Large').'</option>
                </select>
                <p class="description">' . 
                    T_('The number of cards per row varies depending on the size and width of the page:') . '<br>
                    <strong>'. T_('Small:') . '</strong>'.T_(' 3 (narrow), 4 (medium), 5 (wide), 6 (full).').'<br>
                    <strong>'.T_('Medium:').'</strong>'.T_(' 2 (narrow), 3 (medium), 4 (wide), 5 (full).').'<br>
                    <strong>'.T_('Large:').'</strong>'.T_(' 2 (narrow), 2 (medium, larger), 3 (wide), 4 (full)'). '
                </p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_custom_page'
    );

    add_settings_section(
        'rs_zoddak_property_display_section',
        T_('Customization of the Properties card'),
        null,
        'rs_zoddak_property_display_page'
    );

    add_settings_field(
        'rs_zoddak_border_rounded',
        T_('Card edges'),
        function(){
            $rounded = esc_attr(get_option('rs_zoddak_border_rounded', true));
                        echo '<select name="rs_zoddak_border_rounded">
                                <option value="7px" ' . selected($rounded, '7px', false) . '>'.T_('Rounded').'</option>
                                <option value="0px" ' . selected($rounded, '0px', false) . '>'.T_('Peak').'</option>
                            </select>
                <p class="description">' . T_('Select the shape of the card edges. The selection will affect the edges of the other elements in this plugin for better visual consistency.' ).' </p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_property_display_section'
    );
    add_settings_field(
        'rs_zoddak_card_bg_color',
        T_('Card background color'),
        function() {
            $color = esc_attr(get_option('rs_zoddak_card_bg_color', '#ffffff'));
            echo '<input type="text" name="rs_zoddak_card_bg_color" value="' . $color . '" class="my-color-field" data-default-color="#ffffff" />';
            echo '<p class="description">'. T_('Select the background color for the property cards.').'</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_property_display_section'
    );

    add_settings_field(
        'rs_zoddak_color_horizontal_line',
        T_('Color of the horizontal line'),
        function() {
            $colorBtn = esc_attr(get_option('rs_zoddak_color_horizontal_line', '#c61c1c'));
            echo '<input type="text" name="rs_zoddak_color_horizontal_line" value="' . $colorBtn . '" class="my-color-field" data-default-color="#c61c1c" />';
            echo '<p class="description">'. T_('Select the color of the horizontal line.') . '</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_property_display_section'
    );
    add_settings_field(
        'rs_zoddak_text_color',
        T_('Card text color'),
        function() {
            $colorBtn = esc_attr(get_option('rs_zoddak_text_color', 'white'));
            echo '<input type="text" name="rs_zoddak_text_color" value="' . $colorBtn . '" class="my-color-field" data-default-color="white" />';
            echo '<p class="description">' . T_('Select the color of the text on the card.') . '</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_property_display_section'
    );


    add_settings_section(
        'rs_zoddak_settings_display_buttons',
        T_('Button customization'),
        null,
        'rs_zoddak_property_display_page'
    );

    add_settings_field(
        'rs_zoddak_type_property_btn_color',
        T_('Color of the Property reference button'),
        function() {
            $colorBtnType = esc_attr(get_option('rs_zoddak_type_property_btn_color', '#dddd0f'));
            echo '<input type="text" name="rs_zoddak_type_property_btn_color" value="' . $colorBtnType . '" class="my-color-field" data-default-color="#dddd0f" />';
            echo '<p class="description">' . T_('Select the color of the property reference button.') . '</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_settings_display_buttons'
    );

    add_settings_field(
        'rs_zoddak_type_property_txt_color',
        T_('Property Type Text Color'),
        function() {
            $colorTxtType = esc_attr(get_option('rs_zoddak_type_property_txt_color', '#ffffff'));
            echo '<input type="text" name="rs_zoddak_type_property_txt_color" value="' . $colorTxtType . '" class="my-color-field" data-default-color="#ffffff" />';
            echo '<p class="description">' . T_('Select the text color for the property type button.') . '</p>';
        },
        'rs_zoddak_property_display_page',
        'rs_zoddak_settings_display_buttons'
    );

    add_settings_section(
        'rs_zoddak_custom_pagination',
        T_('Customization of pagination'),
        null,
        'rs_zoddak_property_display_page'
    );

    add_settings_field(
        'rs_zoddak_current_page_color',
        T_('Color of the current page number'),
        function() {
            $currentPageColor = esc_attr(get_option('rs_zoddak_current_page_color', '#110400'));
            echo '<input type="text" name="rs_zoddak_current_page_color" value="' . $currentPageColor . '" class="my-color-field" data-default-color="#110400" />';
            echo '<p class="description">' . T_('Select the color of the current page number.') . '</p>';
        },
        'rs_zoddak_property_display_page',
        'zoddak_custom_pagination'
    );

    }
    
    public static function registerFilterDisplaySettings() {
        register_setting('rs_zoddak_filter_display_group', 'rs-zoddak-bg-color-search-menu');
        register_setting('rs_zoddak_filter_display_group', 'rs-zoddak-btn-color-search-menu');
        register_setting('rs_zoddak_filter_display_group', 'rs-zoddak-reset-btn-color');

        add_settings_section(
            'rs_zoddak_filter_display_section',
            T_('Color customization in the filter'),
            null, 
            'rs_zoddak_filter_display_page'
        );

        add_settings_field(
            'rs-zoddak-bg-color-search-menu',
            T_('Search menu background color'),
            function() {
                $bgColor = esc_attr(get_option('rs-zoddak-bg-color-search-menu', '#f5f5f5'));
                echo '<input type="text" name="rs-zoddak-bg-color-search-menu" value="' . $bgColor . '" class="my-color-field" data-default-color="#f5f5f5" />';
                echo '<p class="description">' . T_('Select the background color for the search menu.') . '</p>';
            },
            'rs_zoddak_filter_display_page',
            'rs_zoddak_filter_display_section'
        );

        add_settings_field(
            'rs-zoddak-btn-color-search-menu',
            T_('Color of Search and Find Buttons'),
            function() {
                $btnSearch = esc_attr(get_option('rs-zoddak-btn-color-search-menu', '#070100'));
                echo '<input type="text" name="rs-zoddak-btn-color-search-menu" value="' . $btnSearch . '" class="my-color-field" data-default-color="#070100" />';
                echo '<p class="description">' . T_('Choose the color of the search buttons.') . '</p>';
            },
            'rs_zoddak_filter_display_page',
            'rs_zoddak_filter_display_section'
        );

        add_settings_field(
            'rs-zoddak-reset-btn-color',
            T_('Reset Button Color'),
            function() {
                $btnColor = esc_attr(get_option('rs-zoddak-reset-btn-color', '#ffffff'));
                echo '<input type="text" name="rs-zoddak-reset-btn-color" value="' . $btnColor . '" class="my-color-field" data-default-color="#ffffff" />';
                echo '<p class="description">' . T_('Select the color of the reset button.') . '</p>';
            },
            'rs_zoddak_filter_display_page',
            'rs_zoddak_filter_display_section'
        );
    }
    public static function customizePropertyDetails() {
        register_setting('rs_zoddak_details_display_group', 'rs-zoddak-btn-price-color');
        register_setting('rs_zoddak_details_display_group', 'rs-zoddak-btn-stage-color');
        register_setting('rs_zoddak_details_display_group', 'rs-zoddak-icons-color');
        register_setting('rs_zoddak_details_display_group', 'rs-zoddak-icons-txt-color');
        add_settings_section(
            'rs_zoddak_property_detail_section',
            T_('Customisation of the property details page'),
            null,
            'rs_zoddak_property_detail_page'
        );
        add_settings_field(
            'rs-zoddak-btn-price-color',
            T_('Colour of the Price button'),
            function() {
                $priceBtnColor = esc_attr(get_option('rs-zoddak-btn-price-color', '#e65638'));
                echo '<input type="text" name="rs-zoddak-btn-price-color" value="' . $priceBtnColor . '" class="my-color-field" data-default-color="#e65638" />';
                echo '<p class="description">' . T_('Select the colour of the price button on the property details page.') . '</p>';
            },
            'rs_zoddak_property_detail_page',
            'rs_zoddak_property_detail_section'
        );
        add_settings_field(
            'rs-zoddak-btn-stage-color',
            T_('Property Status Button Colour'),
            function() {
                $stageBtnColor = esc_attr(get_option('rs-zoddak-btn-stage-color', '#dddd0f'));
                echo '<input type="text" name="rs-zoddak-btn-stage-color" value="' . $stageBtnColor . '" class="my-color-field" data-default-color="#dddd0f" />';
                echo '<p class="description">' . T_('Select the colour of the status button on the property details page.') . '</p>';
            },
            'rs_zoddak_property_detail_page',
            'rs_zoddak_property_detail_section'
        );
        add_settings_field(
            'rs-zoddak-icons-color',
            T_('Feature background colour'),
            function() {
                $iconsColor = esc_attr(get_option('rs-zoddak-icons-color', '#e97c61'));
                echo '<input type="text" name="rs-zoddak-icons-color" value="' . $iconsColor . '" class="my-color-field" data-default-color="#e97c61" />';
                echo '<p class="description">' . T_('Select the background colour for the features on the property details page.') . '</p>';
            },
            'rs_zoddak_property_detail_page',
            'rs_zoddak_property_detail_section'
        );
        add_settings_field(
            'rs-zoddak-icons-txt-color',
            T_('Feature color'),
            function() {
                $iconsTxtColor = esc_attr(get_option('rs-zoddak-icons-txt-color', '#000000'));
                echo '<input type="text" name="rs-zoddak-icons-txt-color" value="' . $iconsTxtColor . '" class="my-color-field" data-default-color="#000000" />';
                echo '<p class="description">' . T_('Select the color of the features on the property details page.') . '</p>';
            },
            'rs_zoddak_property_detail_page',
            'rs_zoddak_property_detail_section'
        );
    }
   public static function resalesSettings()
    {
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_resales_location');
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_resales_price_range');
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_resales_stages');
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_resales_types');
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_resales_contact_users');
        register_setting('rs_zoddak_resales_settings_group', 'rs_zoddak_featured_developments');
        add_settings_section(
            'rs_zoddak_resales_admin_section',
            'Ajustes de página',
            null, 
            'rs_zoddak_resales_settings'
        );

        add_settings_field(
            'rs_zoddak_resales_location',
            T_('Areas to hide'),
            function() {
                $selectedLocations = get_option('rs_zoddak_resales_location', []); // ← array
                if (!is_array($selectedLocations)) {
                    $selectedLocations = [$selectedLocations];
                }

                $locations = RsApiController::get_areas();
                echo '<select multiple name="rs_zoddak_resales_location[]" id="rs_zoddak_resales_location" style="min-width: 250px; height: 150px;">';
                echo '<option value="">' . T_('Select one or more locations (Ctrl + clic)') . '</option>';

                foreach ($locations as $loc) {  
                    $name = esc_html($loc['town'] ?? '');
                    if ($name) {
                        $selected = in_array($name, $selectedLocations) ? 'selected' : '';
                        echo '<option value="' . $name . '" ' . $selected . '>' . $name . '</option>';
                    }
                }

                echo '</select>';
                echo '<p class="description">' . T_('Select the areas you do not want to display on your page.') . '</p>';
            },
            'rs_zoddak_resales_settings',       
            'rs_zoddak_resales_admin_section'   
        );
        add_settings_field(
            'rs_zoddak_resales_price_range',
            T_('Rango de precio'),
            function() {
                $priceRange = get_option('rs_zoddak_resales_price_range', ['min' => 0, 'max' => 35000000]);
                $min = esc_attr((int)$priceRange['min']);
                $max = esc_attr($priceRange['max']);
            
            echo '<div class="price-range-wrapper">
                    <div class="price-values">
                        <span id="minPriceLabel">€ ' . number_format($min, 0, ',', '.') . '</span>
                        <span id="maxPriceLabel">€ ' . number_format($max, 0, ',', '.') . '</span>
                    </div>
                    <div class="slider-track"></div>
                    <input type="range" id="minPrice" name="rs_zoddak_resales_price_range[min]" step=150000 min="0" max="35000000" step="1000" value="'. $min .'">
                    <input type="range" id="maxPrice" name="rs_zoddak_resales_price_range[max]" step=150000 min="0" max="35000000" step="1000" value="'. $max .'">
                    
                    <p class="description">' . T_('Select the price range you wish to display.') . ' </p>
                </div>';
            },
            'rs_zoddak_resales_settings',
            'rs_zoddak_resales_admin_section'
        );
        add_settings_field(
            'rs_zoddak_resales_stages',
            T_('Stages'),
            function() {
                $stages = RsApiController::get_property_stage();

                $selectedStages = get_option('rs_zoddak_resales_stages', []);
                if (!is_array($selectedStages)) {
                    $selectedStages = [$selectedStages];
                }   
                $lang = strtolower( substr( get_locale(), 0, 2 ) );
                echo '<select multiple name="rs_zoddak_resales_stages[]" id="rs_zoddak_resales_stages" style="min-width:250px; height:150px;">';
                echo '<option value="">'. T_('Select one or more states to hide') . '(Ctrl + click)</option>';
                if (!empty($stages) && is_array($stages)) {
                    foreach ($stages as $stage) {
                        $name = esc_html($stage[$lang] ?? '');
                        if ($name) {
                            $selected = in_array($name, $selectedStages) ? 'selected' : '';
                            echo '<option value="' . $name . '" ' . $selected . '>' . $name . '</option>';
                        }
                    }
                } else {
                    echo '<option value="">' . T_('No stages found') . '</option>';
                }

                echo '</select>';
                echo '<p class="description">' . T_('Select the stages you wish to hide on your page.'). '</p>';
            },
            'rs_zoddak_resales_settings',
            'rs_zoddak_resales_admin_section'
        );
        add_settings_field(
            'rs_zoddak_resales_types',
            'Tipos',
            function () {
                $selectedTypes = get_option('rs_zoddak_resales_types', []);
                if (!is_array($selectedTypes)) {
                    $selectedTypes = [$selectedTypes];
                }

                $types = [
                    'Apartments',
                    'Villas',
                    'Townhouses'
                ];

                echo '<select multiple name="rs_zoddak_resales_types[]" id="rs_zoddak_resales_types" style="min-width:250px; height:150px;">';
                echo '<option value="">'. T_('Select one or more types to hide') . '(Ctrl + clic)</option>';

                foreach ($types as $type) {
                    $value = strtolower($type);
                    $selected = in_array($value, $selectedTypes) ? 'selected' : '';
                    echo '<option value="' . esc_attr($value) . '" ' . $selected . '>' . esc_html($type) . '</option>';
                }

                echo '</select>';
                echo '<p class="description">' . T_('Select the property types you do not want to display on your page.') . '</p>';
            },
            'rs_zoddak_resales_settings',
            'rs_zoddak_resales_admin_section'
        );
    }

}
