<?php
if ( !function_exists("Divi_filter_item_module_import") ){
    add_action( 'et_builder_ready', 'Divi_filter_item_module_import');

    function Divi_filter_item_module_import(){
        if(class_exists("ET_Builder_Module") && !class_exists("et_pb_df_product_filter_item_code")){

            class et_pb_df_product_filter_item_code extends ET_Builder_Module {

                public $vb_support = 'on';

                public $weight_count = 0;

                public $acf_fields = array();

                public $acf_map_fields = array();

                protected $module_credits = array(
                    'module_uri' => DE_DF_PRODUCT_URL,
                    'author'     => DE_DF_AUTHOR,
                    'author_uri' => DE_DF_URL,
                );

                function init() {

                    global $wpdb;

                    if (defined('DE_DMACH_VERSION')) {
                    $this->name       = esc_html__( 'Search/Filter Item', 'divi-filter' );
                    $this->advanced_setting_title_text = esc_html__( 'New Search/Filter Item', 'divi-filter' );
                    $this->settings_text               = esc_html__( 'Search/Filter Item Settings', 'divi-filter' );
                    } else {
                  $this->name       = esc_html__( 'Filter Item', 'divi-filter' );
                  $this->advanced_setting_title_text = esc_html__( 'New Filter Item', 'divi-filter' );
                  $this->settings_text               = esc_html__( 'Filter Item Settings', 'divi-filter' );
                    }

                    $sql = "SELECT COUNT(*) FROM {$wpdb->posts} a INNER JOIN {$wpdb->postmeta} b ON a.id=b.post_id where a.post_type='product' AND b.meta_key='_weight'";
                    $this->weight_count = $wpdb->get_var($sql);

                    $this->slug = 'et_pb_de_mach_search_posts_item';
                    $this->vb_support      = 'on';
                    $this->type                        = 'child';
                    $this->child_title_var             = 'title';

                    $this->fields_defaults = array(
                    // 'loop_layout'         => array( 'on' ),
                    );

                    if ( class_exists( 'DE_Filter' ) ) {
                        $this->acf_fields = DE_Filter::get_acf_fields();    
                    } else if ( class_exists( 'DEBC_INIT' ) ) {
                        $this->acf_fields = DEBC_INIT::get_acf_fields();
                    } else if ( class_exists( 'DEDMACH_INIT' ) ) {
                        $this->acf_fields = DEDMACH_INIT::get_acf_fields();
                    }
                    

                    $this->acf_map_fields = $this->get_acf_map_fields();

                    $this->settings_modal_toggles = array(
                        'general' => array(
                            'toggles' => array(
                                'main_content' => esc_html__( 'Main Options', 'divi-filter' ),
                                'layout' => esc_html__( 'Layout Options', 'divi-filter' ),
                                'text_filter' => esc_html__( 'Text Filter Options', 'divi-filter' ),
                                'select_filter' => esc_html__( 'Select Filter Options', 'divi-filter' ),
                                'tags_filter' => esc_html__( 'Category Filter Options', 'divi-filter' ),
                                'radio_filter' => esc_html__( 'Checkbox / Radio Filter Options', 'divi-filter' ),
                                'swatch_style_tab' => esc_html__( 'Swatch Filter Options', 'divi-filter' ),
                                'conditional_logic' => esc_html__( 'Conditional Logic', 'divi-filter' ),
                                'range_filter' => esc_html__( 'Range Filter Options', 'divi-filter' ),
                                'true_false_filter' => esc_html__( 'True/False Filter Options', 'divi-filter' ),
                                'radio_button_style' => esc_html__( 'Checkbox / Radio Button Style (Depreciated)', 'divi-filter' ),
                            ),
                        ),
                        'advanced' => array(
                            'toggles' => array(
                                'text' => esc_html__( 'Text', 'divi-filter' ),
                                'select' => array(
                                    'title' => esc_html__( 'Select Style', 'divi-filter' ),
                                ),
                            ),
                        ),
                    );

                    $this->main_css_element = '%%order_class%%';

                    $this->advanced_fields = array(
                        'fonts' => array(
                            'title' => array(
                                'label'    => esc_html__( 'Item', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .et_pb_contact_select, %%order_class%%, %%order_class%% input[type=text], %%order_class%% .divi-filter-item, %%order_class%% input[type=text]::-webkit-input-placeholder, %%order_class%% input[type=text]:-moz-placeholder, %%order_class%% input[type=text]::-moz-placeholder, %%order_class%% input[type=text]:-ms-input-placeholder",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'title_text' => array(
                                'label'    => esc_html__( 'Title', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .et_pb_contact_field_options_title",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'count_text' => array(
                                'label'    => esc_html__( 'Radio / Checkbox Post Count', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .radio-count",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'radio_button_text' => array(
                                'label'    => esc_html__( 'Checkbox / Radio Style', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .et_pb_contact_field_radio label",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'radio_button_text_checked' => array(
                                'label'    => esc_html__( 'Checkbox / Radio Checked Style', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .et_pb_contact_field_radio input:checked+label",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'range_primary_text' => array(
                                'label'    => esc_html__( 'Range Primary', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .irs-from, %%order_class%% .irs-to, %%order_class%% .irs-single",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'range_secondary_text' => array(
                                'label'    => esc_html__( 'Range Secondary', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .irs-min, %%order_class%% .irs-max",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'limit_show_more_text' => array(
                                'label'    => esc_html__( 'Limit Show More Text', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .limit_filter_text.showmore",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            'limit_show_less_text' => array(
                                'label'    => esc_html__( 'Limit Show Less Text', 'divi-filter' ),
                                'css'      => array(
                                    'main' => "%%order_class%% .limit_filter_text.showless",
                                    'important' => 'plugin_only',
                                ),
                                'font_size' => array(
                                    'default' => '14px',
                                ),
                                'line_height' => array(
                                    'default' => '1em',
                                ),
                            ),
                            
                        ),
                        'background' => array(
                            'settings' => array(
                                'color' => 'alpha',
                            ),
                        ),
                        'button' => array(
                          'button' => array(
                              'label' => esc_html__( 'Radio / Checkbox Button', 'divi-machine' ),
                              'css' => array(
                                  'main' => "{$this->main_css_element} .divi-radio-buttons .et_pb_contact_field_radio label",
                                  'important' => 'all',
                              ),
                              'box_shadow'  => array(
                                  'css' => array(
                                      'main' => "{$this->main_css_element} .divi-radio-buttons .et_pb_contact_field_radio label",
                                      'important' => 'all',
                                  ),
                              ),
                              'margin_padding' => array(
                                  'css'           => array(
                                      'main' => "{$this->main_css_element} .divi-radio-buttons .et_pb_contact_field_radio label",
                                      'important' => 'all',
                                  ),
                              ),
                          ),
                          'active_button' => array(
                          'label' => esc_html__( 'Active Radio / Checkbox Button', 'divi-bodyshop-woocommerce' ),
                          'css' => array(
                            'main' => "{$this->main_css_element} .divi-radio-buttons .et_pb_contact_field_radio input:checked + label",
                            'important' => 'all',
                          ),
                          'box_shadow'  => array(
                            'css' => array(
                              'main' => ".woocommerce {$this->main_css_element} .divi-radio-buttons .et_pb_contact_field_radio input:checked + label",
                            ),
                          ),
                          ),
                        
                        
                        ),
                        'form_field'           => array(
                            'form_field' => array(
                                'label'         => esc_html__( 'Fields', 'divi-filter' ),
                                'css'           => array(
                                    'main' => '%%order_class%% .et_pb_contact_select, %%order_class%% .et_pb_contact_field[type="checkbox"] + label i, %%order_class%% .et_pb_contact_field[type="radio"] + label i',
                                    'background_color'       => '%%order_class%% .et_pb_contact_select, %%order_class%% input.divi-filter-item, %%order_class%% .et_pb_contact_field[type="checkbox"] + label i, %%order_class%% .et_pb_contact_field[type="radio"] + label i',
                                    'background_color_hover' => '%%order_class%% .et_pb_contact_select:hover, %%order_class%% input.divi-filter-item:hover, %%order_class%% .et_pb_contact_field[type="checkbox"]:hover + label i, %%order_class%% .et_pb_contact_field[type="radio"]:hover + label i',
                                    'focus_background_color' => '%%order_class%% .et_pb_contact_select:focus, %%order_class%% input.divi-filter-item:focus, %%order_class%% .et_pb_contact_field[type="checkbox"]:active + label i, %%order_class%% .et_pb_contact_field[type="radio"]:active + label i',
                                    'focus_background_color_hover' => '%%order_class%% .et_pb_contact_select:focus:hover, %%order_class%% input.divi-filter-item:focus:hover, %%order_class%% .et_pb_contact_field[type="checkbox"]:active:hover + label i, %%order_class%% .et_pb_contact_field[type="radio"]:active:hover + label i',
                                    'placeholder_focus'      => '%%order_class%% p input:focus::-webkit-input-placeholder, %%order_class%% input.divi-filter-item:focus::-webkit-input-placeholder, %%order_class%% p input:focus::-moz-placeholder, %%order_class%% p input:focus:-ms-input-placeholder, %%order_class%% p textarea:focus::-webkit-input-placeholder, %%order_class%% p textarea:focus::-moz-placeholder, %%order_class%% p textarea:focus:-ms-input-placeholder',
                                    'padding'                => '%%order_class%% .et_pb_contact_select, %%order_class%% .et_pb_contact_field[type="checkbox"] + label i, %%order_class%% .et_pb_contact_field[type="radio"] + label i',
                                    'margin'                 => '%%order_class%% .et_pb_contact_select, %%order_class%% .et_pb_contact_field[type="checkbox"] + label i, %%order_class%% .et_pb_contact_field[type="radio"] + label i',
                                    'form_text_color'        => '%%order_class%% .et_pb_contact_select, %%order_class%% input.divi-filter-item, %%order_class%% .et_pb_contact_field[type="checkbox"] + label, %%order_class%% .et_pb_contact_field[type="radio"] + label, %%order_class%% .et_pb_contact_field[type="checkbox"]:checked + label i:before',
                                    'form_text_color_hover'  => '%%order_class%% .et_pb_contact_select:hover, %%order_class%% input.divi-filter-item:hover, %%order_class%% .et_pb_contact_field[type="checkbox"]:hover + label, %%order_class%% .et_pb_contact_field[type="radio"]:hover + label, %%order_class%% .et_pb_contact_field[type="checkbox"]:checked:hover + label i:before',
                                    'focus_text_color'       => '%%order_class%% .et_pb_contact_select:focus, %%order_class%% input.divi-filter-item:focus, %%order_class%% .et_pb_contact_field[type="checkbox"]:active + label, %%order_class%% .et_pb_contact_field[type="radio"]:active + label, %%order_class%% .et_pb_contact_field[type="checkbox"]:checked:active + label i:before',
                                    'focus_text_color_hover' => '%%order_class%% .et_pb_contact_select:focus:hover, %%order_class%% input.divi-filter-item:focus:hover, %%order_class%% .et_pb_contact_field[type="checkbox"]:active:hover + label, %%order_class%% .et_pb_contact_field[type="radio"]:active:hover + label, %%order_class%% .et_pb_contact_field[type="checkbox"]:checked:active:hover + label i:before',
                                ),

                                'box_shadow'    => false,
                                'border_styles' => false,
                                'font_field'    => array(
                                    'css' => array(
                                        'main'  => implode( ', ', array(
                                            "{$this->main_css_element} input",
                                            "{$this->main_css_element} select",
                                            "{$this->main_css_element} input::placeholder",
                                            "{$this->main_css_element} input::-webkit-input-placeholder",
                                            "{$this->main_css_element} input::-moz-placeholder",
                                            "{$this->main_css_element} input:-ms-input-placeholder",
                                            "{$this->main_css_element} input[type=checkbox] + label",
                                            "{$this->main_css_element} input[type=radio] + label",
                                        ) ),
                                        'hover' => array(
                                            "{$this->main_css_element} input:hover",
                                            "{$this->main_css_element} select:hover",
                                            "{$this->main_css_element} input:hover::placeholder",
                                            "{$this->main_css_element} input:hover::-webkit-input-placeholder",
                                            "{$this->main_css_element} input:hover::-moz-placeholder",
                                            "{$this->main_css_element} input:hover:-ms-input-placeholder",
                                            "{$this->main_css_element} input[type=checkbox]:hover + label",
                                            "{$this->main_css_element} input[type=radio]:hover + label",
                                        ),
                                    ),
                                ),
                                'margin_padding' => array(
                                    'css'        => array(
                                        'main'    => '%%order_class%% .et_pb_contact_field',
                                        'padding' => '%%order_class%% .et_pb_contact_field input',
                                        'margin'  => '%%order_class%% .et_pb_contact_field',
                                    ),
                                    'important' => 'all',
                                ),
                            ),
                        ),
                        'height'         => array(
                            'css' => array(
                                'main' => implode( ', ',
                                    array(
                                        '%%order_class%% input[type=text]',
                                        '%%order_class%% input[type=email]',
                                        '%%order_class%% textarea',
                                        '%%order_class%% [data-type=checkbox]',
                                        '%%order_class%% [data-type=radio]',
                                        '%%order_class%% [data-type=select]',
                                        '%%order_class%% select',
                                    )
                                ),
                            ),
                        ),
                        'box_shadow' => array(
                            'default' => array(),
                            'product' => array(
                                'label' => esc_html__( 'Default Layout - Box Shadow', 'divi-filter' ),
                                'css' => array(
                                    'main' => "%%order_class%% .products .product",
                                ),
                                'option_category' => 'layout',
                                'tab_slug'        => 'advanced',
                                'toggle_slug'     => 'product',
                            ),
                        ),
                    );

                    $this->custom_css_fields = array( );

                    $this->help_videos = array( );

                }

                public function get_acf_fields(  ){

                    $acf_fields = array();

                    if ( function_exists( 'acf_get_field_groups' ) ) {
                        $fields_all = get_posts(array(
                            'posts_per_page'   => -1,
                            'post_type'        => 'acf-field',
                            'orderby'          => 'name',
                            'order'            => 'ASC',
                            'post_status'       => 'publish',
                        ));

                        $acf_fields['none'] = esc_html__('Please select an ACF field', 'divi-filter');

                        foreach ( $fields_all as $field ) {

                            $post_parent = $field->post_parent;
                            $post_parent_name = get_the_title($post_parent);
                            $grandparent = wp_get_post_parent_id($post_parent);
                            $grandparent_name = get_the_title($grandparent);

                            $acf_fields[$field->post_name] = $post_parent_name . " > " . $field->post_title . " - " . $grandparent_name;

                        }


                        $field_groups = acf_get_field_groups();
                        foreach ( $field_groups as $group ) {
                            // DO NOT USE here: $fields = acf_get_fields($group['key']);
                            // because it causes repeater field bugs and returns "trashed" fields
                            $fields = get_posts(array(
                                'posts_per_page'   => -1,
                                'post_type'        => 'acf-field',
                                'orderby'          => 'name',
                                'order'            => 'ASC',
                                'suppress_filters' => true, // DO NOT allow WPML to modify the query
                                'post_parent'      => $group['ID'],
                                'post_status'       => 'publish',
                                'update_post_meta_cache' => false
                            ));

                            $acf_fields['none'] = esc_html__('Please select an ACF field', 'divi-filter');

                            foreach ( $fields as $field ) {
                                $acf_fields[$field->post_name] = $field->post_title . " - " . $group['title'];
                            }
                        }
                    }

                    return $acf_fields;
                }

                public function get_acf_map_fields( ){

                    $acf_fields = array();

                    if ( function_exists( 'acf_get_field_groups' ) ) {
                        $fields_all = get_posts(array(
                            'posts_per_page'   => -1,
                            'post_type'        => 'acf-field',
                            'orderby'          => 'name',
                            'order'            => 'ASC',
                            'post_status'       => 'publish',
                        ));

                        $acf_fields['none'] = 'Please select an ACF field';

                        foreach ( $fields_all as $field ) {

                            $post_content = maybe_unserialize($field->post_content);
                            if ( isset( $post_content['type'] ) && $post_content['type'] == 'google_map' ) {
                                $post_parent = $field->post_parent;
                                $post_parent_name = get_the_title($post_parent);
                                $grandparent = wp_get_post_parent_id($post_parent);
                                $grandparent_name = get_the_title($grandparent);

                                $acf_fields[$field->post_name] = $post_parent_name . " > " . $field->post_title . " - " . $grandparent_name;
                            }

                        }


                        $field_groups = acf_get_field_groups();
                        foreach ( $field_groups as $group ) {
                            // DO NOT USE here: $fields = acf_get_fields($group['key']);
                            // because it causes repeater field bugs and returns "trashed" fields
                            $fields = get_posts(array(
                                'posts_per_page'   => -1,
                                'post_type'        => 'acf-field',
                                'orderby'          => 'name',
                                'order'            => 'ASC',
                                'suppress_filters' => true, // DO NOT allow WPML to modify the query
                                'post_parent'      => $group['ID'],
                                'post_status'       => 'publish',
                                'update_post_meta_cache' => false
                            ));

                            foreach ( $fields as $field ) {

                                $post_content = maybe_unserialize($field->post_content);
                                if ( isset( $post_content['type'] ) && $post_content['type'] == 'google_map' ) {
                                    $acf_fields[$field->post_name] = $field->post_title . " - " . $group['title'];
                                }

                            }
                        }
                    }

                    return $acf_fields;
                }

                function get_fields() {

                    global $wpdb;

                    $et_accent_color = et_builder_accent_color();

                    ///////////////////////////////

                    $filter_post_type = array(
                        'category'          => 'Category',
                        'tags'    => 'Tags',
                        'search'          => 'Search Text',
                        'taxonomy'          => 'Custom Taxonomy',
                        // 'posttypes'          => 'Post Type Select (Search only)',
                    );

                    if ( function_exists( 'acf_get_field_groups' ) ){
                        $filter_post_type['acf'] = 'Advanced Custom Field (ACF Plugin)';
                        //$filter_post_type['acf_map'] = 'Advanced Custom Field - Map Field (ACF Plugin)';
                    }

                    $productattr = array();

                    if ( class_exists('WooCommerce') ){
                        $filter_post_type['productattr'] = 'Product Attributes';
                        $attribute_taxonomies = wc_get_attribute_taxonomies();
                        $productattr['none'] = 'Please select an Product Attribute';
                        if ( $attribute_taxonomies ) {
                            foreach ( $attribute_taxonomies as $tax ) {
                                $productattr[esc_attr( wc_attribute_taxonomy_name( $tax->attribute_name ) )] = esc_html( $tax->attribute_label );
                            }
                        }
                        $filter_post_type['productprice'] = 'Product Price';

                        if ( $this->weight_count > 0 ){
                            $filter_post_type['productweight']  = 'Product Weight';
                        }
                        $filter_post_type['productrating'] = 'Product Rating';
                    }

                    $fields = array(

                        //////////////////////////////////////////////////
                        /* MAIN OPTIONS */
                        //////////////////////////////////////////////////

                        'title' => array(
                            'label'           => esc_html__( 'Admin Filter Name', 'divi-filter' ),
                            'type'            => 'text',
                            'description'     => esc_html__( 'Change the name of the filter for admin purposes ONLY, this is just used so you can see what the filter is.', 'divi-filter' ),
                            'toggle_slug'     => 'main_content',
                            'dynamic_content' => 'text',
                            'option_category' => 'configuration',
                        ),
                        'filter_post_type' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'What do you want to search/filter?', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => $filter_post_type,
                            'default'           => 'category',
                            'affects'         => array(
                                'text_placeholder',
                                'is_number_input',
                                'acf_name',
                                'acf_map_name',
                                'acf_map_radius_unit',
                                'select_options',
                                'custom_tax_choose',
                                'product_attribute',
                                'attribute_swatch',
                                'post_type_choose',
                                'acf_filter_type',
                                'cat_tag_display_mode',
                                'max_price_type'
                            ),
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose what you want to search or filter', 'divi-filter' ),
                        ),
                        'text_typing_timeout' => array(
                          'toggle_slug'       => 'main_content',
                          'label'             => esc_html__( 'Typing delay to filter', 'divi-filter' ),
                          'type'              => 'range',
                          'option_category'   => 'configuration',
                          'default'   => '2000',
                          'show_if' => [
                              'filter_post_type' => [ 'search' ],
                          ],
                          'range_settings'  => array(
                              'min'  => '0',
                              'max'  => '15000',
                              'step' => '1',
                          ),
                          'description'       => esc_html__( 'Choose the delay it takes for the person to stop typing, for the filter to start searching.', 'divi-filter' ),
                        ),
                        'custom_tax_choose' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Choose Your Taxonomy', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => get_taxonomies( array( '_builtin' => FALSE ) ),
                            'option_category'   => 'configuration',
                            'default'           => 'post',
                            'depends_show_if'  => 'taxonomy',
                            'description'       => esc_html__( 'Choose the custom taxonomy that you have made and want to filter', 'divi-filter' ),
                        ),
                        'post_type_choose' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Post Type', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => et_get_registered_post_type_options( false, false ),
                            'option_category'   => 'configuration',
                            'default'           => 'post',
                            'description'       => esc_html__( 'Choose the post type that you want to filter', 'divi-filter' ),
                            'show_if' => [
                                'filter_post_type' => [ 'category', 'tags', 'search', 'taxonomy', 'posttypes', 'acf' ],
                            ],
                        ),
                        'acf_name' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'ACF Name', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => $this->acf_fields,
                            'default'           => 'none',
                            'depends_show_if'   => 'acf',
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose the ACF item that you want to filter by. Make sure it belongs to the post type you have/want to filter. It cannot be inside a group or repeater type. ', 'divi-filter' ),
                        ),
                        'acf_map_name' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'ACF Map Name', 'divi-ajax-filter' ),
                            'type'              => 'select',
                            'options'           => $this->acf_map_fields,
                            'default'           => 'none',
                            'depends_show_if'   => 'acf_map',
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose the ACF Map item that you want to filter by. Make sure it belongs to the post type you have/want to filter. It cannot be inside a group or repeater type. ', 'divi-ajax-filter' ),
                        ),
                        'acf_map_radius_unit'  => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'ACF Map Radius Unit', 'divi-ajax-filter'),
                            'type'              => 'select',
                            'options'           => array(
                                'km'            => esc_html__( 'Km', 'divi-ajax-filter' ),
                                'mi'            => esc_html__( 'Mile', 'divi-ajax-filter' ),
                            ),
                            'default'           => 'km',
                            'depends_show_if'   => 'acf_map',
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose the Unit of the radius for search by address or zip code.', 'divi-ajax-filter' ),
                        ),
                        'product_attribute' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Product Attributes', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => $productattr,
                            'default'           => 'none',
                            'depends_show_if'   => 'productattr',
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Add the name of the Product Attribute you want to display here', 'divi-filter' ),
                        ),
                        'attribute_swatch' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Show Attributes Swatches', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'options'   => array(
                                'on'    => esc_html__( 'Yes', 'divi-filter' ),
                                'off'   => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'           => 'off',
                            'show_if'      => array(
                                'filter_post_type' => ['productattr', 'productrating']
                            ),
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'If you want to display swatches on the filter, check this option. Filter type will be ignored if this option is on.', 'divi-filter' ),
                        ),
                        'acf_filter_type' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Filter Type', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'select'        => 'Select',
                                'number_range'  => 'Number / Range',
                                'radio'         => 'Checkbox / Radio Buttons'
                            ),
                            'default'           => 'select',
                            'show_if_not'           => array(
                                'filter_post_type' => ['productprice', 'search', 'acf_map']
                            ),

                            'affects'         => array(
                                'default_num',
                            ),
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose how you want the filter to be displayed', 'divi-filter' ),
                        ),
                        'max_price_type'      => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Max Price Setting', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'store'         => 'Max of Store',
                                'category'      => 'Max of current category (Category Page only)',
                                'custom'        => 'Custom'
                            ),
                            'show_if'      => array(
                                'filter_post_type' => ['productprice']
                            ),
                            'default'           => 'store',
                            'option_category'   => 'configuration',
                            'description'       => esc_html__( 'Choose how you want the get max price in price range.', 'divi-filter' ),  
                        ),
                        'value_type'    => array(
                              'toggle_slug'       => 'main_content',
                              'label'             => esc_html__( 'Filter Value Type', 'divi-filter' ),
                              'type'              => 'select',
                              'options'           => array(
                                'string'      => 'String',
                                'numeric'     => 'Numeric',
                                'decimal'      => 'Numeric with decimal',
                              ),
                              'default'           => 'string',
                              'show_if_not'           => array(
                                  'filter_post_type' => ['productprice', 'search', 'acf_map']
                              ),
                              'option_category'   => 'configuration',
                              'description'       => esc_html__( 'If you want to have the filter selections show up above the archive loop so the customer can see and remove them, enable this.', 'divi-filter' ),  
                        ),
                        'filter_params' => array(
                          'toggle_slug'       => 'main_content',
                          'label'             => esc_html__( 'Show Filter Parameters', 'divi-filter' ),
                          'type'              => 'select',
                          'options'           => array(
                            'no'        => 'No',
                            'yes_title'        => 'Yes with title',
                            'yes_no_title'        => 'Yes without title, just the value',
                          ),
                          'default'           => 'no',
                          'option_category'   => 'configuration',
                          'description'       => esc_html__( 'If you want to have the filter selections show up above the archive loop so the customer can see and remove them, enable this.', 'divi-filter' ),
                        ),
                        'exclude_option' => array(
                          'toggle_slug'       => 'main_content',
                          'label'             => esc_html__( 'Exclude Options', 'divi-filter' ),
                          'type'              => 'text',
                          'default'           => '',
                          'option_category'   => 'configuration',
                          'description'       => esc_html__( 'Input option values you want to exclude from filter - comma seperated for multiple values.', 'divi-filter' ),
                        ),
                        'radio_show_count' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Display filter count?', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'on',
                            'depends_show_if'   => 'radio',
                            'description'       => esc_html__( 'Choose if you want to show the filter count for every option.', 'divi-filter' ),
                        ),
                        'radio_show_empty' => array(
                            'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Display empty filter option(Select/Radio/Checkbox Only)?', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'off',
                            'depends_show_if'   => 'radio',
                            'description'       => esc_html__( 'Choose if you want to show empty filter options.', 'divi-filter' ),
                        ),
                        'show_label' => array(
                            'label' => esc_html__( 'Show Label', 'divi-filter' ),
                            'type' => 'yes_no_button',
                            'options_category' => 'configuration',
                            'options' => array(
                                'on' => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'affects' => array(
                                'custom_label'
                            ),
                            'default' => 'on',
                            'description' => esc_html__( 'Enable or disable the label.', 'divi-filter' ),
                            'toggle_slug'       => 'main_content',
                        ),
                        'custom_label' => array(
                          'toggle_slug'       => 'main_content',
                            'label'             => esc_html__( 'Custom label (leave blank for default label)', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'depends_show_if'   => 'on',
                            'description'       => esc_html__( 'Add a custom label here or leave it blank to get the default label.', 'divi-filter' ),
                        ),

                        //////////////////////////////////////////////////
                        /* LAYOUT OPTIONS */
                        //////////////////////////////////////////////////

                        'acf_filter_width' => array(
                          'toggle_slug'       => 'layout',
                          'label'             => esc_html__( 'Filter Width', 'divi-filter' ),
                          'type'              => 'select',
                          'options'           => array(
                              'et_pb_column_4_4'        => 'Full (4/4)',
                              'et_pb_column_3_4'        => 'Three Quarter (3/4)',
                              'et_pb_column_2_3'        => 'Two Thirds (2/3)',
                              'et_pb_column_1_2'        => 'Half (1/2)',
                              'et_pb_column_1_3'        => 'Third (1/3)',
                              'et_pb_column_1_4'        => 'Quarter (1/4)',
                          ),
                          'default'           => 'et_pb_column_4_4',
                          'option_category'   => 'configuration',
                          'description'       => esc_html__( 'Choose the width of the filter', 'divi-filter' ),
                      ),



                        //////////////////////////////////////////////////
                        /* CONDITIONAL LOGIC */
                        //////////////////////////////////////////////////
                        
                        'field_id'                   => array(
                            'label'            => esc_html__( 'Logic ID', 'divi-filter' ),
                            'type'             => 'text',
                            'description'      => esc_html__( 'Define the unique ID of this field. You should use only English characters without special characters and spaces.', 'divi-filter' ),
                            'toggle_slug'      => 'conditional_logic',
                            'default_on_front' => '',
                            'option_category'  => 'layout',
                        ),
                        'field_title' => array(
                            'label'           => esc_html__( 'Logic Title', 'divi-filter' ),
                            'type'            => 'text',
                            'description'     => esc_html__( 'Change the name of the filter for admin purposes ONLY, this is just used so you can see what the filter is.', 'divi-filter' ),
                            'toggle_slug'     => 'conditional_logic',
                            'dynamic_content' => 'text',
                            'option_category' => 'layout',
                        ),
                        'conditional_logic'          => array(
                            'label'           => esc_html__( 'Enable', 'divi-filter' ),
                            'type'            => 'yes_no_button',
                            'option_category' => 'layout',
                            'default'         => 'off',
                            'options'         => array(
                                'on'  => esc_html__( 'Yes' ),
                                'off' => esc_html__( 'No' ),
                            ),
                            'affects'         => array(
                                'conditional_logic_rules',
                                'conditional_logic_relation',
                            ),
                            'description'     => et_get_safe_localization( __( 'Enabling conditional logic makes this field only visible when any or all of the rules below are fulfilled<br><strong>Note:</strong> Only fields with an unique and non-empty field ID can be used', 'divi-filter' ) ),
                            'toggle_slug'     => 'conditional_logic',
                        ),
                        'conditional_logic_relation' => array(
                            'label'           => esc_html__( 'Relation', 'divi-filter' ),
                            'type'            => 'yes_no_button',
                            'option_category' => 'layout',
                            'options'         => array(
                                'on'  => esc_html__( 'All', 'divi-filter' ),
                                'off' => esc_html__( 'Any', 'divi-filter' ),
                            ),
                            'default'         => 'off',
                            'button_options'  => array(
                                'button_type' => 'equal',
                            ),
                            'depends_show_if' => 'on',
                            'description'     => esc_html__( 'Choose whether any or all of the rules should be fulfilled', 'divi-filter' ),
                            'toggle_slug'     => 'conditional_logic',
                        ),
                        'conditional_logic_rules'    => array(
                            'label'           => esc_html__( 'Rules', 'divi-filter' ),
                            'type'            => 'conditional_logic',
                            'option_category' => 'layout',
                            'depends_show_if' => 'on',
                            'toggle_slug'     => 'conditional_logic',
                        ),

                        
                        //////////////////////////////////////////////////
                        /* TEXT FILTER */
                        //////////////////////////////////////////////////


                        'text_placeholder' => array(
                            'toggle_slug'       => 'text_filter',
                            'label'             => esc_html__( 'Placeholder Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'show_if'      => array(
                                'filter_post_type' => ['search', 'acf_map']
                            ),
                            'description'       => esc_html__( 'Add the placeholder for the text input.', 'divi-filter' ),
                        ),
                        'is_number_input' => array(
                            'toggle_slug'       => 'text_filter',
                            'label'             => esc_html__( 'Make text a number input?', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'show_if'      => array(
                                'filter_post_type' => ['search', 'acf_map']
                            ),
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'off',
                            'description'       => esc_html__( 'If you want the text input to be a number input (only numberic) - enable this', 'divi-filter' ),
                        ),

                        //////////////////////////////////////////////////
                        /* SELECT FILTER */
                        //////////////////////////////////////////////////                        

                        'select2' => array(
                          'toggle_slug' => 'select_filter',
                          'label' => esc_html__( 'Enable Select2? (make sure to enable in Filter Module too)', 'divi-filter' ),
                          'type' => 'yes_no_button',
                          'option_category' => 'configuration',
                          'options' => array(
                              'on' => esc_html__( 'Yes', 'divi-filter' ),
                              'off' => esc_html__( 'No', 'divi-filter' ),
                          ),
                          'default' => 'off',
                          'description' => esc_html__( 'If you want this filter to have Select2 - enable this.', 'divi-filter' ),
                      ),

                        'select_placeholder' => array(
                            'toggle_slug'       => 'select_filter',
                            'label'             => esc_html__( 'First Option Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '-- Select Option --',
                            'description'       => esc_html__( 'Choose what the first option of the select option will be.', 'divi-filter' ),
                        ),

                        //////////////////////////////////////////////////
                        /* RADIO FILTER */
                        //////////////////////////////////////////////////

                        'radio_select' => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'Checkbox / Radio Button Functionality', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'radio'       => esc_html__( 'Choose One', 'divi-filter' ),
                                'checkbox'       => esc_html__( 'Multiple Select', 'divi-filter' ),
                            ),
                            'option_category'   => 'configuration',
                            'default'           => 'radio',
                            'affects'           => array(
                                'filter_condition'
                            ),
                            'description'       => esc_html__( 'Choose the style of your radio buttons', 'divi-filter' ),
                        ),
                        'filter_condition' => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'Filter combination option for Multiple selection', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'or'            => esc_html__( 'OR', 'divi-filter' ),
                                'and'           => esc_html__( 'AND', 'divi-filter' ),
                            ),
                            'option_category'   => 'configuration',
                            'default'           => 'or',
                            'depends_show_if'   => 'checkbox',
                            'description'       => esc_html__( 'Filter option for multiselected options.', 'divi-filter' ),
                        ),
                        'radio_style' => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'Checkbox / Radio Style', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'normal'       => esc_html__( 'Normal', 'divi-filter' ),
                                'tick_box'       => esc_html__( 'Tick Boxes', 'divi-filter' ),
                                'buttons'       => esc_html__( 'Buttons', 'divi-filter' ),
                                'select'       => esc_html__( 'Select Drop Down', 'divi-filter' ),
                            ),
                            'option_category'   => 'configuration',
                            'default'           => 'normal',
                            'description'       => esc_html__( 'Choose the style of your radio buttons', 'divi-filter' ),
                        ),
                        'radio_inline' => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'Display Checkbox / Radio Inline?', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'off',
                            'affects'         => array(
                                'radio_gap',
                            ),
                            'description'       => esc_html__( 'Choose if you want the checkboxes to be inline or on their own line', 'divi-filter' ),
                        ),

                      'radio_gap' => array(
                        'toggle_slug'       => 'radio_filter',
                        'label'             => esc_html__( 'Gap Between each item', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category'   => 'configuration',
                        'default'   => '20',
                        'depends_show_if'   => 'on',
                        'description'       => esc_html__( 'Specify the gap you want between each item that is inline.', 'divi-filter' ),
                      ),
                        'radio_all_text' => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'All Label Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => 'All',
                            'description'       => esc_html__( 'Define the text you want to be shown as the "all" checkbox to show all the values.', 'divi-filter' ),
                        ),
                        'hide_radio_all'    => array(
                            'toggle_slug'       => 'radio_filter',
                            'label'             => esc_html__( 'Hide All option', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'            => esc_html__( 'Yes', 'divi-filter'),
                                'off'           => esc_html__( 'No', 'divi-filter'),
                            ),
                            'default'           => 'off',
                            'description'       => esc_html__( 'Define the text you want to be shown as the "all" checkbox to show all the values.', 'divi-filter' ),
                        ),

                        'filter_limit' => array(
                          'option_category' => 'configuration',
                          'toggle_slug'     => 'radio_filter',
                          'label'             => esc_html__( 'Limit Height of Radio/Checkbox filters?', 'divi-machine' ),
                          'type'              => 'yes_no_button',
                          'options'   => array(
                              'on'    => esc_html__( 'Yes', 'divi-machine' ),
                              'off'   => esc_html__( 'No', 'divi-machine' ),
                          ),
                          'default'           => 'off',
                          'description'       => esc_html__( 'If you want to limit the height of the filters with an option to toggle more, enable this.', 'divi-machine' ),
                      ),
                      'filter_limit_height' => array(
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                          'label'           => esc_html__( 'Max Height of the Filter Item', 'divi-filter' ),
                          'type'            => 'range',
                          'default'         => '200',
                          'default_unit'    => 'px',
                          'default_on_front' => '',
                          'show_if' => array(
                              'filter_limit' => 'on'
                              ),
                          'range_settings'  => array(
                              'min'  => '0',
                              'max'  => '1000',
                              'step' => '1',
                          ),
                      ),
                      'filter_limit_show_more_text' => array(
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                          'label'             => esc_html__( 'Show More Text', 'divi-filter' ),
                          'type'              => 'text',
                          'show_if' => array(
                              'filter_limit' => 'on'
                              ),
                          'default'           => 'Show More',
                          'description'       => esc_html__( 'Enter the text you want to appear to toggle more', 'divi-filter' ),
                      ),
                      'filter_limit_show_less_text' => array(
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                          'label'             => esc_html__( 'Show Less Text', 'divi-filter' ),
                          'type'              => 'text',
                          'show_if' => array(
                              'filter_limit' => 'on'
                              ),
                          'default'           => 'Show Less',
                          'description'       => esc_html__( 'Enter the text you want to appear to toggle less', 'divi-filter' ),
                      ),
                      'filter_limit_show_less_icon' => array(
                        'label'               => esc_html__( 'Show More/Less Icon', 'divi-filter' ),
                        'description'         => esc_html__( 'Define the icon that appears after the show more and less text', 'divi-filter' ),
                        'type'                => 'select_icon',
                        'class'               => array( 'et-pb-font-icon' ),
                        'default'           => '%%18%%',
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                        'show_if' => array(
                            'filter_limit' => 'on'
                            ),
                      ),
                      'filter_limit_show_less_icon_size' => array(
                        'label'             => esc_html__( 'Show More/Less Icon Size', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                        'default'   => '15',
                        'show_if' => array(
                            'filter_limit' => 'on'
                            ),
                        'description'       => esc_html__( 'Change the size of the icon.', 'divi-filter' ),
                      ),
                      'filter_limit_show_less_icon_pos_top' => array(
                        'label'             => esc_html__( 'Show More/Less Icon Position Top', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                        'default'   => '0',
                        'show_if' => array(
                            'filter_limit' => 'on'
                            ),
                            'range_settings'  => array(
                              'min'  => '-300',
                              'max'  => '300',
                              'step' => '1',
                            ),
                        'description'       => esc_html__( 'Change the position from the top of the icon.', 'divi-filter' ),
                      ),
                      'filter_limit_show_less_icon_pos_right' => array(
                        'label'             => esc_html__( 'Show More/Less Icon Position Right', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category' => 'configuration',
                        'toggle_slug'     => 'radio_filter',
                        'default'   => '-22px',
                        'show_if' => array(
                            'filter_limit' => 'on'
                            ),
                            'range_settings'  => array(
                              'min'  => '-300',
                              'max'  => '300',
                              'step' => '1',
                            ),
                        'description'       => esc_html__( 'Change the position from the right of the icon.', 'divi-filter' ),
                      ),

                        
                      // 'cat_tag_hide_empty' => array(
                      //   'toggle_slug'       => 'radio_filter',
                      //   'label'             => esc_html__( 'Hide Empty Options?', 'divi-filter' ),
                      //   'type'              => 'yes_no_button',
                      //   'option_category'   => 'configuration',
                      //   'options'           => array(
                      //     'on'  => esc_html__( 'Yes', 'divi-filter' ),
                      //     'off' => esc_html__( 'No', 'divi-filter' ),
                      //   ),
                      //   'default'   => 'off',
                      //   'description'       => esc_html__( 'Enable this to hide the empty values (ones that have no posts assigned to them)', 'divi-filter' ),
                      // ),
                      'only_show_avail' => array(
                        'toggle_slug'       => 'radio_filter',
                        'label'             => esc_html__( 'Only show available Options(archive/category pages only)?', 'divi-filter' ),
                        'type'              => 'yes_no_button',
                        'option_category'   => 'configuration',
                        'options'           => array(
                          'on'  => esc_html__( 'Yes', 'divi-filter' ),
                          'off' => esc_html__( 'No', 'divi-filter' ),
                        ),
                        'default'   => 'off',
                        'description'       => esc_html__( 'If you want to show only the categories, tags or custom taxonomies that are linked to the posts queried on the page - enable this', 'divi-filter' ),
                      ),
                        'radio_button_background_color' => array(
                            'label'             => esc_html__( 'Checkbox / Radio Button Background Color', 'divi-filter' ),
                            'type'              => 'color-alpha',
                            'tab_slug'          => 'advanced',
                            'toggle_slug'       => 'radio_button_style',
                            'description'       => esc_html__( 'This will change the fill color for the checkbox or radio button background.', 'divi-filter' ),
                            'default'           => "#eee"
                        ),
                        'radio_button_background_color_selected' => array(
                            'label'             => esc_html__( 'Checkbox / Radio Button Background Color Selected', 'divi-filter' ),
                            'type'              => 'color-alpha',
                            'tab_slug'          => 'advanced',
                            'toggle_slug'       => 'radio_button_style',
                            'description'       => esc_html__( 'This will change the fill color for the checkbox or radio button background when selected/clicked.', 'divi-filter' ),
                            'default'           => $et_accent_color
                        ),

                        

                        //////////////////////////////////////////////////
                        /* SWATCH FILTER */
                        //////////////////////////////////////////////////


                        'swatch_style' => array(
                          'toggle_slug'       => 'swatch_style_tab',
                          'label'             => esc_html__( 'Swatch Style', 'divi-filter' ),
                          'type'              => 'select',
                          'options'           => array(
                              'circle'        => 'Circle',
                              'square'        => 'Square'
                          ),
                          'default'           => 'circle',
                          'affects'         => array(
                              'default_num',
                          ),
                          'description'       => esc_html__( 'When using a color, image or label swatch - choose the style here.', 'divi-filter' ),
                      ),
                      'swatch_width' => array(
                        'toggle_slug'       => 'swatch_style_tab',
                        'label'             => esc_html__( 'Swatch Width', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category'   => 'configuration',
                        'default'   => '40',
                        'description'       => esc_html__( 'Specify the swatch width.', 'divi-filter' ),
                      ),
                      'swatch_height' => array(
                        'toggle_slug'       => 'swatch_style_tab',
                        'label'             => esc_html__( 'Swatch Height', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category'   => 'configuration',
                        'default'   => '40',
                        'description'       => esc_html__( 'Specify the swatch height.', 'divi-filter' ),
                      ),
                      'swatch_bg_color' => array(
                        'label'             => esc_html__( 'Swatch Background Color', 'divi-filter' ),
                        'type'              => 'color-alpha',
                        'toggle_slug'       => 'swatch_style_tab',
                        'description'       => esc_html__( 'Change the color of the swatch background.', 'divi-filter' ),
                        'default'           => "#ffffff"
                      ),
                      'swatch_border_color' => array(
                        'label'             => esc_html__( 'Swatch Border Color', 'divi-filter' ),
                        'type'              => 'color-alpha',
                        'toggle_slug'       => 'swatch_style_tab',
                        'description'       => esc_html__( 'Change the color of the swatch border.', 'divi-filter' ),
                        'default'           => "#000000"
                      ),
                      'swatch_bg_color_active' => array(
                        'label'             => esc_html__( 'Active Swatch Background Color', 'divi-filter' ),
                        'type'              => 'color-alpha',
                        'toggle_slug'       => 'swatch_style_tab',
                        'description'       => esc_html__( 'Change the color of the swatch background when active.', 'divi-filter' ),
                        'default'           => "#ffffff"
                      ),
                      'swatch_border_color_active' => array(
                        'label'             => esc_html__( 'Active Swatch Border Color', 'divi-filter' ),
                        'type'              => 'color-alpha',
                        'toggle_slug'       => 'swatch_style_tab',
                        'description'       => esc_html__( 'Change the color of the swatch border when active.', 'divi-filter' ),
                        'default'           => "#00b8ff"
                      ),
                      'swatch_border_width' => array(
                        'toggle_slug'       => 'swatch_style_tab',
                        'label'             => esc_html__( 'Swatch Border Width', 'divi-filter' ),
                        'type'              => 'range',
                        'option_category'   => 'configuration',
                        'default'   => '2',
                        'description'       => esc_html__( 'Change the width of the border.', 'divi-filter' ),
                      ),

                        //////////////////////////////////////////////////
                        /* CATEGORIES */
                        //////////////////////////////////////////////////
                      
                      'cat_tag_display_mode' => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Category Display Mode', 'divi-filter' ),
                        'type'              => 'select',
                        'option_category'   => 'configuration',
                        'options'           => array(
                          'only_parents'    => esc_html__( 'Only Parent Categories', 'divi-filter' ),
                          'only_child'      => esc_html__( 'Only Sub Categories of Selected Category', 'divi-filter' ),
                          'category_child'  => esc_html__( 'Sub Categories of Current Category (Category page only)', 'divi-filter' ),
                          'all_cat_sub'     => esc_html__( 'All Categories and Sub categories', 'divi-filter' ),
                        ),
                        'default'   => 'all_cat_sub',
                        'description'       => esc_html__( 'Select option which categories you want to display.', 'divi-filter' ),
                        'depends_show_if'   => 'category',
                        'affects'         => array(
                            'cat_parent_category',
                            'cat_show_only_children',
                            'cat_sub_prefix',
                            'cat_sub_collapsible'
                        ),
                      ),
                      'cat_parent_category' => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Parent Category', 'divi-filter' ),
                        'type'              => 'text',
                        'option_category'   => 'configuration',
                        'default'   => 'all_cat_sub',
                        'description'       => esc_html__( 'Input a parent category slug of the categories that you want to display.', 'divi-filter' ),
                        'depends_show_if'   => 'only_child',
                      ),
                      'cat_show_only_children'  => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Show Sub categories Only?', 'divi-filter'),
                        'type'              => 'yes_no_button',
                        'option_category'   => 'configuration',
                        'options'           => array(
                          'on'  => esc_html__( 'Yes', 'divi-filter' ),
                          'off' => esc_html__( 'No', 'divi-filter' ),
                        ),
                        'default'           => 'off',
                        'show_if'           => array(
                            'cat_tag_display_mode' => ['only_child', 'category_child']
                        ),
                        'description'       => esc_html__( 'Enable this to show only subcategories of selected or current category.', 'divi-filter' ),
                      ),
                      'cat_sub_prefix'      => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Sub Category Prefix', 'divi-filter'),
                        'type'              => 'text',
                        'option_category'   => 'configuration',
                        'default'           => '--',
                        'show_if_not'       => array(
                            'cat_tag_display_mode' => ['only_parents', 'conditional']
                        ),
                        'description'       => esc_html__( 'Enable this to show only subcategories of selected or current category.', 'divi-filter' ),
                      ),
                      'cat_sub_collapsible'      => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Collapsible Sub Categories?', 'divi-filter'),
                        'type'              => 'yes_no_button',
                        'option_category'   => 'configuration',
                        'options'           => array(
                          'on'  => esc_html__( 'Yes', 'divi-filter' ),
                          'off' => esc_html__( 'No', 'divi-filter' ),
                        ),
                        'default'           => 'off',
                        'show_if_not'       => array(
                            'cat_tag_display_mode' => ['only_parents', 'conditional']
                        ),
                        'description'       => esc_html__( 'Enable this if you want to have the sub-categories expand and collapse when clicking.', 'divi-filter' ),
                      ),
                      'cat_sub_collapsible_prevent'      => array(
                        'toggle_slug'       => 'tags_filter',
                        'label'             => esc_html__( 'Disable Filter on Parent?', 'divi-filter'),
                        'type'              => 'yes_no_button',
                        'option_category'   => 'configuration',
                        'options'           => array(
                          'on'  => esc_html__( 'Yes', 'divi-filter' ),
                          'off' => esc_html__( 'No', 'divi-filter' ),
                        ),
                        'default'           => 'on',
                        'show_if_not'       => array(
                            'cat_sub_collapsible' => ['off']
                        ),
                        'description'       => esc_html__( 'Enable this if you want to disable the filter of the posts when clicking on the parent, this will expand the list without filtering.', 'divi-filter' ),
                      ),
                      'cat_sub_collapsible_toggle_icon_color' => array(
                          'label'             => esc_html__( 'Toggle Color', 'divi-filter' ),
                          'type'              => 'color-alpha',
                          'option_category'   => 'configuration',
                          'toggle_slug'       => 'tags_filter',
                          'description'       => esc_html__( 'This will change the fill color of the chevron icon to toggle the sub-categories.', 'divi-filter' ),
                          'default'           => "#666"
                      ),
                   

                        //////////////////////////////////////////////////
                        /* RANGE FILTER */
                        //////////////////////////////////////////////////

                        'range_from' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Range From Number', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '100',
                            'depends_show_if'   => 'double',
                            'description'       => esc_html__( 'Choose the default from number.', 'divi-filter' ),
                        ),
                        'range_to' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Range To Number', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '800',
                            'depends_show_if'   => 'double',
                            'description'       => esc_html__( 'Choose the default to number.', 'divi-filter' ),
                        ),
                        'range_step' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range Step', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '1',
                            'description'       => esc_html__( 'Choose the number it steps up.', 'divi-filter' ),
                        ),
                        'range_skin' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range Appearance Style', 'divi-filter' ),
                            'type'              => 'select',
                            'options'           => array(
                                'flat'       => esc_html__( 'Flat', 'divi-filter' ),
                                'big'       => esc_html__( 'Big', 'divi-filter' ),
                                'modern'       => esc_html__( 'Modern', 'divi-filter' ),
                                'sharp'       => esc_html__( 'Sharp', 'divi-filter' ),
                                'round'       => esc_html__( 'Round', 'divi-filter' ),
                                'square'       => esc_html__( 'Square', 'divi-filter' ),
                            ),
                            'option_category'   => 'configuration',
                            'default'           => 'flat',
                            'description'       => esc_html__( 'Choose the appearance style of the slider', 'divi-filter' ),
                        ),
                        'range_prim_color' => array(
                            'label'             => esc_html__( 'Range Primary Color', 'divi-bodyshop-woocommerce' ),
                            'type'              => 'color-alpha',
                            'custom_color'      => true,
                            'default' => et_get_option( 'accent_color', '#2ea3f2' ),
                            'toggle_slug'       => 'range_filter',
                            'option_category'   => 'configuration',
                        ),
                        'range_sec_color' => array(
                            'label'             => esc_html__( 'Range Secondary Color', 'divi-bodyshop-woocommerce' ),
                            'type'              => 'color-alpha',
                            'custom_color'      => true,
                            'default' => '#efefef',
                            'toggle_slug'       => 'range_filter',
                            'option_category'   => 'configuration',
                        ),
                        'range_hide_min_max' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Range Hide Min and Max Labels', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'off',
                            'depends_show_if'   => 'number_range'
                        ),
                        'range_hide_from_to' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Range Hide From and To Labels', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'off',
                            'depends_show_if'   => 'number_range'
                        ),
                        'range_prettify_enabled' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range Prettify', 'divi-filter' ),
                            'type'              => 'yes_no_button',
                            'option_category'   => 'configuration',
                            'options'           => array(
                                'on'  => esc_html__( 'Yes', 'divi-filter' ),
                                'off' => esc_html__( 'No', 'divi-filter' ),
                            ),
                            'default'   => 'on',
                            'description'       => esc_html__( 'Enable this if you want to pretify your text, improve readibility of long numbers. 10000000 → 10 000 000', 'divi-filter' ),
                        ),
                        'range_prettify_separator' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range Prettify Separator', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => ' ',
                            'description'       => esc_html__( 'Set up your own separator for long numbers. 10 000, 10.000, 10-000 etc.', 'divi-filter' ),
                        ),
                        'range_prefix' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range Before Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '',
                            'description'       => esc_html__( 'Set the text for values. Will be set up right before the number: $100', 'divi-filter' ),
                        ),
                        'range_postfix' => array(
                            'toggle_slug'       => 'range_filter',
                            'label'             => esc_html__( 'Number / Range After Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => '',
                            'description'       => esc_html__( 'Set the text for values. Will be set up right after the number: 100k', 'divi-filter' ),
                        ),
                        'true_text' => array(
                            'toggle_slug'       => 'true_false_filter',
                            'label'             => esc_html__( 'True Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => 'Yes',
                            'description'       => esc_html__( 'Set the text you want to appear when it is "true"', 'divi-filter' ),
                        ),
                        'false_text' => array(
                            'toggle_slug'       => 'true_false_filter',
                            'label'             => esc_html__( 'False Text', 'divi-filter' ),
                            'type'              => 'text',
                            'option_category'   => 'configuration',
                            'default'   => 'No',
                            'description'       => esc_html__( 'Set the text you want to appear when it is "false"', 'divi-filter' ),
                        ),

                        
                        
                    );

                    return $fields;
                }

                  function render( $attrs, $content = null, $render_slug ) {
    if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
      return;
    }

                    if (is_admin()) {
                      return;
                    }

                    $post_type_choose   = $this->props['post_type_choose'];
                    $filter_post_type   = $this->props['filter_post_type'];
                    $custom_tax_choose   = $this->props['custom_tax_choose'];

                    $acf_name           = $this->props['acf_name'];
                    $acf_map_name       = !empty($this->props['acf_map_name'])?$this->props['acf_map_name']:'';
                    $acf_map_radius_unit= !empty($this->props['acf_map_radius_unit'])?$this->props['acf_map_radius_unit']:'';
                    $acf_filter_type    = $this->props['acf_filter_type'];
                    $acf_filter_width   = $this->props['acf_filter_width'];
                    $attribute_swatch   = $this->props['attribute_swatch'];
                    $show_label         = $this->props['show_label'];
                    $text_placeholder   = $this->props['text_placeholder'];
                    $is_number_input   = $this->props['is_number_input'];
                    $max_price_type     = $this->props['max_price_type'];
                    
                    $select_placeholder = $this->props['select_placeholder'];
                    $exclude_option     = $this->props['exclude_option'];
                    $value_type         = $this->props['value_type'];

                    $product_attribute  = $this->props['product_attribute'];

                    // $default_num                         = $this->props['default_num'];
                    $radio_style        = $this->props['radio_style'];
                    $radio_select       = $this->props['radio_select'];
                    $radio_all_text     = $this->props['radio_all_text'];
                    $radio_all_hide     = $this->props['hide_radio_all'];

                    // $checkbox_color                         = $this->props['checkbox_color'];
                    $range_prim_color                               = $this->props['range_prim_color'];
                    $range_sec_color                                = $this->props['range_sec_color'];
                    $radio_button_background_color                  = $this->props['radio_button_background_color'];
                    $radio_button_background_color_selected         = $this->props['radio_button_background_color_selected'];

                    // $range_type                         = $this->props['range_type'];
                    $range_from                 = $this->props['range_from'];
                    $range_to                   = $this->props['range_to'];
                    $range_step                 = $this->props['range_step'];
                    $range_skin                 = $this->props['range_skin'];
                    $range_hide_min_max         = $this->props['range_hide_min_max'];
                    $range_hide_from_to         = $this->props['range_hide_from_to'];
                    $range_prettify_enabled     = $this->props['range_prettify_enabled'];
                    $range_prettify_separator   = $this->props['range_prettify_separator'];
                    $range_prefix               = $this->props['range_prefix'];
                    $range_postfix              = $this->props['range_postfix'];

                    $select_options             = !empty($this->props['select_options'])?$this->props['select_options']:'';
                    $select2   = $this->props['select2'];
                    $custom_label               = $this->props['custom_label'];
                    // $tags_style                 = $this->props['tags_style'];
                    $radio_inline               = $this->props['radio_inline'];
                    $radio_gap               = $this->props['radio_gap'];
                    $radio_show_count           = $this->props['radio_show_count'];
                    $radio_show_empty           = $this->props['radio_show_empty'];


                    $swatch_style               = $this->props['swatch_style'];
                    $swatch_width               = $this->props['swatch_width'];
                    $swatch_height              = $this->props['swatch_height'];
                    $swatch_bg_color            = $this->props['swatch_bg_color'];
                    $swatch_border_color        = $this->props['swatch_border_color'];
                    $swatch_bg_color_active     = $this->props['swatch_bg_color_active'];
                    $swatch_border_color_active = $this->props['swatch_border_color_active'];
                    $swatch_border_width        = $this->props['swatch_border_width'];
                    $field_title                = $this->props['field_title'];
                    $field_id                   = $this->props['field_id'];
                    $conditional_logic          = $this->props['conditional_logic'];
                    $conditional_logic_relation = $this->props['conditional_logic_relation'];
                    $conditional_logic_rules    = $this->props['conditional_logic_rules'];

                    $hide_title        = !empty($this->props['hide_title'])?$this->props['hide_title']:'';

                    $cat_tag_display_mode       = $this->props['cat_tag_display_mode'];
                    $cat_parent_category        = $this->props['cat_parent_category'];
                    $cat_show_only_children     = $this->props['cat_show_only_children'];
                    $cat_sub_prefix             = $this->props['cat_sub_prefix'];
                    $cat_sub_collapsible        = $this->props['cat_sub_collapsible'];
                    $cat_sub_collapsible_prevent        = $this->props['cat_sub_collapsible_prevent'];                    
                    $cat_sub_collapsible_toggle_icon_color                                = $this->props['cat_sub_collapsible_toggle_icon_color'];
                    
                    

                    $only_show_avail           = $this->props['only_show_avail'];

                    $filter_limit        =  $this->props['filter_limit'];
                    $filter_limit_height        =  $this->props['filter_limit_height'];
                    $filter_limit_show_more_text        =  $this->props['filter_limit_show_more_text'];
                    $filter_limit_show_less_text        =  $this->props['filter_limit_show_less_text'];
                    
                    $filter_limit_show_less_icon        =  $this->props['filter_limit_show_less_icon'];
                    $filter_limit_show_less_icon_size        =  $this->props['filter_limit_show_less_icon_size'];
                    $filter_limit_show_less_icon_pos_right        =  $this->props['filter_limit_show_less_icon_pos_right'];
                    $filter_limit_show_less_icon_pos_top        =  $this->props['filter_limit_show_less_icon_pos_top'];
                    $filter_condition                           =  $this->props['filter_condition'];

                    $text_typing_timeout                           =  $this->props['text_typing_timeout'];
                    
                    if ($radio_show_count  == "on") {
                      $this->add_classname( 'radio_show_count');
                    }

                    $button_use_icon          	= $this->props['button_use_icon'];
                    $custom_icon          		= $this->props['button_icon'];
                    $button_custom        		= $this->props['custom_button'];
                    $button_bg_color       		= $this->props['button_bg_color'];
		                $button_icon_placement 		= $this->props['button_icon_placement'];

                    $custom_active_button  			= $this->props['custom_active_button'];
                  $custom_icon_active_button         		= $this->props['active_button_icon'];
                  $button_bg_color_active_button       		= $this->props['active_button_bg_color'];
                  $button_use_icon_active_button  			= $this->props['active_button_use_icon'];
                  $button_icon_active_button 				= $this->props['active_button_icon'];
                  $button_icon_placement_active_button 		= $this->props['active_button_icon_placement'];


                  $true_text 		= $this->props['true_text'];
                  $false_text 		= $this->props['false_text'];
                  


                  if( $custom_icon != '' ){

                    $IconSelector = '';
                            if( $button_icon_placement == 'right' ){
                              $IconSelector = '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input+ label:after';
                            }elseif( $button_icon_placement == 'left' ){
                              $IconSelector = '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input+ label:before';
                            }
  
                            if( !empty( $IconContent ) && !empty( $IconSelector ) ){
            ET_Builder_Element::set_style( $render_slug, array(
              'selector' => $IconSelector,
              'declaration' => "content: '{$IconContent}'!important;font-family:ETmodules!important;"
              )
            );
          }
  
                  }

                  if( $custom_active_button == 'on' ){

                    // button icon
                    if( $button_icon_active_button !== '' ){

                        if ( class_exists( 'DE_Filter' ) ) {
                            $addToCartIconContent = DE_Filter::et_icon_css_content( esc_attr($button_icon_active_button) );
                        } else if ( class_exists( 'DEBC_INIT' ) ) {
                      $addToCartIconContent = DEBC_INIT::et_icon_css_content( esc_attr($button_icon_active_button) );
                        } else if ( class_exists( 'DEDMACH_INIT' ) ) {
                            $addToCartIconContent = DEDMACH_INIT::et_icon_css_content( esc_attr($button_icon_active_button) );
                        }
                      

                      $addToCartIconSelector = '';
                      if( $button_icon_placement_active_button == 'right' ){
                        $addToCartIconSelector = '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input:checked + label:after';
                      }elseif( $button_icon_placement_active_button == 'left' ){
                        $addToCartIconSelector = '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input:checked + label:before';
                      }

                      if( !empty( $addToCartIconContent ) && !empty( $addToCartIconSelector ) ){
                        ET_Builder_Element::set_style( $render_slug, array(
                          'selector' => $addToCartIconSelector,
                          'declaration' => "
                          content: '{$addToCartIconContent}'!important;
                          font-family:ETmodules!important;
                          display: inline-block;
                          line-height: inherit;
                          font-size: inherit!important;
                          margin-left: .3em;
                          left: auto;
                          display: inline-block;
                          "
                          )
                        );
                      }
                    }

                    // button background
                    if( !empty( $button_bg_color_active_button ) ){
                      ET_Builder_Element::set_style( $render_slug, array(
                        'selector'    => 'body #page-container %%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input:checked + label',
                        'declaration' => "background-color:". esc_attr( $button_bg_color_active_button ) ."!important;",
                      ) );
                    }
                  }

                    if ($filter_limit == "on" && $filter_limit_show_less_icon != "") {

                      $filter_limit_show_less_icon_rendered = DE_Filter::et_icon_css_content( esc_attr($filter_limit_show_less_icon) );
 ET_Builder_Element::set_style( $render_slug, array(
      'selector'    => '%%order_class%% .limit_filter_text:after',
      'declaration' => sprintf(
        'content: "%1$s";
        font-size: %2$spx;
        top: %3$spx;
        right: %4$spx;',
        esc_html( $filter_limit_show_less_icon_rendered ),
        $filter_limit_show_less_icon_size,
        $filter_limit_show_less_icon_pos_top,
        $filter_limit_show_less_icon_pos_right
      ),
    ) );
                    }

                    if ( $attribute_swatch == "on" ) {
                        if ( $swatch_style == "square" ) {
                            ET_Builder_Element::set_style( $render_slug, array(
                                'selector'    => '%%order_class%% .divi-swatch .et_pb_contact_field_radio label:not([data-value=all])',
                                'declaration' => "border-radius:0;"
                            ) );

                            ET_Builder_Element::set_style( $render_slug, array(
                                'selector'    => '%%order_class%% .divi-swatch .et_pb_contact_field_radio label:not([data-value=all]) i',
                                'declaration' => "border-radius:0;"
                            ) );
                        }
                    }


                    if ($radio_show_empty == "off") {
                      $cat_tag_hide_empty_dis = true;
                    } else {
                      $cat_tag_hide_empty_dis = false;
                    }

                    if ( $acf_filter_type == "number_range" || ($filter_post_type == "productprice") || ($filter_post_type == "productweight") ) {
                        wp_enqueue_script( 'divi-filter-rangeSlider-js');
                        wp_enqueue_style( 'divi-filter-rangeSlider-css');
                    }

                    // SWATCH STYLE
                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch .et_pb_contact_field_radio label:not([data-value="all"])',
                      'declaration' => "
                      width: {$swatch_width}px;
                      height: {$swatch_height}px;
                      background-color: {$swatch_bg_color};
                      border-color: {$swatch_border_color};
                      border-width: {$swatch_border_width}px;
                      "
                      )
                    );
                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch-full .et_pb_contact_field_radio label:not([data-value="all"])',
                      'declaration' => "
                      width: 100%!important;
                      height: auto!important;
                      border:none!important;
                      background:none!important;
                      "
                      )
                    );
                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch-full .et_pb_contact_field_radio label:not([data-value="all"]) .star-rating',
                      'declaration' => "
                      float: left;
                      "
                      )
                    );
                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch .et_pb_contact_field_radio input:checked ~ label',
                      'declaration' => "
                      background-color: {$swatch_bg_color_active};
                      border-color: {$swatch_border_color_active};
                      "
                      )
                    );

                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch-full .et_pb_contact_field_radio input:checked ~ label',
                      'declaration' => "
                      background-color: none;
                      "
                      )
                    );

                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch .et_pb_contact_field_radio label .star-rating span:before',
                      'declaration' => "
                      color: {$swatch_bg_color};
                      "
                      )
                    );

                    ET_Builder_Element::set_style( $render_slug, array(
                      'selector' => '%%order_class%% .divi-swatch .et_pb_contact_field_radio input:checked ~ label .star-rating span:before',
                      'declaration' => "
                      color: {$swatch_bg_color_active};
                      "
                      )
                    );
                    // END SWATCH STYLE

                    $filter_params           = $this->props['filter_params'];
                    if ($filter_params !== "no") {
                      $this->add_classname( 'filter_params_' . $filter_params);
                      $this->add_classname( 'filter_params');
                    } else {
                      $this->add_classname( 'no_filter_params');
                    }

                    if ($hide_title == "on") {
                      $this->add_classname( 'hide_title');
                    }

                    if ($radio_inline == "on") {
                      $this->add_classname( 'inline_checkboxes');
                      self::set_style( $render_slug,
                        array(
                          'selector'    => '%%order_class%%.inline_checkboxes .divi-filter-item>*',
                          'declaration' => sprintf( 'margin-right: %1$spx;', esc_attr( $radio_gap ))
                        )
                      );
                      self::set_style( $render_slug,
                        array(
                          'selector'    => '%%order_class%%.inline_checkboxes .divi-filter-item>*:nth-last-child(1)',
                          'declaration' => 'margin-right: 0 !important;',
                        )
                      );
                    }

                    $exclude_option_array = ($exclude_option != '')?explode(',', $exclude_option):array();

                    $num = mt_rand(100000,999999);
                    $css_class = $render_slug . "_" . $num;

                    if ($range_hide_min_max == "off") {$range_hide_min_max = "false";} else {$range_hide_min_max = "true";};
                    if ($range_hide_from_to == "off") {$range_hide_from_to = "false";} else {$range_hide_from_to = "true";};
                    if ($range_prettify_enabled == "off") {$range_prettify_enabled = "false";} else {$range_prettify_enabled = "true";};

                    $this->add_classname(
                      array(
                        $acf_filter_width,
                        'et_pb_column',
                      )
                    );

                    if ( ! empty( $radio_button_background_color ) ) {
                      self::set_style( $render_slug,
                      array(
                        'selector'    => '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio label, %%order_class%% .divi-radio-tick_box .checkmark',
                        'declaration' => sprintf( 'background-color: %1$s;', esc_attr( $radio_button_background_color ) ),
                      )
                    );
                  }

                  // TODO: add color for simple radiio
                  if ( ! empty( $radio_button_background_color_selected ) ) {
                    self::set_style( $render_slug,
                    array(
                      'selector'    => '%%order_class%% .divi-radio-buttons .et_pb_contact_field_radio input:checked+label, %%order_class%% .divi-radio-tick_box input:checked ~ .checkmark',
                      'declaration' => sprintf( 'background-color: %1$s!important;', esc_attr( $radio_button_background_color_selected ) ),
                    )
                  );
                }


                if ($show_label == "off") {
                  $label_css = "divi-hide";
                } else {
                  $label_css = "";
                }

                if ($acf_filter_width == "et_pb_column_4_4") {
                  $acf_filter_width_num = "100";
                } else if ($acf_filter_width == "et_pb_column_3_4") {
                  $acf_filter_width_num = "75";
                } else if ($acf_filter_width == "et_pb_column_2_3") {
                  $acf_filter_width_num = "60";
                } else if ($acf_filter_width == "et_pb_column_1_2") {
                  $acf_filter_width_num = "50";
                } else if ($acf_filter_width == "et_pb_column_1_3") {
                  $acf_filter_width_num = "40";
                } else if ($acf_filter_width == "et_pb_column_1_4") {
                  $acf_filter_width_num = "25";
                } else {

                }

                //////////////////////////////////////////////////////////////////////

                $conditional_logic_attr = '';
                $conditional_display = '';

                if ( 'on' === $conditional_logic && ! empty( $conditional_logic_rules ) ) {
                    $option_search           = array( '&#91;', '&#93;' );
                    $option_replace          = array( '[', ']' );
                    $conditional_logic_rules = str_replace( $option_search, $option_replace, $conditional_logic_rules );
                    $condition_rows          = json_decode( $conditional_logic_rules );
                    $ruleset                 = array();

                    foreach ( $condition_rows as $condition_row ) {
                        $condition_value = isset( $condition_row->value ) ? $condition_row->value : '';
                        $condition_value = trim( $condition_value );

                        $ruleset[] = array(
                            $condition_row->field,
                            $condition_row->condition,
                            $condition_value,
                        );
                    }

                    if ( ! empty( $ruleset ) ) {
                        $json     = json_encode( $ruleset );
                        $relation = $conditional_logic_relation === 'off' ? 'any' : 'all';

                        $conditional_logic_attr = sprintf(
                            ' data-conditional-logic="%1$s" data-conditional-relation="%2$s"',
                            esc_attr( $json ),
                            $relation
                        );

                        ET_Builder_Element::set_style( $render_slug, array(
                          'selector' => '%%order_class%%',
                          'declaration' => "
                          display:none;
                          "
                          )
                        );

                        $conditional_display = '';
                    }
                }

                ob_start();

                global $wp_query;
                $field_id = strtolower($field_id);
                
                $data_attribs = '';

                if ( $filter_post_type == 'category' ) {
                    $data_attribs = ' data-child-mode="'.$cat_show_only_children.'" data-hide-empty="'.$cat_tag_hide_empty_dis.'" data-sub-prefix="' . $cat_sub_prefix.'" data-show-available="'.$only_show_avail.'" data-field-type="' . $acf_filter_type . '"';
                    if ( $acf_filter_type == 'select') {
                        $data_attribs .= ' data-select-placeholder="'.$select_placeholder.'"';
                    }else{
                        $data_attribs .= ' data-radio-select="'.$radio_select.'" data-radio-all-hide="'.$radio_all_hide.'" data-radio-style="'.$radio_style.'" data-radio-all-text="'.$radio_all_text.'"';
                    }
                }

                if ( $radio_select == 'checkbox' && $filter_condition == 'and' ) {
                    $filter_condition = 'and';
                } else {
                    $filter_condition = 'or';
                }
