<?php
namespace WTC_CHECKOUT\Modules\Forms\Admin;
defined('ABSPATH') || exit;
class FieldLayoutSettings {
    private $option_name = 'wtc_field_layouts';
    private $priority_option_name = 'wtc_field_priorities';
    private $page_slug = 'wtc-layouts';
    private $default_layouts = array(
        'billing_invoice_type' => 'wtc-full',
        'billing_first_name' => 'wtc-first',
        'billing_last_name' => 'wtc-last',
        'billing_tckn' => 'wtc-full',
        'billing_company' => 'wtc-full',
        'billing_tax_number' => 'wtc-first',
        'billing_tax_office' => 'wtc-last',
        'billing_country' => 'wtc-first',
        'billing_state' => 'wtc-last',
        'billing_city' => 'wtc-first',
        'billing_address_1' => 'wtc-last',
        'billing_address_2' => 'wtc-full',
        'billing_postcode' => 'wtc-first',
        'billing_phone' => 'wtc-last',
        'billing_email' => 'wtc-full',
        'shipping_first_name' => 'wtc-first',
        'shipping_last_name' => 'wtc-last',
        'shipping_company' => 'wtc-full',
        'shipping_country' => 'wtc-first',
        'shipping_state' => 'wtc-last',
        'shipping_city' => 'wtc-first',
        'shipping_address_1' => 'wtc-last',
        'shipping_address_2' => 'wtc-full',
        'shipping_postcode' => 'wtc-first',
        'shipping_name' => 'wtc-full'
    );
    private $default_priorities = array(
        'billing_invoice_type' => 10,
        'billing_first_name' => 20,
        'billing_last_name' => 30,
        'billing_tckn' => 40,
        'billing_company' => 50,
        'billing_tax_number' => 60,
        'billing_tax_office' => 70,
        'billing_country' => 80,
        'billing_state' => 90,
        'billing_city' => 100,
        'billing_address_1' => 110,
        'billing_address_2' => 120,
        'billing_postcode' => 130,
        'billing_phone' => 140,
        'billing_email' => 150,
        'shipping_first_name' => 10,
        'shipping_last_name' => 20,
        'shipping_company' => 30,
        'shipping_country' => 40,
        'shipping_state' => 50,
        'shipping_city' => 60,
        'shipping_address_1' => 70,
        'shipping_address_2' => 80,
        'shipping_postcode' => 90,
        'shipping_name' => 100,
        'order_comments' => 200
    );
    private $allowed_html = [
        'li' => [
            'class' => true,
            'data-field-id' => true,
        ],
        'span' => [
            'class' => true,
        ],
        'select' => [
            'class' => true,
            'name' => true,
        ],
        'option' => [
            'value' => true,
            'selected' => true,
        ],
        'input' => [
            'type' => true,
            'name' => true,
            'value' => true,
        ],
    ];
    private $tabs = [];
    private $active_tab = '';
    public function __construct() {
        if (get_option($this->option_name, false) === false) {
            update_option($this->option_name, $this->default_layouts);
        }
        if (get_option($this->priority_option_name, false) === false) {
            update_option($this->priority_option_name, $this->default_priorities);
        }
        $this->tabs = [
            'settings' => __('Ayarlar', 'wtc-checkout'),
        ];
    }
    public function render_settings_page() {
        if (!current_user_can('manage_woocommerce')) {
            wp_die(esc_html__('Bu sayfaya erişim yetkiniz yok.', 'wtc-checkout'));
        }
        $tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : '';
        $nonce = isset($_GET['wtc_tab_nonce']) ? sanitize_text_field(wp_unslash($_GET['wtc_tab_nonce'])) : '';
        if ($tab && $nonce && wp_verify_nonce($nonce, 'wtc_layouts_tab_action') && array_key_exists($tab, $this->tabs)) {
            $this->active_tab = $tab;
        } else {
            $this->active_tab = 'settings';
        }
        ?>
        <div class="wrap wtc-admin-page">
            <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
            <?php
            if (isset($_GET['settings-updated'])) {
                $settings_updated = sanitize_text_field(wp_unslash($_GET['settings-updated']));
                if ($settings_updated === 'true') {
                    echo '<div class="notice notice-success is-dismissible"><p>' . 
                         esc_html__('Alan düzenleri ve sıralaması başarıyla kaydedildi.', 'wtc-checkout') . 
                         '</p></div>';
                }
            }
            $this->render_tabs();
            ?>
            <div class="wtc-card">
                <?php
                switch ($this->active_tab) {
                    case 'settings':
                    default:
                        $this->render_layouts_tab();
                        break;
                }
                ?>
            </div>
        </div>
        <?php
    }
    private function render_tabs() {
        echo '<h2 class="wtc-nav-tab-wrapper nav-tab-wrapper">';
        $nonce = wp_create_nonce('wtc_layouts_tab_action');
        foreach ($this->tabs as $tab_id => $tab_name) {
            $active_class = $this->active_tab === $tab_id ? ' nav-tab-active wtc-nav-tab-active' : '';
            $url = admin_url('admin.php?page=wtc-layouts&tab=' . $tab_id . '&wtc_tab_nonce=' . $nonce);
            echo '<a href="' . esc_url($url) . '" class="wtc-nav-tab nav-tab' . esc_attr($active_class) . '">' . esc_html($tab_name) . '</a>';
        }
echo '<style>
        .wtc-nav-tab-wrapper {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
        position: relative;
    }
    .wtc-right-tabs {
        margin-left: auto;
        display: flex;
        gap: 10px;
    }
    .wtc-right-tabs a {
        display: inline-flex;
        align-items: center;
        font-weight: bold;
        border-radius: 4px;
        text-decoration: none;
        padding: 10px 20px;
        transition: background-color 0.3s ease;
        font-size: 16px;
    }
    .wtc-premium-link {
        background-color: #0AA000;
        color: #fff !important;
    }
    .wtc-premium-link:hover {
        background-color:rgb(8, 97, 2);
    }
    .wtc-support-link {
        background-color: #FFDD00;
        color: #000 !important;
    }
    .wtc-support-link:hover {
        background-color: #f2cc00;
    }
    </style>';
echo '<span class="wtc-right-tabs">';
echo '<a href="https://www.woosoft.com.tr" target="_blank" class="wtc-premium-link">⭐&nbsp;&nbsp;Premium</a>';
echo '<a href="https://coff.ee/woosoft" target="_blank" class="wtc-support-link">☕&nbsp;&nbsp;Buy me a coffee</a>';
echo '</span>';
        echo '</h2>';
    }
    private function render_layouts_tab() { ?>
        <div class="wtc-admin-content">
            <div id="wtc-field-layout-manager">
                <div class="wtc-card-header wtc-flex-between">
                <div class="wtc-description">
                    <p>Alan düzenlerini ve sıralamalarını buradan yönetebilirsiniz. Meta Key (billing_invoice_type, billing_tckn, billing_tax_number, billing_tax_office) isimlendirmelerini değiştirmeniz durumunda, önceki siparişlerinizde kayıtlı olan bu veriler görüntülenmeyecektir. Varsayılan Meta Key tanımlarını kullanmak için alanı boş bırakıp ‘Değişiklikleri kaydet’ butonuna tıklayabilirsiniz.</p>
                </div>
                <button type="button" id="wtc-add-field-btn" class="button wtc-button wtc-button-primary"> Yeni Alan Ekle </button>
                </div>
                <form method="post" id="wtc-priorities-form">
                <div class="wtc-fields-container">
                    <div class="wtc-fields-section">
                    <h2>Fatura Alanları</h2>
                    <ul class="wtc-sortable ui-sortable" id="billing-fields-sortable">
                        <li class="wtc-sortable-item  " data-field-id="billing_invoice_type">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Fatura Tipi</span>
                            <div class="wtc-item-meta">
                            <input type="text" name="wtc_keys[invoice_type]" value="billing_invoice_type" class="wtc-key-input" placeholder="billing_invoice_type">
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_invoice_type]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_invoice_type]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_first_name">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Ad</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_first_name</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_first_name]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_first_name]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_last_name">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Soyad</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_last_name</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_last_name]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_last_name]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_tckn">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">TC Kimlik No</span>
                            <div class="wtc-item-meta">
                            <input type="text" name="wtc_keys[tckn]" value="billing_tckn" class="wtc-key-input" placeholder="billing_tckn">
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_tckn]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_tckn]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_company">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Firma Adı</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_company</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_company]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_company]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_tax_number">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Vergi No</span>
                            <div class="wtc-item-meta">
                            <input type="text" name="wtc_keys[tax_number]" value="billing_tax_number" class="wtc-key-input" placeholder="billing_tax_number">
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_tax_number]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_tax_number]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_tax_office">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Vergi Dairesi</span>
                            <div class="wtc-item-meta">
                            <input type="text" name="wtc_keys[tax_office]" value="billing_tax_office" class="wtc-key-input" placeholder="billing_tax_office">
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_tax_office]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_tax_office]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_country">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Ülke</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_country</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_country]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_country]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_state">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">İl</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_state</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_state]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_state]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_city">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">İlçe</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_city</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_city]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_city]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_address_1">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Mahalle</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_address_1</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_address_1]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_address_1]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_address_2">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Adres</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_address_2</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_address_2]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_address_2]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_postcode">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Posta Kodu</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_postcode</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_postcode]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_postcode]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_phone">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Cep Telefonu</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_phone</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_phone]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_phone]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="billing_email">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">E-posta</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">billing_email</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[billing_email]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[billing_email]" value="">
                        </li>
                    </ul>
                    </div>
                    <div class="wtc-fields-section">
                    <h2>Teslimat Alanları</h2>
                    <ul class="wtc-sortable ui-sortable" id="shipping-fields-sortable">
                        <li class="wtc-sortable-item  " data-field-id="shipping_first_name">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Ad</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_first_name</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_first_name]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_first_name]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_last_name">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Soyad</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_last_name</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_last_name]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_last_name]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_company">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Firma Adı</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_company</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_company]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_company]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_country">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Ülke</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_country</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_country]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_country]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_state">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">İl</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_state</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_state]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_state]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_city">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">İlçe</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_city</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_city]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_city]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_address_1">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Mahalle</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_address_1</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_address_1]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last" selected="selected">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_address_1]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_address_2">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Adres</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_address_2</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_address_2]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_address_2]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_postcode">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Posta Kodu</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_postcode</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_postcode]">
                            <option value="wtc-full">Tam</option>
                            <option value="wtc-first" selected="selected">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_postcode]" value="">
                        </li>
                        <li class="wtc-sortable-item  " data-field-id="shipping_name">
                        <div class="wtc-item-handle">
                            <span class="dashicons dashicons-menu wtc-drag-handle ui-sortable-handle"></span>
                        </div>
                        <div class="wtc-item-content">
                            <span class="wtc-item-label">Adres Başlığı</span>
                            <div class="wtc-item-meta">
                            <span class="wtc-key-badge">shipping_name</span>
                            </div>
                        </div>
                        <div class="wtc-item-actions">
                            <select class="wtc-layout-select" name="layouts[shipping_name]">
                            <option value="wtc-full" selected="selected">Tam</option>
                            <option value="wtc-first">Sol</option>
                            <option value="wtc-last">Sağ</option>
                            </select>
                        </div>
                        <input type="hidden" name="priorities[shipping_name]" value="">
                        </li>
                    </ul>
                    </div>
                </div>
                <div class="wtc-card-footer">
                    <input type="hidden" id="wtc_priorities_nonce" name="wtc_priorities_nonce" value="437b792010">
                    <input type="hidden" name="_wp_http_referer" value="/wp-admin/admin.php?page=wtc-layouts">
                    <input type="hidden" name="wtc_field_priorities" id="wtc-field-priorities" value="">
                    <input type="hidden" name="wtc_field_layouts" id="wtc-field-layouts" value="">
                    <input type="submit" name="submit" id="submit" class="button button-primary wtc-button wtc-button-primary" value="Değişiklikleri kaydet">
                    <button type="submit" name="wtc_reset_layouts" value="1" class="button wtc-button wtc-button-secondary wtc-ml-10" onclick="return confirm('Tüm alan düzenleri ve öncelikler varsayılan değerlere döndürülecek. Emin misiniz?');"> Varsayılana Döndür </button>
                    <input type="hidden" id="wtc_reset_nonce" name="wtc_reset_nonce" value="c2cd4a9f20">
                    <input type="hidden" name="_wp_http_referer" value="/wp-admin/admin.php?page=wtc-layouts">
                </div>
                </form>
            </div>
            </div>
    <?php
    }
} 