<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly 

$iwbvel_items = $filter_form_items['taxonomies'];

foreach ($iwbvel_items as $iwbvel_name => $iwbvel_item):
    if ($iwbvel_name === 'taxonomy_section'):
?>
        <div class="iwbvel-form-group">
            <div>
                <strong><?php echo esc_html($iwbvel_item['label']); ?></strong>
                <hr>
                <div class="iwbvel-mb20"></div>
            </div>
        </div>

        <?php if (!empty($taxonomies['taxonomy'])) : ?>
            <?php foreach ($taxonomies['taxonomy'] as $iwbvel_tax_name => $iwbvel_taxonomy) :
                if (in_array($iwbvel_tax_name, ['pos_product_visibility'])) {
                    continue;
                }
            ?>
                <div class="iwbvel-form-group" data-filter-type="taxonomy" data-field-type="select_multiple" data-name="<?php echo esc_attr($iwbvel_tax_name); ?>">
                    <label for="iwbvel-filter-form-product-attr-<?php echo esc_attr($iwbvel_tax_name); ?>"><?php echo esc_html($iwbvel_taxonomy['label']); ?></label>
                    <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled'] && $iwbvel_taxonomy['label'] === 'Brands') ? 'disabled="disabled"' : ''; ?> id="iwbvel-filter-form-product-attr-operator-<?php echo esc_attr($iwbvel_tax_name); ?>" title="<?php esc_attr_e('Select Operator', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>" data-field="operator">
                        <?php include IWBVEL_VIEWS_DIR . "bulk_edit/filter_form/operators/taxonomy.php"; ?>
                    </select>

                    <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled'] && $iwbvel_taxonomy['label'] === 'Brands') ? 'disabled="disabled"' : ''; ?> class="iwbvel-select2-taxonomies iwbvel-select2-item iwbvel-filter-form-select2-option-values" data-output="term_id" data-option-name="<?php echo esc_attr($iwbvel_tax_name); ?>" data-field="value" id="iwbvel-filter-form-product-attr-<?php echo esc_attr($iwbvel_tax_name); ?>" multiple></select>
                    <?php if (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled'] && $iwbvel_taxonomy['label'] === 'Brands') : ?>
                        <span class="iwbvel-alert-pro-description"><?php esc_html_e('Upgrade to pro version!', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>
        <?php else : ?>
            <div class="iwbvel-alert iwbvel-alert-warning">
                <span><?php esc_html_e('There is not any added Custom Taxonomies', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
            </div>
        <?php endif; ?>

    <?php elseif ($iwbvel_name === 'attribute_section'): ?>
        <div class="iwbvel-form-group">
            <div>
                <strong><?php echo esc_html($iwbvel_item['label']); ?></strong>
                <hr>
                <div class="iwbvel-mb20"></div>
            </div>
        </div>

        <?php if (!empty($taxonomies['attribute'])) : ?>
            <?php foreach ($taxonomies['attribute'] as $iwbvel_attr_name => $iwbvel_taxonomy) : ?>
                <div class="iwbvel-form-group" data-filter-type="attribute" data-field-type="select_multiple" data-name="<?php echo esc_attr($iwbvel_attr_name); ?>">
                    <label for="iwbvel-filter-form-product-attr-<?php echo esc_attr($iwbvel_attr_name); ?>"><?php echo esc_html($iwbvel_taxonomy['label']); ?></label>
                    <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled'] && $iwbvel_taxonomy['label'] === 'Brands') ? 'disabled="disabled"' : ''; ?> id="iwbvel-filter-form-product-attr-operator-<?php echo esc_attr($iwbvel_attr_name); ?>" title="<?php esc_attr_e('Select Operator', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>" data-field="operator">
                        <?php include IWBVEL_VIEWS_DIR . "bulk_edit/filter_form/operators/taxonomy.php"; ?>
                    </select>
                    <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled'] && $iwbvel_taxonomy['label'] === 'Brands') ? 'disabled="disabled"' : ''; ?> class="iwbvel-select2-taxonomies iwbvel-select2-item iwbvel-filter-form-select2-option-values" data-output="slug" data-option-name="<?php echo esc_attr($iwbvel_attr_name); ?>" data-field="value" id="iwbvel-filter-form-product-attr-<?php echo esc_attr($iwbvel_attr_name); ?>" multiple></select>
                    <?php if (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']) : ?>
                        <span class="iwbvel-alert-pro-description"><?php esc_html_e('Upgrade to pro version!', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>
        <?php else : ?>
            <div class="iwbvel-alert iwbvel-alert-warning">
                <span><?php esc_html_e('There is not any added Attributes', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
            </div>
        <?php endif; ?>
    <?php endif; ?>
<?php endforeach; ?>