?>
                <div class="search_filter_cont <?php echo $css_class ?>" id="<?php echo $field_id;?>" data-count="<?php echo $acf_filter_width_num ?>" <?php echo $conditional_logic_attr;?> data-value-type="<?php echo $value_type;?>" data-type="<?php echo $filter_post_type;?>" data-post-type="<?php echo $post_type_choose;?>" <?php echo $data_attribs . $conditional_display;?> data-filter-condition="<?php echo $filter_condition;?>">
                <?php
                
                if ($filter_limit == "on") {
                  $filter_limit_height = $filter_limit_height;
                } else {
                  $filter_limit_height = "";
                }

               // if show available is true


                  // 1) First we get the term query
                  // if ($filter_post_type == "category") {
                  //   if ( $post_type_choose == 'product' ){ // if products
                  //     $term_query = new WP_Term_Query( array( 'taxonomy' => 'product_cat' ) );
                  //   } else if ($post_type_choose == 'post') { // else if posts
                  //     $term_query = new WP_Term_Query( array( 'taxonomy' => 'category' ) );
                  //   }else { // else everything else
                  //     $ending = "_category";
                  //     $cat_key = $post_type_choose . $ending;
                  //     $term_query = new WP_Term_Query( array( 'taxonomy' => $cat_key ) );
                  //   }
                  // } else if ($filter_post_type == "tags") {
                  //   $ending = "_tag";
                  //   $cat_key = $post_type_choose . $ending;
                  //   $term_query = new WP_Term_Query( array( 'taxonomy' => $cat_key ) );
                  // } else if ( $filter_post_type == "taxonomy" ) {
                  //   $term_query = new WP_Term_Query( array( 'taxonomy' => $custom_tax_choose ) );
                  // }


                if ( $filter_post_type == "category" ) {

                  // GET AVAILABLE CATEGORIES
                  // 1) First we get the term query
                  if ($only_show_avail == "on") {
                    global $wp_query;
                    $current_query_var = $wp_query->query_vars;
                    unset( $current_query_var['paged']);
                    $current_query_var['posts_per_page'] = 999999;
                    $the_query = new WP_Query( $current_query_var );
                    $ID_array = $the_query->posts;
                    $avail_terms = '';
                    foreach($ID_array as $item) { // Then for each ID - we then look for the category
                      if ($post_type_choose == 'post') {
                        $terms_post = get_the_category( $item->ID );
                      } else if ( $post_type_choose == 'product' ) {
                        $terms_post = get_the_terms( $item->ID , 'product_cat' );
                      } else {
                        $cat_key = $post_type_choose . '_category';
                        if ( !empty( $cpt_taxonomies ) && in_array( 'category', $cpt_taxonomies ) ){
                          $terms_post = get_the_category( $item->ID );
                        } else {
                          $terms_post = get_the_terms( $item->ID , $cat_key );
                        }
                      }
                      // 3) for each category we then add the ID to a string
                      if (is_array($terms_post)) {
                        foreach ($terms_post as $term_cat) {
                          $term_cat_id = $term_cat->term_id;
                          $avail_terms .= $term_cat_id.",";
                        }
                      }
                    }
                    $avail_terms = implode(',',array_unique(explode(',', $avail_terms)));
                    if ( $avail_terms == '' ){
                      $avail_terms = array(-1);
                      $this->add_classname( 'divi-hide');
                      $this->add_classname( 'no-avail-terms');
                    }
                  } else {
                    $avail_terms = '';
                  }
                  // GET AVAILABLE CATEGORIES


                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = 'Categories';
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Category Filter Label', $custom_label_final );

                    $cat_args = array(
                        'hide_empty' => $cat_tag_hide_empty_dis,
                        'include'   => $avail_terms,
                    );

                    if ($post_type_choose == 'post') {
                        $cat_key = 'category';
                    } else if ( $post_type_choose == 'product' ) {
                        $cat_key = 'product_cat';
                    } else {
                        $cpt_taxonomies = get_object_taxonomies( $post_type_choose );

                        if ( !empty( $cpt_taxonomies ) && in_array( 'category', $cpt_taxonomies ) ){
                            $cat_key = 'category';
                        }else{
                            $ending = "_category";
                            $cat_key = $post_type_choose . $ending;
                        }
                    }

                    $cat_args['taxonomy'] = $cat_key;

                    $cat_parent_data = '';

                    switch ( $cat_tag_display_mode ) {
                        case 'only_parents':
                            $cat_args['parent'] = 0;
                            $get_categories = get_terms( $cat_args );
                            break;
                        case 'only_child':
                            $parent_term = get_term_by( 'slug', $cat_parent_category, $cat_key );
                            $cat_parent_data = ' data-parent-cat="'.$cat_parent_category.'"';
                            if ( $parent_term ){
                                $term_id = $parent_term->term_id;
                                $cat_args['parent'] = $term_id;    
                            }else{
                                $cat_args['parent'] = 0;
                            }

                            if ( $cat_show_only_children == 'on' ) {
                                $get_categories = get_terms( $cat_args );
                            } else {
                                $this->listTaxonomies( $cat_args, $get_categories );
                            }
                            break;
                        case 'category_child':
                            if ( is_tax( $cat_key ) ) {
                                $current_cat = get_query_var( $cat_key );
                                $current_cat_obj = get_term_by( 'slug', $current_cat, $cat_key );
                                if ( isset( $current_cat ) ) {
                                    $cat_args['parent'] = $current_cat_obj->term_id;
                                    if ( $cat_show_only_children == 'on' ) {
                                        $get_categories = get_terms( $cat_args );
                                    } else {
                                        $this->listTaxonomies( $cat_args, $get_categories );
                                    }       
                                }
                            }else {
                                $cat_args['parent'] = 0;
                                $this->listTaxonomies( $cat_args, $get_categories );
                            }
                            break;
                        case 'all_cat_sub':
                        default:
                            $cat_args['parent'] = 0;
                            $this->listTaxonomies( $cat_args, $get_categories );
                            break;
                    }

                    $queryvar = !empty($_GET[$cat_key])?$_GET[$cat_key]:(get_query_var( $cat_key )?get_query_var( $cat_key):'' );
                    $get_categories = ( !empty( $get_categories) && is_array( $get_categories) )?array_values( $get_categories ):$get_categories;
                    $first_parent_id = ( !empty( $get_categories) && is_array( $get_categories) )?$get_categories[0]->parent:0;
                    $cat_depth = array( $first_parent_id => 0 );

                    if ($acf_filter_type == "select") {

                        $selected_cats = preg_split('/(,|\|)/', $queryvar);
?>
                      <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-ajax-filter' ); ?></p>
                      <p class="et_pb_contact_field divi-filter-item" data-type="select" data-filtertype="select" name="categories" data-field_type="select" data-filter-option="<?php echo $cat_key;?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $cat_key;?>">
                        <select id="<?php echo $cat_key . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-filtertype="customcategory" data-field_type="select" name="<?php echo $cat_key . '_' . $num ?>" data-name="<?php echo $cat_key;?>">
                          <option value="" <?php echo in_array('', $selected_cats)?'selected':''; ?>><?php echo $select_placeholder ?></option>
                          <?php
                          if ( $get_categories ) :
                            foreach ( $get_categories as $cat ) :
                                if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                    continue;
                                }
                                $child_cats = get_terms(array( 'hide_empty' => true, 'parent' => $cat->term_id, 'taxonomy' => $cat_key ) );
                                $data_parent = '';
                                if ( !empty( $child_cats) && sizeof( $child_cats ) > 0 ) {
                                    $data_parent = ' data-type="has-child"';
                                }
                                $parent_cat_id = $cat->parent;
                                $prefix = '';
                                if ( isset( $cat_depth[$parent_cat_id] ) ) {
                                    $prefix = str_repeat( $cat_sub_prefix, $cat_depth[ $parent_cat_id ] );
                                    $cat_depth[ $cat->term_id ] = $cat_depth[$parent_cat_id] + 1;
                                }
                              ?>
                              <option id="<?php echo $cat->term_id . '_' . $num; ?>" <?php echo $data_parent;?> value="<?php echo $cat->slug; ?>" <?php echo in_array($cat->slug, $selected_cats)?'selected':'';?>><?php echo $prefix . $cat->name; ?></option>
                              <?php
                            endforeach;
                          endif;
                          ?>
                        </select>
                      </p>
                      <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $cat_key . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }

                    } else {

                        $empty_class = '';
                        if ( $radio_show_empty == 'on' ){
                            $empty_class = 'show-empty';
                        }

                        if ($radio_select == "checkbox") {
                            $checkboxtype = "divi-checkboxmulti";
                        } else {
                            $checkboxtype = "divi-checkboxsingle";
                        }
                        $queryvar = preg_split('/(,|\|)/', $queryvar);
?>
                      <div class="et_pb_contact_field" data-type="radio" data-filtertype="radio">
                        <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                          <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                              <!-- <form> -->
                          <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype. ' ' . $empty_class; ?> limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $cat_key;?>" data-filter-name="<?php echo $cat_key;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>" <?php echo $cat_parent_data;?>>
                            <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on') && $only_show_avail == "off" ) { ?>
                            <span class="et_pb_contact_field_radio">
                              <input type="<?php echo $radio_select ?>" id="<?php echo $cat_key; ?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" name="<?php echo $cat_key . '_' . $num;?>" data-name="<?php echo $cat_key;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo (sizeof($queryvar) == 1 && $queryvar[0] =='' )?'checked="checked"':'';?>>
                              <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; }?>
                              <label class="radio-label" data-value="all<?php echo ($cat_tag_display_mode=='only_child')?'_'.$cat_parent_category:'';?>" for="<?php echo $cat_key; ?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                            </span>
                            <?php } ?>
                            <?php
                            if ( $get_categories ) :
                              $cat_inx = 0;
                              foreach ( $get_categories as $cat ) :
                                if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                    continue;
                                }
                                $parent_cat_id = $cat->parent;
                                $cat_id = $cat->term_id;
                                $prefix = '';
                                $child_cats = get_terms(array( 'hide_empty' => true, 'parent' => $cat->term_id, 'taxonomy' => $cat_key ) );
                                $data_parent = '';
                                if ( !empty( $child_cats) && sizeof( $child_cats ) > 0 ) {
                                    $data_parent = ' data-type="has-child"';
                                }
                                $collapsible_class = '';
                                if ( $cat_sub_collapsible == 'on' && ( $cat_inx < sizeof($get_categories) - 1 ) && $cat->term_id == $get_categories[$cat_inx + 1]->parent ) { 
                                  $this->add_classname( 'sub_cat_collapsible');
                                    $collapsible_class = 'is-collapsible';

                                    ET_Builder_Element::set_style( $render_slug, array(
                                      'selector' => '%%order_class%% .et_pb_contact_field_radio.is-collapsible::after',
                                      'declaration' => "
                                      color: {$cat_sub_collapsible_toggle_icon_color};
                                      "
                                      )
                                    );

                                }
                                $cat_inx++;
                                if ( isset( $cat_depth[$parent_cat_id] ) ) {
                                    $prefix = str_repeat( $cat_sub_prefix, $cat_depth[ $parent_cat_id ] );
                                    $cat_depth[ $cat->term_id ] = $cat_depth[$parent_cat_id] + 1;
                                }
                                ?>
                                <span class="et_pb_contact_field_radio <?php echo $collapsible_class;?>" data_prevent_collapse="<?php echo $cat_sub_collapsible_prevent?>" data_parent_cat_id="<?php echo $parent_cat_id?>" data_cat_id="<?php echo $cat_id ?>">
                                  <input type="<?php echo $radio_select ?>" <?php echo $data_parent;?>  id="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num; ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $cat->slug ?>" data-name="<?php echo $cat_key;?>" name="<?php echo $cat_key . '_' . $num;?>" data-required_mark="required" data-field_type="<?php echo $radio_select;?>" <?php echo in_array($cat->slug, $queryvar)?'checked':'';?> data-original_id="radio">
                                  <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                  <label class="radio-label" data-value="<?php echo $cat->slug ?>" for="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num; ?>" title="<?php echo $cat->name;?>"><i></i><?php echo $prefix . $cat->name; ?></label>
                                </span>
                                <?php
                              endforeach;
                            endif;
                            ?>
                            <!-- </form> -->
                          </div>
                        </div>
                      </div>
                      <?php
                    }
                } else if ( $filter_post_type == "acf" ) {
                  if( class_exists('ACF') ) {
                    $acf_get = get_field_object($acf_name);
                    $acf_type = $acf_get['type'];

                    if ( $acf_type == 'true_false' ) {
                        $acf_get['choices'] = array(
                            '1' => esc_html__($true_text, 'divi-filter'),
                            '0' => esc_html__($false_text, 'divi-filter')
                        );
                    }

                    $queryvar = get_query_var($acf_get['name']) ? get_query_var($acf_get['name']) : ( !empty( $_GET[$acf_get['name']] )? $_GET[$acf_get['name']] : '' );

                    if ($custom_label !== '') {
                      $custom_label_final = $custom_label;
                    } else {
                      $custom_label_final = $acf_get['label'];
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'ACF Filter Label - ' . $acf_get['name'], $custom_label_final );
                    ?>
                    <div class="et_pb_contact">
                      <?php
                      if ($acf_filter_type == "select") {

                        if (isset($acf_get['multiple']) && $acf_get['multiple'] == '1') {
                          $select_multiple = 'mulitple';
                        } else {
                          $select_multiple = '';
                        }

                        if ($acf_type == "select" || $acf_type == "checkbox" || $acf_type == 'true_false') {

                          if ($acf_type == "select" || $acf_type == 'true_false') {
                            $acf_type_filter = "acfselect";
                          } else {
                            if ($radio_select == "checkbox") {
                              $acf_type_filter = "divi-checkboxmulti";
                            } else {
                              $acf_type_filter = "divi-checkboxsingle";
                            }
                          }

                          $data_type = 'select';

                          if ( $acf_type == "checkbox" || ( $acf_type == "select" && $acf_get['multiple'] == '1' ) ){
                            $data_type = 'checkbox';
                          }
                          ?>
                          <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                          <p class="et_pb_contact_field divi-filter-item" data-type="<?php echo $data_type;?>" data-filtertype="<?php echo $acf_filter_type;?>" data-filter-option="<?php echo $acf_get['name'];?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $acf_get['key'];?>">
                            <select id="<?php echo $acf_get['name'] . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-filtertype="<?php echo $acf_type_filter ?><?php echo $select_multiple ?>" name="<?php echo $acf_get['name'] . '_' . $num; ?>" data-name="<?php echo $acf_get['name']; ?>" data-field_type="select">
                              <option value="" <?php echo (empty($queryvar) || $queryvar == '')?'selected':'';?>><?php echo $select_placeholder ?></option>
                              <?php
                              foreach($acf_get['choices'] as $key => $value) {
                                if ( !empty($exclude_option_array) && in_array( $key , $exclude_option_array ) ) {
                                    continue;
                                }
                                if ($queryvar === $key) {
                                  ?>
                                  <option value="<?php echo $key ?>" selected="selected"><?php echo $value; ?></option>
                                  <?php
                                } else {
                                  ?>
                                  <option value="<?php echo $key ?>"><?php echo $value; ?></option>
                                  <?php
                                }
                              }
                              ?>
                            </select>
                          </p>
                          <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $acf_get['name'] . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                        } else {
                          echo "Please make sure your field is a select or checkbox type";
                        }
                      }else if ($acf_filter_type == "radio") {
                          $data_type = $acf_type;

                          if ( $acf_type == "checkbox" || ( $acf_type == "select" && $acf_get['multiple'] == '1' ) ){
                            $data_type = 'checkbox';
                          }

                        if ($radio_style == "select") {
                          ?>
                          <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                          <p class="et_pb_contact_field divi-filter-item" data-type="<?php echo $data_type;?>" name="<?php echo $acf_get['name']; ?>" data-field_type="select" data-filtertype="<?php echo $acf_filter_type;?>" data-filter-option="<?php echo $acf_get['name'];?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $acf_get['key'];?>">
                            <select id="<?php echo $acf_get['name'] . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-filtertype="divi-checkboxsingle" data-field_type="select" name="<?php echo $acf_get['name'] . '_' . $num; ?>" data-name="<?php echo $acf_get['name']; ?>">
                              <option value=""  <?php echo (empty($queryvar) || $queryvar == '')?'selected':'';?>><?php echo $select_placeholder ?></option>
                              <?php
                              foreach($acf_get['choices'] as $key => $value) {
                                if ( !empty($exclude_option_array) && in_array( $key , $exclude_option_array ) ) {
                                    continue;
                                }
                                if ($queryvar === $key) {
                                  ?>
                                  <option id="<?php echo $acf_get['name']; ?>_<?php echo $key . '_' . $num; ?>" value="<?php echo $key ?>" selected="selected"><?php echo $value; ?></option>
                                  <?php
                                } else {
                                  ?>
                                  <option id="<?php echo $acf_get['name']; ?>_<?php echo $key . '_' . $num; ?>" value="<?php echo $key ?>"><?php echo $value; ?></option>
                                  <?php
                                }
                              }
                              ?>
                            </select>
                          </p>
                          <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $acf_get['name'] . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                        } else {
                          if ($radio_select == "checkbox") {
                            $checkboxtype = "divi-checkboxmulti";
                          } else {
                            $checkboxtype = "divi-checkboxsingle";
                          }

                          $additional_classes = '';
                          if ( isset( $radio_show_count ) && $radio_show_count == 'on' ){
                            $additional_classes .= ' divi-show-count';
                          }

                          $empty_class = '';
                          if ( $radio_show_empty == 'on' ){
                            $empty_class = 'show-empty';
                          }

                          $data_type = $acf_type;

                          if ( $acf_type == "checkbox" || ( $acf_type == "select" && $acf_get['multiple'] == '1' ) ){
                            $data_type = 'checkbox';
                          }

                          $selected_values = explode( ',', $queryvar );
                          ?>
                          <p class="et_pb_contact_field" data-type="<?php echo $data_type;?>" data-filtertype="<?php echo $acf_filter_type;?>">
                            <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                              <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                              <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype ?> <?php echo $empty_class;?> limit_filter_cont" data-filter-option="<?php echo $acf_get['name'];?>" data-filter-name="<?php echo $acf_get['key'];?>" data-filter-count="<?php echo $radio_show_count;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                              <!-- <form> -->
                                <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on' ) ) { ?>
                                  <span class="et_pb_contact_field_radio">
                                    <input type="<?php echo $radio_select ?>" id="<?php echo $acf_get['name']; ?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" name="<?php echo $acf_get['name'] . '_' . $num; ?>" data-name="<?php echo $acf_get['name']; ?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo (empty($selected_values) || (count($selected_values) == 1 && $selected_values[0] == ''))?'checked':'';?>>
                                    <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } ?>
                                    <label class="radio-label" data-value="all" for="<?php echo $acf_get['name']; ?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                                  </span>
                                <?php } ?>
                                  <?php
                                foreach($acf_get['choices'] as $key => $value) {
                                    if ( !empty($exclude_option_array) && in_array( $key , $exclude_option_array ) ) {
                                        continue;
                                    }
                                  ?>
                                  <span class="et_pb_contact_field_radio">
                                      <input type="<?php echo $radio_select ?>" id="<?php echo $acf_get['name']; ?>_<?php echo $key . '_' . $num; ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $key ?>" name="<?php echo $acf_get['name'] . '_' . $num; ?>" data-name="<?php echo $acf_get['name']; ?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo in_array( $key, $selected_values )?'checked="checked"':'';?>>
                                      <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                      <label class="radio-label" data-value="<?php echo $key ?>" for="<?php echo $acf_get['name']; ?>_<?php echo $key . '_' . $num; ?>" title="<?php echo $value;?>"><i></i><?php echo $value; ?></label>
                                  </span>
                                  <?php
                                }
                                ?>
                                <!-- </form> -->
                              </div>
                            </div>
                          </p>
                          <?php
                        }
                      } else if ($acf_filter_type == "number_range") {
                        $acf_type = $acf_get['type'];

                        if ($acf_type == "range") {
                          $range_type = "double";
                        } else if ($acf_type == "number")  {
                          $range_type = "single";
                        } else {
                          $range_type = "none";
                        }

                        $data_type = $acf_type;

                        if ( $acf_type == "checkbox" || ( $acf_type == "select" && $acf_get['multiple'] == '1' ) ){
                          $data_type = 'checkbox';
                        }

                        if ($range_type == "none") {
                          echo "please make sure your ACF item is a number or a range field.";
                        } else {

                          if (isset($queryvar)) {
                            $queryvar_arr = (explode(";",$queryvar));
                            if ( is_array( $queryvar_arr ) ) {
                              if ( isset( $queryvar_arr[1] ) ){
                                $range_from_query = $queryvar_arr[0];
                                $range_to_query = $queryvar_arr[1];
                              }else{
                                $range_from_query = $queryvar_arr[0];
                                $range_to_query = '';
                              }
                            } else {
                              $range_from_query = "";
                              $range_to_query = "";
                            }
                          }

                          if ($range_from_query != "") {
                            $range_from = $range_from_query;
                          }
                          if ($range_to_query != "") {
                            $range_to = $range_to_query;
                          }

                          if ($acf_get['max'] < $range_to && $acf_get['max'] !== "") {
                            $range_to = $acf_get['max'];
                          }
                          
                          if ($acf_get['max'] == "") {
                            $range_max = $range_to;
                          } else {
                            $range_max = $acf_get['max'];
                          }
                        
                          ?>
                          <p class="et_pb_contact_field" data-type="<?php echo $data_type;?>" data-filtertype="input">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="divi-filter-item" data-filter-option="<?php echo $acf_get['name'];?>">
                              <input id="<?php echo $acf_get['name'] . '_' . $num; ?>" type="select" class="divi-acf js-range-slider" data-filtertype="rangeslider" data-field_type="range" name="<?php echo $acf_get['name'] . '_' . $num; ?>" data-name="<?php echo $acf_get['name']; ?>" value="" />
                            </div>
                          </p>
                          <?php
                          $css_classrend = "." . $css_class . "";
                          ?>
                          <style>
                          <?php echo $css_classrend ?> .irs-bar,
                          <?php echo $css_classrend ?> .irs-from,
                          <?php echo $css_classrend ?> .irs-to,
                          <?php echo $css_classrend ?> .irs-single,
                          <?php echo $css_classrend ?> .irs-handle>i:first-child {
                            background-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-from:before,
                          <?php echo $css_classrend ?> .irs-to:before,
                          <?php echo $css_classrend ?> .irs-single:before {
                            border-top-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-line,
                          <?php echo $css_classrend ?> .irs-min,
                          <?php echo $css_classrend ?> .irs-max {
                            background-color: <?php echo $range_sec_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs--round .irs-handle {
                           border-color: <?php echo $range_prim_color; ?> !important;
                          }
                        </style>

                        <?php
                        if ($acf_get['min'] == "") {
                          $acf_get['min'] = "0";
                        }
                        ?>

                        <script>
                        jQuery(document).ready(function($) {

                          var type = '<?php echo $range_type ?>',
                          min = <?php echo $acf_get['min'] ?>,
                          max = <?php echo $range_max ?>,
                          from = <?php echo $range_from ?>,
                          to = <?php echo $range_to ?>,
                          step = <?php echo $range_step ?>,
                          skin = "<?php echo $range_skin ?>",
                          hide_min_max = <?php echo $range_hide_min_max ?>,
                          hide_from_to = <?php echo $range_hide_from_to ?>,
                          prettify_enabled = <?php echo $range_prettify_enabled ?>,
                          prettify_separator = "<?php echo $range_prettify_separator ?>",
                          prefix = "<?php echo $range_prefix ?>",
                          postfix = "<?php echo $range_postfix ?>";

                          var filters = [];

                          var filter_item_name_arr = [];
                          var filter_item_id_arr = [];
                          var filter_item_val_arr = [];
                          var filter_input_type_arr = [];
                          jQuery('.divi-acf').each(function(i, obj) {
                            var filter_item_name = jQuery(this).attr("name"),
                            filter_item_id = jQuery(this).attr("id"),
                            filter_item_val = jQuery(this).val(),
                            filter_input_type = jQuery(this).attr('type');
                            filter_item_name_arr.push(filter_item_name);
                            filter_item_id_arr.push(filter_item_id);
                            filter_item_val_arr.push(filter_item_val);
                            filter_input_type_arr.push(filter_input_type);
                          });

                          var filter_item_name = jQuery(".<?php echo $css_class ?> .js-range-slider").attr("name");

                          $(".<?php echo $css_class ?> .js-range-slider").ionRangeSlider({
                            type: type,
                            min: min,
                            max: max,
                            from: from,
                            to: to,
                            step: step,
                            skin: skin,
                            hide_min_max: hide_min_max,
                            hide_from_to: hide_from_to,
                            prettify_enabled: prettify_enabled,
                            prettify_separator: prettify_separator,
                            prefix: prefix,
                            postfix: postfix,
                            onFinish: function (data) {
                              if ( $(".<?php echo $css_class ?> .js-range-slider").parents('.et_pb_de_mach_search_posts').length == 0 && $(".<?php echo $css_class ?> .js-range-slider").parents('.updatetype-update_button').length == 0 ){

                                      var _this = $(".<?php echo $css_class ?> .js-range-slider");
                                      var iris_to = data.to;
                                      var irs_from = data.from;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                      if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) && (irs_from != data.min || iris_to != data.max ) ) {
                                        if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                                          var filter_param_type = "title";
                                        } else {
                                          var filter_param_type = "no-title";
                                        }
                                        var value = _this.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                                        name = _this.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                                        slug = _this.attr("name"),
                                        type = 'range';
                                        //iris_to = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                                        //irs_from = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                        divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                                      } else {
                                        if (jQuery('.param-' + _this.attr('name') ).length) {
                                          jQuery('.param-' + _this.attr('name') ).remove();
                                        }
                                      }
                                divi_find_filters_to_filter();
                              }
                            }
                          });
<?php
            if ( !empty( $_GET[$acf_get['name']] ) && ( $range_from != $acf_get['min'] || $range_to != $acf_get['max'] ) ) {
?>
                var acf_slider = $(".<?php echo $css_class ?> .js-range-slider");
                if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) ) {
                    if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                      var filter_param_type = "title";
                    } else {
                      var filter_param_type = "no-title";
                    }
                    var value = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                    name = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                    slug = acf_slider.attr("name"),
                    type = 'range',
                    slider_data = acf_slider.data('ionRangeSlider'),
                    iris_to = slider_data.options.to, //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                    irs_from = slider_data.options.from; //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                    divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                }
<?php
            }
?>
                        });
                      </script>
                      <?php
                    }
                  }
                  ?>
                </div>
                <?php
                  }
                } else if ($filter_post_type == "tags") {

                  // GET AVAILABLE TAGS
                  // 1) First we get the term query
                  if ($only_show_avail == "on") {
                    $ending = "_tag";
                    $cat_key = $post_type_choose . $ending;
                    // 2) We get the WP_Query - get all the posts ID's on the page
                    
                    global $wp_query;
                    $avail_terms = "";
                    $current_query_var = $wp_query->query_vars;
                    unset( $current_query_var['paged']);
                    $current_query_var['posts_per_page'] = 999999;
                    $the_query = new WP_Query( $current_query_var );
                    $ID_array = $the_query->posts;
                    foreach($ID_array as $item) { // Then for each ID - we then look for the category
                      $terms_post = get_the_terms( $item->ID , $cat_key );
                      // 3) for each category we then add the ID to a string
                      if (is_array($terms_post)) {
                        foreach ($terms_post as $term_cat) {
                          $term_cat_id = $term_cat->term_id;
                          $avail_terms .= $term_cat_id.",";
                        }
                      }
                    }
                    $avail_terms = implode(',',array_unique(explode(',', $avail_terms)));
                    if ( $avail_terms == '' ){
                      $avail_terms = array(-1);
                      $this->add_classname( 'divi-hide');
                      $this->add_classname( 'no-avail-terms');
                    }
                  } else {
                    $avail_terms = '';
                  }
                  // GET AVAILABLE TAGS

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = 'Tags';
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Tag Filter Label', $custom_label_final );

                    $ending = "_tag";
                    $cat_key = $post_type_choose . $ending;

                    $get_categories = get_terms( $cat_key, array('hide_empty' => $cat_tag_hide_empty_dis, 'include' => $avail_terms) );

                    $queryvar = get_query_var( $cat_key )?get_query_var( $cat_key):( !empty($_GET[$cat_key])?$_GET[$cat_key]:'' );

                    if ($acf_filter_type == "select") {
?>
                    <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                    <p class="et_pb_contact_field divi-filter-item" data-type="select" data-filtertype="select" name="tags" data-field_type="select" data-filter-option="<?php echo $cat_key;?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $cat_key;?>">
                      <select id="<?php echo $cat_key . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-field_type="select" data-filtertype="customtag" name="<?php echo $cat_key . '_' . $num ?>" data-name="<?php echo $cat_key ?>">
                        <option value="" <?php echo (empty($queryvar) || ($queryvar != ''))?'selected':'';?>><?php echo $select_placeholder ?></option>
                        <?php
                        if ( $get_categories ) :
                          foreach ( $get_categories as $cat ) :
                            if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                continue;
                            }
                            ?>
                            <option id="<?php echo $cat->term_id . '_' . $num; ?>" value="<?php echo $cat->slug; ?>" <?php echo ($queryvar == $cat->slug)?'selected':''; ?>><?php echo $cat->name; ?></option>
                            <?php
                          endforeach;
                        endif;
                        ?>
                      </select>
                    </p>
                    <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $cat_key . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                    } else {

                        if ($radio_select == "checkbox") {
                            $checkboxtype = "divi-checkboxmulti";
                        } else {
                            $checkboxtype = "divi-checkboxsingle";
                        }

                        $query_var_arr = explode( ',', $queryvar );
?>
                    <p class="et_pb_contact_field" data-type="radio" data-filtertype="radio">
                      <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                        <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                        <!-- <form> -->
                        <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype ?> limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $cat_key;?>" data-filter-name="<?php echo $cat_key;?>"  data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                          <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on' ) && $only_show_avail == "off") { ?>
                          <span class="et_pb_contact_field_radio">
                            <input type="<?php echo $radio_select ?>" id="<?php echo $cat_key;?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" name="<?php echo $cat_key . '_' . $num;?>" data-name="<?php echo $cat_key;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" checked="checked">
                            <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                            <label class="radio-label" data-value="all" for="<?php echo $cat_key;?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                          </span>
                          <?php } ?>
                          <?php
                          if ( $get_categories ) :
                            foreach ( $get_categories as $cat ) :
                                if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                    continue;
                                }
                              ?>
                              <span class="et_pb_contact_field_radio">
                                <input type="<?php echo $radio_select ?>" id="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num; ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $cat->slug ?>" name="<?php echo $cat_key . '_' . $num;?>" data-name="<?php echo $cat_key;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo in_array($cat->slug, $query_var_arr)?'checked':'';?>>
                                <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                <label class="radio-label" data-value="<?php echo $cat->slug ?>" for="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num; ?>" title="<?php echo $cat->name;?>"><i></i><?php echo $cat->name; ?></label>
                              </span>
                              <?php
                            endforeach;
                          endif;
                          ?>
                          <!-- </form> -->
                        </div>
                      </div>
                    </p>
<?php
                    }
                } else if ($filter_post_type == "search") {

                  if ($is_number_input == "on") {
                    $text_search_type = 'number';
                  } else {
                    $text_search_type = 'text';
                  }

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = '';
                    }

                    if (get_search_query() == "") {
                        $seach_value = get_search_query();
                    } else {
                        $seach_value = "";
                    }

                    if ( $custom_label_final != '' ) {
                        do_action( 'wpml_register_single_string', 'divi-filter', 'Search Filter Label', $custom_label_final );
                    }
?>
                    <p class="et_pb_contact_field" data-type="input" data-filtertype="input" style="padding-left: 0;">
                        <span class="et_pb_contact_field_options_title"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                        <input id="s_<?php echo $num;?>" class="divi-acf divi-filter-item" data-filter-option="<?php echo "s";?>" data-filtertype="textsearch" data-searchdelay="<?php echo esc_attr($text_typing_timeout); ?>" type="<?php echo esc_attr($text_search_type); ?>" name="s" data-name="s" placeholder="<?php echo esc_html__( $text_placeholder, 'divi-ajax-filter' ); ?>" value="<?php echo $seach_value ?>" style="width: 100%;">
                    </p>
                  <?php
                } else if ($filter_post_type == "posttypes") {

                  if ($custom_label !== '') {
                    $custom_label_final = $custom_label;
                  } else {
                    $custom_label_final = '';
                  }

                  if ( $custom_label_final != '' ) {
                        do_action( 'wpml_register_single_string', 'divi-filter', 'PostType Filter Label', $custom_label_final );
                    }

                  $option_search  = array( '&#91;', '&#93;' );
                  $option_replace = array( '[', ']' );
                  $select_options = str_replace( $option_search, $option_replace, $select_options );
                  $select_options = json_decode( $select_options );
                  ?>
                  <p class="et_pb_contact_field_options_title"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                  <p class="et_pb_contact_field divi-filter-item" data-type="select" data-filtertype="select" data-filter-option="select_post_types">
                    <select id="select_post_types_<?php echo $num;?>" class="divi-acf et_pb_contact_select" data-filtertype="posttypes" name="select_post_types" data-name="select_post_types" data-field_type="select">
                      <option value="" selected="selected"><?php echo $select_placeholder ?></option>
                      <?php
                      foreach ( $select_options as $option ) {
                        if ( in_array( $option->value , $exclude_option_array ) ) {
                                continue;
                            }
                        $pt = get_post_type_object( $option->value );
                        ?>
                        <option value="<?php echo $option->value; ?>"><?php echo $pt->labels->name; ?></option>
                        <?php
                      }
                      ?>
                    </select>
                  </p>
                  <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#select_post_types_<?php echo $num;?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                } else if ( $filter_post_type == "taxonomy" ) {

                   // GET AVAILABLE TAXONOMIES
                  // 1) First we get the term query
                  if ($only_show_avail == "on") {
                    global $wp_query;
                    $avail_terms = "";
                    $current_query_var = $wp_query->query_vars;
                    unset( $current_query_var['paged']);
                    $current_query_var['posts_per_page'] = 999999;
                    $the_query = new WP_Query( $current_query_var );
                    $ID_array = $the_query->posts;
                    foreach($ID_array as $item) { // Then for each ID - we then look for the category
                      $terms_post = get_the_terms( $item->ID , $custom_tax_choose );
                      // 3) for each category we then add the ID to a string
                      if (is_array($terms_post)) {
                        foreach ($terms_post as $term_cat) {
                          $term_cat_id = $term_cat->term_id;
                          $avail_terms .= $term_cat_id.",";
                        }
                      }
                    }
                    $avail_terms = implode(',',array_unique(explode(',', $avail_terms)));
                    if ( $avail_terms == '' ){
                      $avail_terms = array(-1);
                      $this->add_classname( 'divi-hide');
                      $this->add_classname( 'no-avail-terms');
                    }
                  } else {
                    $avail_terms = '';
                  }
                  // GET AVAILABLE TAXONOMIES

                    $taxonomy_details = get_taxonomy( $custom_tax_choose );

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = $taxonomy_details->label;
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Taxonomy Filter Label - ' . $custom_tax_choose, $custom_label_final );

                    $get_categories = get_terms( $custom_tax_choose, array('hide_empty' => $cat_tag_hide_empty_dis, 'include' => $avail_terms) );

                    $queryvar = get_query_var( $custom_tax_choose )?get_query_var( $custom_tax_choose):( !empty($_GET[$custom_tax_choose])?$_GET[$custom_tax_choose]:'' );

                    if ($acf_filter_type == "select") {
?>
                    <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                    <p class="et_pb_contact_field divi-filter-item" data-type="select" data-filtertype="select" name="<?php echo $taxonomy_details->name ?>" data-field_type="select" data-filter-option="<?php echo $custom_tax_choose;?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $custom_tax_choose;?>">
                        <select id="<?php echo $custom_tax_choose . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-filtertype="customtaxonomy" data-field_type="select" data-name="<?php echo $custom_tax_choose ?>" name="<?php echo $custom_tax_choose . '_' . $num; ?>">
                            <option value="" <?php selected( $queryvar, ''); ?>><?php echo $select_placeholder ?></option>
<?php
                        if ( $get_categories ) :
                            foreach ( $get_categories as $cat ) :
                                if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                    continue;
                                }
?>
                            <option id="<?php echo $cat->term_id . '_' . $num; ?>" value="<?php echo $cat->slug; ?>" <?php selected( $queryvar, $cat->slug); ?>><?php echo $cat->name; ?></option>
<?php
                            endforeach;
                        endif;
                        ?>
                        </select>
                    </p>
                    <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $custom_tax_choose . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                    } else if ( $acf_filter_type == "radio" ) {

                        $empty_class = '';
                        if ( $radio_show_empty == 'on' ){
                            $empty_class = 'show-empty';
                        }

                        if ($radio_select == "checkbox") {
                            $checkboxtype = "divi-checkboxmulti";
                        } else {
                            $checkboxtype = "divi-checkboxsingle";
                        }

                        $queryvar = explode(',', $queryvar);

?>
                    <p class="et_pb_contact_field" data-type="radio" data-filtertype="radio">
                      <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                        <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                              <!-- <form> -->
                        <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype ?> <?php echo $empty_class;?> limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $custom_tax_choose;?>" data-filter-name="<?php echo $custom_tax_choose;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                          <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on' ) && $only_show_avail == "off") { ?>
                          <span class="et_pb_contact_field_radio">
                            <input type="<?php echo $radio_select ?>" id="<?php echo $custom_tax_choose;?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" name="<?php echo $custom_tax_choose . '_' . $num;?>" data-name="<?php echo $custom_tax_choose;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo ( sizeof($queryvar) == 1 && $queryvar[0]=='')?'checked="checked"':'';?>>
                            <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; }?>
                            <label class="radio-label" data-value="all" for="<?php echo $custom_tax_choose;?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                          </span>
                          <?php } ?>
                          <?php
                          if ( $get_categories ) :
                            foreach ( $get_categories as $cat ) :
                                if ( in_array( $cat->slug , $exclude_option_array ) ) {
                                    continue;
                                }
                              ?>
                              <span class="et_pb_contact_field_radio">
                                <input type="<?php echo $radio_select ?>" id="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $cat->slug ?>" name="<?php echo $custom_tax_choose . '_' . $num;?>" data-name="<?php echo $custom_tax_choose;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo ( in_array( $cat->slug, $queryvar ))?'checked="checked"':'';?>>
                                <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                <label class="radio-label" data-value="<?php echo $cat->slug ?>" for="<?php echo $cat->term_id; ?>_<?php echo $cat->slug . '_' . $num ?>" title="<?php echo $cat->name;?>"><i></i><?php echo $cat->name; ?></label>
                              </span>
                              <?php
                            endforeach;
                          endif;
                          ?>
                          <!-- </form> -->
                        </div>
                      </div>
                    </p>
<?php
                    } else if ( $acf_filter_type == "number_range"){
                        $is_term_number = true;
                        $term_min = 99999999;
                        $term_max = 0;

                        if ( !empty( $get_categories ) && is_array( $get_categories ) ) {
                            foreach ($get_categories as $term) {
                                $term_slug = $term->slug;
                                if ( $value_type == 'decimal' ) {
                                    $term_slug = str_replace('-', '.', $term_slug );
                                }
                                if ( !is_numeric( $term_slug ) ) {
                                    $is_term_number = false;
                                    break;
                                }else {
                                    $number_slug = ($value_type == 'decimal')?floatval($term_slug):intval($term_slug);
                                    $term_max = max( $term_max, $number_slug );
                                    $term_min = min( $term_min, $number_slug );
                                }
                            }
                        }

                        if ( $is_term_number ) {
                            if (isset($queryvar)) {
                                $queryvar_arr = (explode(";",$queryvar));
                                if ( is_array( $queryvar_arr ) ) {
                                    if ( isset( $queryvar_arr[1] ) ){
                                        $range_from_query = $queryvar_arr[0];
                                        $range_to_query = $queryvar_arr[1];
                                    }else{
                                        $range_from_query = $queryvar_arr[0];
                                        $range_to_query = '';
                                    }
                                } else {
                                    $range_from_query = "";
                                    $range_to_query = "";
                                }
                            }

                            if ($range_from_query != "") {
                                $range_from = $range_from_query;
                            }
                            if ( $range_from > $term_max ) {
                                $range_from = 0;
                            }
                            if ($range_to_query != "") {
                                $range_to = $range_to_query;
                            }

                            if ( $term_max < $range_to) {
                                $range_to = $term_max;
                            }
?>
                        <div class="et_pb_contact_field" data-type="range" data-filtertype="range">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="divi-filter-item" data-filter-option="<?php echo $custom_tax_choose;?>">
                              <input id="<?php echo $custom_tax_choose . '_' . $num; ?>" type="select" class="divi-acf js-range-slider" data-filtertype="rangeslider" data-field_type="range" name="<?php echo $custom_tax_choose;?>" data-name="<?php echo $custom_tax_choose;?>" value="" />
                            </div>
                        </div>
<?php
                                $css_classrend = "." . $css_class . "";
?>
                        <style>
                          <?php echo $css_classrend ?> .irs-bar,
                          <?php echo $css_classrend ?> .irs-from,
                          <?php echo $css_classrend ?> .irs-to,
                          <?php echo $css_classrend ?> .irs-single,
                          <?php echo $css_classrend ?> .irs-handle>i:first-child {
                            background-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-from:before,
                          <?php echo $css_classrend ?> .irs-to:before,
                          <?php echo $css_classrend ?> .irs-single:before {
                            border-top-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-line,
                          <?php echo $css_classrend ?> .irs-min,
                          <?php echo $css_classrend ?> .irs-max {
                            background-color: <?php echo $range_sec_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs--round .irs-handle {
                           border-color: <?php echo $range_prim_color; ?> !important;
                          }
                        </style>
                        <script>
                        jQuery(document).ready(function($) {

                          var type = 'double',
                          min = <?php echo $term_min ?>,
                          max = <?php echo $term_max ?>,
                          from = <?php echo $range_from ?>,
                          to = <?php echo $range_to ?>,
                          step = <?php echo $range_step ?>,
                          skin = "<?php echo $range_skin ?>",
                          hide_min_max = <?php echo $range_hide_min_max ?>,
                          hide_from_to = <?php echo $range_hide_from_to ?>,
                          prettify_enabled = <?php echo $range_prettify_enabled ?>,
                          prettify_separator = "<?php echo $range_prettify_separator ?>",
                          prefix = "<?php echo $range_prefix ?>",
                          postfix = "<?php echo $range_postfix ?>";

                          var filters = [];

                          var filter_item_name_arr = [];
                          var filter_item_id_arr = [];
                          var filter_item_val_arr = [];
                          var filter_input_type_arr = [];
                          jQuery('.divi-acf').each(function(i, obj) {
                            var filter_item_name = jQuery(this).attr("name"),
                            filter_item_id = jQuery(this).attr("id"),
                            filter_item_val = jQuery(this).val(),
                            filter_input_type = jQuery(this).attr('type');
                            filter_item_name_arr.push(filter_item_name);
                            filter_item_id_arr.push(filter_item_id);
                            filter_item_val_arr.push(filter_item_val);
                            filter_input_type_arr.push(filter_input_type);
                          });

                          var filter_item_name = jQuery(".<?php echo $css_class ?> .js-range-slider").attr("name");

                          $(".<?php echo $css_class ?> .js-range-slider").ionRangeSlider({
                            type: type,
                            min: min,
                            max: max,
                            from: from,
                            to: to,
                            step: step,
                            skin: skin,
                            hide_min_max: hide_min_max,
                            hide_from_to: hide_from_to,
                            prettify_enabled: prettify_enabled,
                            prettify_separator: prettify_separator,
                            prefix: prefix,
                            postfix: postfix,
                            onFinish: function (data) {
                              if ( $(".<?php echo $css_class ?> .js-range-slider").parents('.et_pb_de_mach_search_posts').length == 0 && $(".<?php echo $css_class ?> .js-range-slider").parents('.updatetype-update_button').length == 0 ){

                                      var _this = $(".<?php echo $css_class ?> .js-range-slider");
                                      var iris_to = data.to;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text();
                                      var irs_from = data.from;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                      if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) && (irs_from != 0 || iris_to != max ) ) {
                                        if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                                          var filter_param_type = "title";
                                        } else {
                                          var filter_param_type = "no-title";
                                        }
                                        var value = _this.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                                        name = _this.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                                        slug = _this.attr("name"),
                                        type = 'range';
                                        //iris_to = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                                        //irs_from = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                        divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                                      } else {
                                        if (jQuery('.param-' + _this.attr('name') ).length) {
                                          jQuery('.param-' + _this.attr('name') ).remove();
                                        }
                                      }
                                divi_find_filters_to_filter();
                              }
                            }
                          });
<?php
                                if ( !empty( $_GET[$custom_tax_choose] ) && ( $range_from != $term_min || $range_to != $term_max ) ) {
?>
                        var acf_slider = $(".<?php echo $css_class ?> .js-range-slider");
                        if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) ) {
                            if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                              var filter_param_type = "title";
                            } else {
                              var filter_param_type = "no-title";
                            }
                            var value = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                            name = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                            slug = acf_slider.attr("name"),
                            type = 'range',
                            slider_data = acf_slider.data('ionRangeSlider'),
                            iris_to = slider_data.options.to, //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                            irs_from = slider_data.options.from; //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                            divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                        }
<?php
                                }
?>
                        });
                      </script>
<?php
                        } else {
                            echo '<p>' . esc_html__( 'This taxonomy contains non numeric value.', 'divi-filter' ) . '</p>';
                        }
                    }
                } else if ($filter_post_type == "productattr") {


                  // GET AVAILABLE PRO ATTR
                  // 1) First we get the term query
                  if ($only_show_avail == "on") {
                    // 2) We get the WP_Query - get all the posts ID's on the page
                    global $wp_query;
                    $avail_terms = "";
                    $current_query_var = $wp_query->query_vars;
                    unset( $current_query_var['paged']);
                    $current_query_var['posts_per_page'] = 999999;
                    $the_query = new WP_Query( $current_query_var );
                    $ID_array = $the_query->posts;
                    foreach($ID_array as $item) { // Then for each ID - we then look for the category
                      $terms_post = get_the_terms( $item->ID , $product_attribute );
                      // 3) for each category we then add the ID to a string
                      if (is_array($terms_post)) {
                        foreach ($terms_post as $term_cat) {
                          $term_cat_id = $term_cat->term_id;
                          $avail_terms .= $term_cat_id.",";
                        }
                      }
                    }
                    $avail_terms = implode(',',array_unique(explode(',', $avail_terms)));
                    if ( $avail_terms == '' ){
                      $avail_terms = array(-1);
                      $this->add_classname( 'divi-hide');
                      $this->add_classname( 'no-avail-terms');
                    }
                  } else {
                    $avail_terms = '';
                  }
                  // GET AVAILABLE PRO ATTR

                    $terms_array = array(
                        'taxonomy' => $product_attribute,
                        'hide_empty' => $cat_tag_hide_empty_dis,
                        'include' => $avail_terms
                    );
                    $terms = get_terms( $terms_array );

                    $name = str_replace( 'pa_', '', wc_sanitize_taxonomy_name( $product_attribute ) );
                    $taxonomy_array = wc_get_attribute_taxonomies();
                    $taxonomies = wp_list_pluck( $taxonomy_array, 'attribute_label', 'attribute_name' );
                    $taxonomy_types = wp_list_pluck( $taxonomy_array, 'attribute_type', 'attribute_name' );

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    }else{
                        $custom_label_final = $taxonomies[$name];
                    }
                    do_action( 'wpml_register_single_string', 'divi-filter', 'Product Attribute Filter Label - ' . $product_attribute, $custom_label_final );

                    $queryvar = get_query_var( $product_attribute )?get_query_var( $product_attribute):( !empty($_GET[$product_attribute])?$_GET[$product_attribute]:'' );

                    if ($radio_select == "checkbox") {
                        $checkboxtype = "divi-checkboxmulti";
                    } else {
                        $checkboxtype = "divi-checkboxsingle";
                    }

                    if ( $attribute_swatch == 'on' ){
                        if ( $taxonomy_types[$name] != 'select' && $taxonomy_types[$name] != 'button' ) {
?>
                    <div class="et_pb_contact_field divi-swatch" data-type="radio" data-filtertype="radio">
                        <div class="et_pb_contact_field_options_wrapper">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype;?> limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $product_attribute;?>" data-filter-name="<?php echo $product_attribute;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                                <span class="et_pb_contact_field_radio remove_filter">
                                    <input type="<?php echo $radio_select ?>" id="<?php echo $product_attribute;?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype;?>" value="" name="<?php echo $product_attribute;?>" data-name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, '' );?>>
                                    <label class="radio-label" data-value="all" for="<?php echo $product_attribute;?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( 'Remove Filter', 'divi-filter' ); ?></label>
                                </span>
<?php
                            if ( !empty( $terms ) ) {
                                foreach ($terms as $term) {
                                    if ( in_array( $term->slug , $exclude_option_array ) ) {
                                        continue;
                                    }
                                    $value = get_term_meta( $term->term_id, 'product_attribute_'.$taxonomy_types[$name], TRUE );
?>
                                <span class="et_pb_contact_field_radio">
                                    <input type="<?php echo $radio_select ?>" id="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype;?>" value="<?php echo $term->slug ?>" name="<?php echo $product_attribute;?>" data-name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, $term->slug );?>>
                                    <label class="radio-label" data-value="<?php echo $term->slug ?>" title="<?php echo $term->name;?>" for="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num ?>"><i style="<?php echo ($taxonomy_types[$name] == 'color')?'background':'background-image';?>:<?php echo ($taxonomy_types[$name] == 'color' )?$value:"url('".$value."')";?>;"></i></label>
                                </span>
<?php
                                }
                            }
?>
                            </div>
                        </div>
                    </div>
<?php
                        } else if ( $taxonomy_types[$name] == 'button' ){
?>
                    <div class="et_pb_contact_field divi-swatch" data-type="radio" data-filtertype="radio">
                        <div class="et_pb_contact_field_options_wrapper">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="et_pb_contact_field_options_list divi-filter-item divi-checkboxsingle limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $product_attribute;?>" data-filter-name="<?php echo $product_attribute;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                                <span class="et_pb_contact_field_radio remove_filter">
                                    <input type="<?php echo $radio_select ?>" id="<?php echo $product_attribute;?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="divi-checkboxsingle" value="" name="<?php echo $product_attribute;?>" data-name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, '' );?>>
                                    <label class="radio-label" data-value="all" for="<?php echo $product_attribute;?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( 'Remove Filter', 'divi-filter' ); ?></label>
                                </span>
<?php
                            if ( !empty( $terms ) ) {
                                foreach ($terms as $term) {
                                    if ( in_array( $term->slug , $exclude_option_array ) ) {
                                        continue;
                                    }
                                    $value = get_term_meta( $term->term_id, 'product_attribute_'.$taxonomy_types[$name], TRUE );
?>
                                <span class="et_pb_contact_field_radio">
                                    <input type="<?php echo $radio_select ?>" id="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num ?>" class="divi-acf input" data-filtertype="divi-checkboxsingle" value="<?php echo $term->slug ?>" name="<?php echo $product_attribute;?>" data-name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, $term->slug );?>>
                                    <label class="radio-label" data-value="<?php echo $term->slug ?>" title="<?php echo $term->name;?>" for="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num ?>"><i><?php echo $term->name;?></i></label>
                                </span>
<?php
                                }
                            }
?>
                            </div>
                        </div>
                    </div>
<?php
                        } else if ( $taxonomy_types[$name] == 'select' ) {
?>
                        <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                        <div class="et_pb_contact_field divi-filter-item" data-type="select" data-field_type="select" data-filter-option="<?php echo $product_attribute;?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $product_attribute;?>">
                          <select id="<?php echo $product_attribute . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-field_type="select" data-filtertype="customtag" data-name="<?php echo $product_attribute ?>" name="<?php echo $product_attribute ?>">
                            <option value="" <?php selected( $queryvar, '' );?>><?php echo $select_placeholder ?></option>
                            <?php
                            if ( !empty($terms) ) :
                              foreach ( $terms as $term ) :
                                if ( in_array( $term->slug , $exclude_option_array ) ) {
                                    continue;
                                }
                                ?>
                                <option id="<?php echo $term->term_id . '_' . $num; ?>" value="<?php echo $term->slug; ?>" <?php selected( $queryvar, $term->slug );?>><?php echo $term->name; ?></option>
                                <?php
                              endforeach;
                            endif;
                            ?>
                          </select>
                        </div>
                        <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $product_attribute . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                        }
                    }else{
                        if ($acf_filter_type == "select") {
?>
                        <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                        <div class="et_pb_contact_field divi-filter-item" data-type="select" data-field_type="select" data-filter-option="<?php echo $product_attribute;?>" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="<?php echo $product_attribute;?>">
                            <select id="<?php echo $product_attribute . '_' . $num; ?>" class="divi-acf et_pb_contact_select" data-field_type="select" data-filtertype="customtag" data-name="<?php echo $product_attribute ?>" name="<?php echo $product_attribute ?>">
                                <option value="" <?php selected( $queryvar, '' );?>><?php echo $select_placeholder ?></option>
                            <?php
                                if ( !empty($terms) ) :
                                    foreach ( $terms as $term ) :
                                        if ( in_array( $term->slug , $exclude_option_array ) ) {
                                            continue;
                                        }
                            ?>
                                <option id="<?php echo $term->term_id . '_' . $num; ?>" value="<?php echo $term->slug; ?>" <?php selected( $queryvar, $term->slug );?>><?php echo $term->name; ?></option>
                        <?php
                                    endforeach;
                                endif;
                        ?>
                            </select>
                        </div>
                        <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo $product_attribute . '_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                        } else if ( $acf_filter_type == "radio" ) {
                            if ($radio_select == "checkbox") {
                                $checkboxtype = "divi-checkboxmulti";
                            } else {
                                $checkboxtype = "divi-checkboxsingle";
                            }
                            $queryvar = explode(',', $queryvar);
    ?>
                          <p class="et_pb_contact_field" data-type="radio" data-filtertype="radio">
                            <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                              <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                              <!-- <form> -->
                              <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype ?> limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="<?php echo $product_attribute;?>" data-filter-name="<?php echo $product_attribute;?>" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                                <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on' ) && $only_show_avail == "off" ) { ?>
                                <span class="et_pb_contact_field_radio">
                                  <input type="<?php echo $radio_select ?>" id="<?php echo $product_attribute; ?>_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" data-name="<?php echo $product_attribute;?>" name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo ($queryvar =='' )?'checked="checked"':'';?>>
                                  <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; }?>
                                  <label class="radio-label" data-value="all" for="<?php echo $product_attribute; ?>_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                                </span>
                                <?php } ?>
                                <?php
                                if ( $terms ) :
                                  foreach ( $terms as $term ) :
                                    if ( in_array( $term->slug , $exclude_option_array ) ) {
                                        continue;
                                    }
                                    ?>
                                    <span class="et_pb_contact_field_radio">
                                      <input type="<?php echo $radio_select ?>" id="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num; ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $term->slug ?>" data-name="<?php echo $product_attribute;?>" name="<?php echo $product_attribute;?>" data-required_mark="required" data-field_type="radio" <?php echo in_array($term->slug, $queryvar)?'checked':'';?> data-original_id="radio">
                                      <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                      <label class="radio-label" data-value="<?php echo $term->slug ?>" for="<?php echo $term->term_id; ?>_<?php echo $term->slug . '_' . $num; ?>" title="<?php echo $term->name;?>"><i></i><?php echo $term->name; ?></label>
                                    </span>
                                    <?php
                                  endforeach;
                                endif;
                                ?>
                                <!-- </form> -->
                              </div>
                            </div>
                          </p>
<?php
                        } else if ( $acf_filter_type == "number_range"){
                            $is_term_number = true;
                            $term_min = 999999999;
                            $term_max = 0;
                            foreach ($terms as $term) {
                                $term_slug = $term->slug;
                                if ( $value_type == 'decimal' ) {
                                    $term_slug = str_replace('-', '.', $term_slug );
                                }
                                if ( !is_numeric( $term_slug ) ) {
                                    $is_term_number = false;
                                    break;
                                }else {
                                    $number_slug = ($value_type == 'decimal')?floatval($term_slug):intval($term_slug);
                                    $term_max = max( $term_max, $number_slug );
                                    $term_min = min( $term_min, $number_slug );
                                }
                            }

                            if ( $is_term_number ) {
                                if (isset($queryvar)) {
                                    $queryvar_arr = (explode(";",$queryvar));
                                    if ( is_array( $queryvar_arr ) ) {
                                        if ( isset( $queryvar_arr[1] ) ){
                                            $range_from_query = $queryvar_arr[0];
                                            $range_to_query = $queryvar_arr[1];
                                        }else{
                                            $range_from_query = $queryvar_arr[0];
                                            $range_to_query = '';
                                        }
                                    } else {
                                        $range_from_query = "";
                                        $range_to_query = "";
                                    }
                                }

                                if ($range_from_query != "") {
                                    $range_from = $range_from_query;
                                }
                                if ( $range_from > $term_max ) {
                                    $range_from = 0;
                                }
                                if ($range_to_query != "") {
                                    $range_to = $range_to_query;
                                }

                                if ( $term_max < $range_to) {
                                    $range_to = $term_max;
                                }
?>
                        <div class="et_pb_contact_field" data-type="range" data-filtertype="range">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="divi-filter-item" data-filter-option="<?php echo $product_attribute;?>">
                              <input id="<?php echo $product_attribute . '_' . $num; ?>" type="select" class="divi-acf js-range-slider" data-filtertype="rangeslider" data-field_type="range" name="<?php echo $product_attribute;?>" data-name="<?php echo $product_attribute;?>" value="" />
                            </div>
                        </div>
<?php
                                $css_classrend = "." . $css_class . "";
?>
                        <style>
                          <?php echo $css_classrend ?> .irs-bar,
                          <?php echo $css_classrend ?> .irs-from,
                          <?php echo $css_classrend ?> .irs-to,
                          <?php echo $css_classrend ?> .irs-single,
                          <?php echo $css_classrend ?> .irs-handle>i:first-child {
                            background-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-from:before,
                          <?php echo $css_classrend ?> .irs-to:before,
                          <?php echo $css_classrend ?> .irs-single:before {
                            border-top-color: <?php echo $range_prim_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs-line,
                          <?php echo $css_classrend ?> .irs-min,
                          <?php echo $css_classrend ?> .irs-max {
                            background-color: <?php echo $range_sec_color; ?> !important;
                          }
                          <?php echo $css_classrend ?> .irs--round .irs-handle {
                           border-color: <?php echo $range_prim_color; ?> !important;
                          }
                        </style>
                        <script>
                        jQuery(document).ready(function($) {

                          var type = 'double',
                          min = <?php echo $term_min ?>,
                          max = <?php echo $term_max ?>,
                          from = <?php echo $range_from ?>,
                          to = <?php echo $range_to ?>,
                          step = <?php echo $range_step ?>,
                          skin = "<?php echo $range_skin ?>",
                          hide_min_max = <?php echo $range_hide_min_max ?>,
                          hide_from_to = <?php echo $range_hide_from_to ?>,
                          prettify_enabled = <?php echo $range_prettify_enabled ?>,
                          prettify_separator = "<?php echo $range_prettify_separator ?>",
                          prefix = "<?php echo $range_prefix ?>",
                          postfix = "<?php echo $range_postfix ?>";

                          var filters = [];

                          var filter_item_name_arr = [];
                          var filter_item_id_arr = [];
                          var filter_item_val_arr = [];
                          var filter_input_type_arr = [];
                          jQuery('.divi-acf').each(function(i, obj) {
                            var filter_item_name = jQuery(this).attr("name"),
                            filter_item_id = jQuery(this).attr("id"),
                            filter_item_val = jQuery(this).val(),
                            filter_input_type = jQuery(this).attr('type');
                            filter_item_name_arr.push(filter_item_name);
                            filter_item_id_arr.push(filter_item_id);
                            filter_item_val_arr.push(filter_item_val);
                            filter_input_type_arr.push(filter_input_type);
                          });

                          var filter_item_name = jQuery(".<?php echo $css_class ?> .js-range-slider").attr("name");

                          $(".<?php echo $css_class ?> .js-range-slider").ionRangeSlider({
                            type: type,
                            min: min,
                            max: max,
                            from: from,
                            to: to,
                            step: step,
                            skin: skin,
                            hide_min_max: hide_min_max,
                            hide_from_to: hide_from_to,
                            prettify_enabled: prettify_enabled,
                            prettify_separator: prettify_separator,
                            prefix: prefix,
                            postfix: postfix,
                            onFinish: function (data) {
                              if ( $(".<?php echo $css_class ?> .js-range-slider").parents('.et_pb_de_mach_search_posts').length == 0 && $(".<?php echo $css_class ?> .js-range-slider").parents('.updatetype-update_button').length == 0 ){

                                      var _this = $(".<?php echo $css_class ?> .js-range-slider");
                                      var iris_to = data.to;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text();
                                      var irs_from = data.from;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                      if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) && (irs_from != 0 || iris_to != max ) ) {
                                        if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                                          var filter_param_type = "title";
                                        } else {
                                          var filter_param_type = "no-title";
                                        }
                                        var value = _this.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                                        name = _this.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                                        slug = _this.attr("name"),
                                        type = 'range';
                                        //iris_to = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                                        //irs_from = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                        divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                                      } else {
                                        if (jQuery('.param-' + _this.attr('name') ).length) {
                                          jQuery('.param-' + _this.attr('name') ).remove();
                                        }
                                      }
                                divi_find_filters_to_filter();
                              }
                            }
                          });
<?php
                                if ( !empty( $_GET[$product_attribute] ) && ( $range_from != $term_min || $range_to != $term_max ) ) {
?>
                        var acf_slider = $(".<?php echo $css_class ?> .js-range-slider");
                        if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) ) {
                            if ( acf_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                              var filter_param_type = "title";
                            } else {
                              var filter_param_type = "no-title";
                            }
                            var value = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                            name = acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                            slug = acf_slider.attr("name"),
                            type = 'range',
                            slider_data = acf_slider.data('ionRangeSlider'),
                            iris_to = slider_data.options.to, //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                            irs_from = slider_data.options.from; //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                            divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                        }
<?php
                                }
?>
                        });
                      </script>
<?php
                            } else {
                                echo '<p>' . esc_html__( 'This attribute contains non numeric value.', 'divi-filter' ) . '</p>';
                            }
                        }
                    }
                } else if ( $filter_post_type == "productprice" ) {
                    $product_cat  = get_query_var( 'product_cat' )?get_query_var('product_cat') : ( !empty($_GET['product_cat'])?$_GET['product_cat'] : '');
                    $queryvar = get_query_var('product_price') ? get_query_var('product_price') : ( !empty( $_GET['product_price'] )? $_GET['product_price'] : '' );
                    global $wpdb;

                    if ( $max_price_type == 'store' || $max_price_type == 'category' ) {
                        $sql = "SELECT MAX(a.max_price) AS max_price FROM {$wpdb->wc_product_meta_lookup} a JOIN {$wpdb->posts} b ON a.product_id=b.id";
                        if ( $max_price_type == 'category' && !empty( $product_cat ) ) {
                            $current_cat = get_term_by( 'slug', $product_cat, 'product_cat' );
                            $current_cat_id = $current_cat->term_id;
                            $categories = get_categories( array( 'child_of' => $current_cat->term_id, 'taxonomy' => 'product_cat' ) );
                            $cat_ids = array( $current_cat_id );
                            foreach ( $categories as $cat_key => $cat ) {
                                $cat_ids[] = $cat->term_id;
                            }
                            $sql .= " JOIN {$wpdb->term_relationships} c ON b.id = c.object_id JOIN {$wpdb->term_taxonomy} d ON c.term_taxonomy_id = d.term_taxonomy_id JOIN {$wpdb->terms} e ON d.term_id = e.term_id WHERE e.term_id IN (". implode(',', $cat_ids ) . ")";
                        }

                        $max_price = ceil( $wpdb->get_var( $sql ) );
                    } else {
                        $max_price = $range_to;
                    }

                    $min_price = (!empty( $range_from ) && $range_from < $max_price)?$range_from:0;

                    $range_from_query = 0;
                    $range_to_query = $max_price;
                    if ( !empty( $queryvar ) ){
                        $price_arr = (explode(";", $queryvar));
                        if ( is_array( $price_arr ) ) {
                            if ( isset( $price_arr[1] ) ) {
                                $range_from_query = $price_arr[0];
                                $range_to_query = $price_arr[1];
                            }else{
                                $range_from_query = $price_arr[0];
                                $range_to_query = '';
                            }
                        }
                    }

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = 'Price Range';
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Product Price Filter Label', $custom_label_final );

?>
                    <div class="et_pb_contact_field" data-type="range" data-filtertype="range">
                        <span class="et_pb_contact_field_options_title <?php echo $label_css;?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                        <div class="divi-filter-item" data-filter-option="product_price">
                            <input id="<?php echo "price_" . $num;?>" type="input" class="divi-acf js-range-slider" data-filtertype="rangeslider" data-name="product_price" name="product_price" value="" />
                        </div>
                    </div>
<?php
                    $css_classrend = '.' . $css_class;
?>
            <style>
                <?php echo $css_classrend ?> .irs-bar,
                <?php echo $css_classrend ?> .irs-from,
                <?php echo $css_classrend ?> .irs-to,
                <?php echo $css_classrend ?> .irs-single,
                <?php echo $css_classrend ?> .irs-handle>i:first-child {
                    background-color: <?php echo $range_prim_color; ?> !important;
                }
                <?php echo $css_classrend ?> .irs-from:before,
                <?php echo $css_classrend ?> .irs-to:before,
                <?php echo $css_classrend ?> .irs-single:before {
                    border-top-color: <?php echo $range_prim_color; ?> !important;
                }
                <?php echo $css_classrend ?> .irs-line,
                <?php echo $css_classrend ?> .irs-min,
                <?php echo $css_classrend ?> .irs-max {
                    background-color: <?php echo $range_sec_color; ?> !important;
                }
                          <?php echo $css_classrend ?> .irs--round .irs-handle {
                           border-color: <?php echo $range_prim_color; ?> !important;
                          }
            </style>
        <script>
            jQuery(document).ready(function($) {

                var from = <?php echo $range_from_query ?>,
                to = <?php echo $range_to_query ?>,
                step = <?php echo $range_step ?>,
                skin = "<?php echo $range_skin ?>",
                hide_min_max = <?php echo $range_hide_min_max ?>,
                hide_from_to = <?php echo $range_hide_from_to ?>,
                prettify_enabled = <?php echo $range_prettify_enabled ?>,
                prettify_separator = "<?php echo $range_prettify_separator ?>",
                prefix = "<?php echo $range_prefix ?>",  // before the number
                postfix = "<?php echo $range_postfix ?>"; // after the number

                var filters = [];

                var filter_item_name_arr = [];
                var filter_item_id_arr = [];
                var filter_item_val_arr = [];
                var filter_input_type_arr = [];

                jQuery('.divi-acf').each(function(i, obj) {
                    var filter_item_name = jQuery(this).attr("name"),
                    filter_item_id = jQuery(this).attr("id"),
                    filter_item_val = jQuery(this).val(),
                    filter_input_type = jQuery(this).attr('type');
                    filter_item_name_arr.push(filter_item_name);
                    filter_item_id_arr.push(filter_item_id);
                    filter_item_val_arr.push(filter_item_val);
                    filter_input_type_arr.push(filter_input_type);
                });

                var filter_item_name = jQuery(".<?php echo $css_class ?> .js-range-slider").attr("name");

                $(".<?php echo $css_class ?> .js-range-slider").ionRangeSlider({
                    type: 'double',
                    min: <?php echo $min_price;?>,
                    max: <?php echo $max_price;?>,
                    from: from,
                    to: to,
                    step: step,
                    skin: skin,
                    hide_min_max: hide_min_max,
                    hide_from_to: hide_from_to,
                    prettify_enabled: prettify_enabled,
                    prettify_separator: prettify_separator,
                    prefix: prefix,
                    postfix: postfix,
                    onFinish: function (data) {
                        if ( $(".<?php echo $css_class ?> .js-range-slider").parents('.et_pb_de_mach_search_posts').length == 0 && $(".<?php echo $css_class ?> .js-range-slider").parents('.updatetype-update_button').length == 0 ){

                              var _this = $(".<?php echo $css_class ?> .js-range-slider");
                              var iris_to = data.to;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text();
                              var irs_from = data.from;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                              if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) && (irs_from != 0 || iris_to != <?php echo $max_price;?> ) ) {
                                if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                                  var filter_param_type = "title";
                                } else {
                                  var filter_param_type = "no-title";
                                }
                                var value = _this.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                                name = _this.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                                slug = _this.attr("name"),
                                type = 'range';
                                //iris_to = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                                //irs_from = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                              } else {
                                if (jQuery('.param-' + _this.attr('name') ).length) {
                                  jQuery('.param-' + _this.attr('name') ).remove();
                                }
                              }
                              divi_find_filters_to_filter();
                        }
                   }
                });

<?php
            if ( !empty( $_GET['product_price'] ) && ( $range_from_query != 0 || $range_to_query != $max_price ) ) {
?>
                var price_slider = $(".<?php echo $css_class ?> .js-range-slider");
                if ( price_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) ) {
                    if ( price_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                      var filter_param_type = "title";
                    } else {
                      var filter_param_type = "no-title";
                    }
                    var value = price_slider.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                    name = price_slider.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                    slug = price_slider.attr("name"),
                    type = 'range',
                    slider_data = price_slider.data('ionRangeSlider'),
                    iris_to = slider_data.options.to, //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                    irs_from = slider_data.options.from; //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                    divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                }
<?php
            }
?>
            });
        </script>
<?php
                } else if ( $filter_post_type == "productweight" ) {
                    $product_cat  = get_query_var( 'product_cat' )?get_query_var('product_cat') : ( !empty($_GET['product_cat'])?$_GET['product_cat'] : '');
                    $product_weight = get_query_var('product_weight') ? get_query_var('product_weight') : ( !empty( $_GET['product_weight'] )? $_GET['product_weight'] : '' );
                    global $wpdb;
                    $sql = "SELECT MAX(b.meta_value) FROM {$wpdb->posts} a JOIN (SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_weight') b ON a.id=b.post_id";
                    if ( !empty( $product_cat ) ) {
                        $sql .= " JOIN {$wpdb->term_relationships} c ON a.id = c.object_id JOIN {$wpdb->term_taxonomy} d ON c.term_taxonomy_id = d.term_taxonomy_id JOIN {$wpdb->terms} e ON d.term_id = e.term_id WHERE e.slug='".$product_cat."'";
                    }
                    $max_weight = ceil( $wpdb->get_var( $sql ) );

                    if ( !empty( $range_to ) && $range_to != '800' ) {
                        $max_weight = $range_to;
                    }

                    $min_weight = (!empty( $range_from ) && $range_from < $max_weight)?$range_from:0;

                    $range_from_query = 0;
                    $range_to_query = $max_weight;
                    if ( !empty( $product_weight ) ){
                        $weight_arr = (explode(";", $product_weight));
                        if ( is_array( $weight_arr ) ) {
                            if ( isset( $weight_arr[1] ) ) {
                                $range_from_query = $weight_arr[0];
                                $range_to_query = $weight_arr[1];
                            }else{
                                $range_from_query = $weight_arr[0];
                                $range_to_query = '';
                            }
                        }
                    }

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                    } else {
                        $custom_label_final = 'Weight Range';
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Product Weight Filter Label', $custom_label_final );

?>
                    <div class="et_pb_contact_field" data-type="range" data-filtertype="range">
                        <span class="et_pb_contact_field_options_title <?php echo $label_css;?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                        <div class="divi-filter-item" data-filter-option="product_weight">
                            <input id="<?php echo "weight_" . $num;?>" type="input" class="divi-acf js-range-slider" data-filtertype="rangeslider" data-name="product_weight" name="product_weight" value="" />
                        </div>
                    </div>
<?php
                    $css_classrend = '.' . $css_class;
?>
            <style>
                <?php echo $css_classrend ?> .irs-bar,
                <?php echo $css_classrend ?> .irs-from,
                <?php echo $css_classrend ?> .irs-to,
                <?php echo $css_classrend ?> .irs-single,
                <?php echo $css_classrend ?> .irs-handle>i:first-child {
                    background-color: <?php echo $range_prim_color; ?> !important;
                }
                <?php echo $css_classrend ?> .irs-from:before,
                <?php echo $css_classrend ?> .irs-to:before,
                <?php echo $css_classrend ?> .irs-single:before {
                    border-top-color: <?php echo $range_prim_color; ?> !important;
                }
                <?php echo $css_classrend ?> .irs-line,
                <?php echo $css_classrend ?> .irs-min,
                <?php echo $css_classrend ?> .irs-max {
                    background-color: <?php echo $range_sec_color; ?> !important;
                }
                          <?php echo $css_classrend ?> .irs--round .irs-handle {
                           border-color: <?php echo $range_prim_color; ?> !important;
                          }
            </style>
        <script>
            jQuery(document).ready(function($) {

                var from = <?php echo $range_from_query ?>,
                to = <?php echo $range_to_query ?>,
                step = <?php echo $range_step ?>,
                skin = "<?php echo $range_skin ?>",
                hide_min_max = <?php echo $range_hide_min_max ?>,
                hide_from_to = <?php echo $range_hide_from_to ?>,
                prettify_enabled = <?php echo $range_prettify_enabled ?>,
                prettify_separator = "<?php echo $range_prettify_separator ?>",
                prefix = "<?php echo $range_prefix ?>",  // before the number
                postfix = "<?php echo $range_postfix ?>"; // after the number

                var filters = [];

                var filter_item_name_arr = [];
                var filter_item_id_arr = [];
                var filter_item_val_arr = [];
                var filter_input_type_arr = [];

                jQuery('.divi-acf').each(function(i, obj) {
                    var filter_item_name = jQuery(this).attr("name"),
                    filter_item_id = jQuery(this).attr("id"),
                    filter_item_val = jQuery(this).val(),
                    filter_input_type = jQuery(this).attr('type');
                    filter_item_name_arr.push(filter_item_name);
                    filter_item_id_arr.push(filter_item_id);
                    filter_item_val_arr.push(filter_item_val);
                    filter_input_type_arr.push(filter_input_type);
                });

                var filter_item_name = jQuery(".<?php echo $css_class ?> .js-range-slider").attr("name");

                $(".<?php echo $css_class ?> .js-range-slider").ionRangeSlider({
                    type: 'double',
                    min: <?php echo $min_weight;?>,
                    max: <?php echo $max_weight;?>,
                    from: from,
                    to: to,
                    step: step,
                    skin: skin,
                    hide_min_max: hide_min_max,
                    hide_from_to: hide_from_to,
                    prettify_enabled: prettify_enabled,
                    prettify_separator: prettify_separator,
                    prefix: prefix,
                    postfix: postfix,
                    onFinish: function (data) {
                        if ( $(".<?php echo $css_class ?> .js-range-slider").parents('.et_pb_de_mach_search_posts').length == 0 && $(".<?php echo $css_class ?> .js-range-slider").parents('.updatetype-update_button').length == 0 ){

                              var _this = $(".<?php echo $css_class ?> .js-range-slider");
                              var iris_to = data.to;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text();
                              var irs_from = data.from;//_this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                              if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) && (irs_from != 0 || iris_to != <?php echo $max_weight;?> ) ) {
                                if ( _this.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                                  var filter_param_type = "title";
                                } else {
                                  var filter_param_type = "no-title";
                                }
                                var value = _this.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                                name = _this.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                                slug = _this.attr("name"),
                                type = 'range';
                                //iris_to = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                                //irs_from = _this.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                                divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                              } else {
                                if (jQuery('.param-' + _this.attr('name') ).length) {
                                  jQuery('.param-' + _this.attr('name') ).remove();
                                }
                              }
                              divi_find_filters_to_filter();
                        }
                    }
                });

<?php
            if ( !empty( $_GET['product_weight'] ) && ( $range_from_query != 0 || $range_to_query != $max_weight ) ) {
?>
                var weight_slider = $(".<?php echo $css_class ?> .js-range-slider");
                if ( weight_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params" ) ) {
                    if ( weight_slider.closest(".et_pb_de_mach_search_posts_item").hasClass( "filter_params_yes_title" ) ) {
                      var filter_param_type = "title";
                    } else {
                      var filter_param_type = "no-title";
                    }
                    var value = weight_slider.closest(".et_pb_de_mach_search_posts_item").find(".js-range-slider").val(),
                    name = weight_slider.closest(".et_pb_de_mach_search_posts_item").find(".et_pb_contact_field_options_title ").text(),
                    slug = weight_slider.attr("name"),
                    type = 'range',
                    slider_data = acf_slider.data('ionRangeSlider'),
                    iris_to = slider_data.options.to, //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-to").text(),
                    irs_from = slider_data.options.from; //acf_slider.closest(".et_pb_de_mach_search_posts_item").find(".irs-from").text();
                    divi_filter_params(type, slug, value, name, filter_param_type, iris_to, irs_from);
                }
<?php
            }
?>
            });
        </script>
<?php
                } else if ( $filter_post_type == "productrating" ) {

                    $queryvar = get_query_var('product_rating') ? get_query_var('product_rating') : ( !empty( $_GET['product_rating'] )? $_GET['product_rating'] : '' );

                    if ($custom_label !== '') {
                      $custom_label_final = $custom_label;
                    } else {
                      $custom_label_final = 'Product Rating';
                    }

                    do_action( 'wpml_register_single_string', 'divi-filter', 'Product Rating Filter Label', $custom_label_final );

                    $terms = array(0, 1, 2, 3, 4, 5);

                    if ( $attribute_swatch == 'on' ){
?>
                    <div class="et_pb_contact_field divi-swatch divi-swatch-full" data-type="radio" data-filtertype="radio">
                        <div class="et_pb_contact_field_options_wrapper">
                            <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                            <div class="et_pb_contact_field_options_list divi-filter-item divi-checkboxsingle limit_filter_cont" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-option="product_rating" data-filter-name="product_rating" data-limitsize="<?php echo $filter_limit_height ?>" style="max-height:<?php echo $filter_limit_height ?>">
                                <span class="et_pb_contact_field_radio remove_filter">
                                    <input type="<?php echo $radio_select ?>" id="product_rating_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="divi-checkboxsingle" value="" name="product_rating" data-name="product_rating" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, '' );?>>
                                    <label class="radio-label" data-value="all" title="All" for="product_rating_all_<?php echo $num;?>"><i></i><?php echo esc_html__( 'Remove Filter', 'divi-filter' ); ?></label>
                                </span>
<?php
                            if ( !empty( $terms ) ) {
                                foreach ($terms as $term) {
                                    if ( in_array( $term , $exclude_option_array ) ) {
                                        continue;
                                    }
?>
                                <span class="et_pb_contact_field_radio">
                                    <input type="<?php echo $radio_select ?>" id="product_rating_<?php echo $term . '_' . $num ?>" class="divi-acf input" data-filtertype="divi-checkboxsingle" value="<?php echo $term; ?>" name="product_rating" data-name="product_rating" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php checked( $queryvar, $term );?>>
                                    <label class="radio-label" data-value="<?php echo $term ?>" title="<?php echo $term;?>" for="product_rating_<?php echo $term . '_' . $num ?>">
                                        <div class="star-rating" role="img">
                                            <span style="width:<?php echo 20 * $term;?>%"></span>
                                        </div>
                                    </label>
                                </span>
<?php
                                }
                            }
?>
                            </div>
                        </div>
                    </div>
<?php
                    }else{
                        if ($acf_filter_type == "select") {
?>
                        <p class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></p>
                        <div class="et_pb_contact_field divi-filter-item" data-type="select" data-field_type="select" data-filter-option="product_rating" data-filter-count="<?php echo $radio_show_count;?>" data-show-empty="<?php echo $radio_show_empty;?>" data-filter-name="product_rating">
                            <select id="<?php echo 'product_rating_' . $num; ?>" class="divi-acf et_pb_contact_select" data-field_type="select" data-filtertype="divi-checkboxsingle" name="product_rating" data-name="product_rating">
                                <option value="" <?php selected( $queryvar, '' );?>><?php echo $select_placeholder ?></option>
                            <?php
                                if ( !empty($terms) ) :
                                    foreach ( $terms as $term ) :
                                        if ( in_array( $term , $exclude_option_array ) ) {
                                            continue;
                                        }
                            ?>
                                <option id="<?php echo 'product_rating_'.$term.'_' . $num; ?>" value="<?php echo $term; ?>" <?php selected( $queryvar, $term );?>><?php echo ($term == 0)?esc_html__('No Rating', 'divi-filter'):sprintf(esc_html__('%d Rating(s)', 'divi-filter'), $term); ?></option>
                        <?php
                                    endforeach;
                                endif;
                        ?>
                            </select>
                        </div>
                        <?php
                      if ($select2 == "on") {
                        ?>
                        <script>
                        jQuery(document).ready(function ($) {
                          $('#<?php echo 'product_rating_' . $num; ?>').select2({width: '100%'});
                        });
                        </script>
                        <?php 
                      }
                        } else if ( $acf_filter_type == "radio" ) {
                            if ($radio_select == "checkbox") {
                                $checkboxtype = "divi-checkboxmulti";
                            } else {
                                $checkboxtype = "divi-checkboxsingle";
                            }
                            $queryvar = explode(',', $queryvar);
    ?>
                          <p class="et_pb_contact_field" data-type="radio" data-filtertype="radio">
                            <div class="et_pb_contact_field_options_wrapper divi-radio-<?php echo $radio_style ?>">
                              <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-filter' ); ?></span>
                              <!-- <form> -->
                              <div class="et_pb_contact_field_options_list divi-filter-item <?php echo $checkboxtype ?>" data-filter-option="product_rating" data-filter-name="product_rating">
                                <?php if ( ( $radio_select != 'checkbox') && ($radio_all_hide != 'on' ) && $only_show_avail == "off" ) { ?>
                                <span class="et_pb_contact_field_radio">
                                  <input type="<?php echo $radio_select ?>" id="product_rating_all_<?php echo $num;?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="" name="product_rating" data-name="product_rating" data-required_mark="required" data-field_type="radio" data-original_id="radio" <?php echo ($queryvar =='' )?'checked="checked"':'';?>>
                                  <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; }?>
                                  <label class="radio-label" data-value="all" for="product_rating_all_<?php echo $num;?>" title="All"><i></i><?php echo esc_html__( $radio_all_text, 'divi-filter' ); ?></label>
                                </span>
                                <?php } ?>
                                <?php
                                if ( $terms ) :
                                  foreach ( $terms as $term ) :
                                    if ( in_array( $term , $exclude_option_array ) ) {
                                        continue;
                                    }
                                    ?>
                                    <span class="et_pb_contact_field_radio">
                                      <input type="<?php echo $radio_select ?>" id="product_rating_<?php echo $term . '_' . $num; ?>" class="divi-acf input" data-filtertype="<?php echo $checkboxtype ?>" value="<?php echo $term ?>" name="product_rating" data-name="product_rating" data-required_mark="required" data-field_type="radio" <?php echo in_array($term, $queryvar)?'checked':'';?> data-original_id="radio">
                                      <?php if ($radio_style == "tick_box") { echo '<span class="checkmark"></span>'; } else {} ?>
                                      <label class="radio-label" data-value="<?php echo $term ?>" for="product_rating_<?php echo $term . '_' . $num; ?>" title="<?php echo $term;?>"><i></i><?php echo ($term == 0)?esc_html__('No Rating', 'divi-filter'):sprintf(esc_html__('%d Rating(s)', 'divi-filter'), $term); ?></label>
                                    </span>
                                    <?php
                                  endforeach;
                                endif;
                                ?>
                                <!-- </form> -->
                              </div>
                            </div>
                          </p>
<?php
                        }
                    }
                } else if ($filter_post_type == "sort") {
                } else if ($filter_post_type == "date") {
                } else if ($filter_post_type == "acf_map"){

                    if ($custom_label !== '') {
                        $custom_label_final = $custom_label;
                } else {
                        $custom_label_final = 'Search By Address';
                    }

                    if( class_exists('ACF') ) {
                        $acf_get = get_field_object($acf_map_name);
                        $acf_type = $acf_get['type'];
                    }

                    $address_value = get_query_var($acf_get['name']) ? get_query_var($acf_get['name']) : ( !empty( $_GET[$acf_get['name']] )? $_GET[$acf_get['name']] : '' );
                    $radius_value = get_query_var('map_radius') ? get_query_var('map_radius') : ( !empty( $_GET['map_radius'] )? $_GET['map_radius'] : '' );

                    if ( $custom_label_final != '' ) {
                        do_action( 'wpml_register_single_string', 'divi-ajax-filter', 'Map Address Label', $custom_label_final );
                    }
                    $radius_label = 'Radius in ' . strtoupper($acf_map_radius_unit);
                    do_action( 'wpml_register_single_string', 'divi-ajax-filter', 'Range Label for Search by Address ', $radius_label );
                    wp_enqueue_script('dmach_js_googlemaps_script');
?>
                    <div class="et_pb_contact_field_options_wrapper" data-type="address" data-filtertype="input" style="padding-left: 0;">
                        <span class="et_pb_contact_field_options_title <?php echo $label_css ?>"><?php echo esc_html__( $custom_label_final, 'divi-ajax-filter' ); ?></span>
                        <div class="et_pb_contact_field_options_wrapper divi-filter-item">
                            <input id="map_address_<?php echo $num;?>" class="divi-acf divi-filter-item divi-acf-map" data-filtertype="address" type="text" name="<?php echo $acf_get['name'];?>" data-name="<?php echo $acf_get['name'];?>" placeholder="<?php echo esc_html__( $text_placeholder, 'divi-ajax-filter' ); ?>" value="<?php echo $address_value ?>" onFocus="geolocate()" style="width: 100%;">
                            <input id="map_address_lat_<?php echo $num;?>" type="hidden" name="map_address_lat" class="map_address_lat">
                            <input id="map_address_lng_<?php echo $num;?>" type="hidden" name="map_address_lng" class="map_address_lng">
                            <span class="radius_label"><?php echo __($radius_label, 'divi-ajax-filter');?></span>
                            <input id="map_radius_<?php echo $num;?>" class="divi-acf divi-filter-item divi-acf-map-radius" data-radius-type="<?php echo $acf_map_radius_unit;?>" data-filtertype="radius" data-searchdelay="<?php echo esc_attr($text_typing_timeout); ?>" type="text" name="map_radius" data-name="map_radius" placeholder="<?php echo esc_html__( $radius_label, 'divi-ajax-filter' ); ?>" value="<?php echo $radius_value ?>" style="width: 100%;">
                        </div>
                    </div>
                  <?php
                } else{

                }
if ($filter_limit == "on") {
// TODO: Finish styling of the show more/less. Add Icons, animations smoother
  $this->add_classname( 'limit_filters');
  echo '<span class="limit_filter_text showmore">' . $filter_limit_show_more_text . '</span>';
  echo '<span class="limit_filter_text showless">' . $filter_limit_show_less_text . '</span>';
}
?>
                </div>
                <?php
                $data = ob_get_clean();

                //////////////////////////////////////////////////////////////////////

                return $data;
            }

            public function listTaxonomies($args, &$new_categories = array()) {
                
                $categories = get_terms($args);

                if($categories) {
                    foreach( $categories as $category ) {
                        $new_categories[] = $category;
                        $args['parent'] = $category->term_id;
                        $this->listTaxonomies($args, $new_categories);
                    }
                }
            }
        }

        new et_pb_df_product_filter_item_code;
        }
    }
}