<?php



$options = get_option(self::OPTION_NAME);

$endpoint = $options["api"]['endpoint'] ?? '';
$api_key = $options["api"]['api-key'] ?? '';
$api_key_status = $options["api"]["api-key-status"] ?? false;

$thankyou_page_id=$options['thankyou-page']['id'] ?? "";

$force_login_status=$options['force-login']['status'] ?? '0';

$top_banner_status = $options['top-banner']['status'] ?? '1';

$product_card_status = $options['product-card']['status'] ?? '1';
$product_card_position = $options['product-card']['position'] ?? 'woocommerce_before_shop_loop_item';

$product_single_status = $options['product-single']['status'] ?? '1';
$product_single_position = $options['product-single']['position'] ?? 'woocommerce_after_add_to_cart_button';

$product_single_modal_logo_id=$options['product-single-modal']['logo'] ?? '';
$product_single_modal_link=$options['product-single-modal']['link'] ?? '';
$product_single_modal_title=$options['product-single-modal']['title'] ?? '';


$product_single_badge_status = $options['product-single-badge']['status'] ?? '1';
$product_single_badge_position = $options['product-single-badge']['position'] ?? 'woocommerce_before_add_to_cart_button';

$checkout_status = $options['checkout']['status'] ?? '1';
$checkout_position = $options['checkout']['position'] ?? 'woocommerce_before_checkout_form';

$cart_status = $options['cart']['status'] ?? '1';
$cart_position = $options['cart']['position'] ?? 'woocommerce_before_cart_table';

$minicart_status = $options['minicart']['status'] ?? '1';

$custom_css=$options['custom']['css'] ?? "";
$custom_js=$options['custom']['js'] ?? "";


$product_single_modal_logo_link = $product_single_modal_logo_id ? wp_get_attachment_url($product_single_modal_logo_id) : '';

$pages=get_pages();


?>


<div id="bwdk-wrapper" class="bwdk-wrapper">


    <div class="wrap">


        <form id="kt_project_settings_form" class="form fv-plugins-bootstrap5 fv-plugins-framework"
              novalidate="novalidate"
              method="post" action="options.php"
        >

            <?php
            settings_fields(self::OPTION_GROUP);
            ?>

            <div class="kt_app_content">

                <div class="bwdk-card mb-9">

                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">تنظیمات API</div>
                    </div>
                    <div class="bwdk-card-body p-9">

                        <?php
                        if ($api_key_status){
                            ?>
                            <div class="alert alert-danger d-flex align-items-center p-5">
                                <!--begin::Icon-->
                                <i class="ki-duotone ki-shield-tick fs-2hx text-success me-4"><span class="path1"></span><span class="path2"></span></i>
                                <!--end::Icon-->

                                <!--begin::Wrapper-->
                                <div class="d-flex flex-column">
                                    <!--begin::Title-->
                                    <h4 class="mb-1 text-dark">خطا</h4>
                                    <!--end::Title-->

                                    <!--begin::Content-->
                                    <span>
<?php echo $api_key_status; ?>
                                </span>
                                    <!--end::Content-->
                                </div>
                                <!--end::Wrapper-->
                            </div>
                            <?php
                        }

                        ?>

                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">آدرس سرور</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <input type="text"
                                       class="form-control form-control-solid"
                                       name="bwdk_options[api][endpoint]"
                                       value="<?php echo esc_attr($endpoint) ?>"
                                       dir="ltr"

                                >
                            </div>
                        </div>

                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کلید API</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <input type="text"
                                       class="form-control form-control-solid"
                                       name="bwdk_options[api][api-key]"
                                       value="<?php echo esc_attr($api_key) ?>"
                                       dir="ltr"
                                >
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">تنظیمات لاگین اجباری</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">وضعیت</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[force-login][status]" id="force_login_status_yes"
                                            <?php echo ($force_login_status == 1) ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="force_login_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[force-login][status]" id="force_login_status_no"
                                            <?php echo ($force_login_status == 0) ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="force_login_status_no">غیرفعال</label>
                                    </div>
                                    <!--end::رادیو-->
                                </div>
                            </div>

                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">برگه وضعیت سفارش</div>
                            </div>
                            <div class="col-xl-10 fv-row">

                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[thankyou-page][id]"
                                >
                                    <?php
                                    foreach ($pages as $page) {
                                        ?>
                                        <option value="<?php echo $page->ID;  ?>"
                                            <?php echo ($page->ID == $thankyou_page_id) ? 'selected' : ''; ?>
                                        >
                                            <?php echo $page->post_title;  ?>
                                        </option>
                                    <?php
                                    }

                                    ?>

                                </select>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_thankyou]</code>
                            </div>
                        </div>




                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">تنظیمات بنر</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[top-banner][status]" id="top_banner_status_yes"
                                            <?php echo ($top_banner_status == 1) ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="top_banner_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[top-banner][status]" id="top_banner_status_no"
                                            <?php echo ($top_banner_status == 0) ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="top_banner_status_no">غیرفعال</label>
                                    </div>
                                    <!--end::رادیو-->
                                </div>
                            </div>

                        </div>

                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه بنر</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_top_banner]</code>
                            </div>
                        </div>


                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">کامپوننت کارت محصول </div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <!--begin::Alert-->
                        <div class="alert alert-primary d-flex align-items-center p-5">
                            <!--begin::Icon-->
                            <i class="ki-duotone ki-shield-tick fs-2hx text-success me-4"><span class="path1"></span><span class="path2"></span></i>
                            <!--end::Icon-->

                            <!--begin::Wrapper-->
                            <div class="d-flex flex-column">
                                <!--begin::Title-->
                                <h4 class="mb-1 text-dark">توجه</h4>
                                <!--end::Title-->

                                <!--begin::Content-->
                                <span>اگر قالب فروشگاه برای کارت محصول هوک استاندارد داشته باشد، بج از طریق همان هوک درج می‌شود.

در صورتی که هوک در قالب تعریف نشده باشد، بج به‌صورت شورت‌کد با موقعیت مطلق (absolute) روی تصویر محصول قرار می‌گیرد.</span>
                                <!--end::Content-->
                            </div>
                            <!--end::Wrapper-->
                        </div>
                        <!--end::Alert-->
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[product-card][status]" id="product_card_status_yes"
                                            <?php echo ($product_card_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_card_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[product-card][status]" id="product_card_status_no"
                                            <?php echo ($product_card_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_card_status_no">غیرفعال</label>
                                    </div>
                                    <!--end::رادیو-->
                                </div>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">انتخاب جایگاه نمایش</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[product-card][position]"
                                >
                                    <option value="woocommerce_before_shop_loop_item"
                                        <?php echo ($product_card_position == 'woocommerce_before_shop_loop_item') ? 'selected' : ''; ?>
                                    >روی عکس محصول</option>
                                    <option value="woocommerce_shop_loop_item_title"
                                        <?php echo ($product_card_position == 'woocommerce_shop_loop_item_title') ? 'selected' : ''; ?>
                                    >قبل از عنوان</option>
                                    <option value="woocommerce_after_shop_loop_item_title"
                                        <?php echo ($product_card_position == 'woocommerce_after_shop_loop_item_title') ? 'selected' : ''; ?>
                                    >بعد از عنوان</option>
                                </select>
                            </div>
                        </div>



                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_product_card_badge]</code>
                            </div>
                        </div>


                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">صفحه نمایش محصول</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[product-single][status]" id="product_single_status_yes"
                                            <?php echo ($product_single_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_single_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[product-single][status]" id="product_single_status_no"
                                            <?php echo ($product_single_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_single_status_no">غیرفعال</label>
                                    </div>
                                    <!--end::رادیو-->
                                </div>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">انتخاب جایگاه نمایش</div>
                            </div>
                            <div class="col-xl-10 fv-row">


                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[product-single][position]"
                                >
                                    <option value="woocommerce_before_add_to_cart_button"
                                        <?php echo ($product_single_position == "woocommerce_before_add_to_cart_button") ? "selected" : ""; ?>
                                    >قبل از دکمه افزودن به سبد خرید</option>
                                    <option value="woocommerce_after_add_to_cart_button"
                                        <?php echo ($product_single_position == "woocommerce_after_add_to_cart_button") ? "selected" : ""; ?>
                                    >بعد از دکمه افزودن به سبد خرید</option>
                                </select>
                            </div>
                        </div>



                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_add_to_cart_button]</code>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">عنوان سایت</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <input type="text"
                                       class="form-control form-control-solid"
                                       name="bwdk_options[product-single-modal][title]"
                                       value="<?php echo esc_attr($product_single_modal_title); ?>"

                                >
                            </div>
                        </div>

                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">لوگو</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">


                                <input type="hidden" name="bwdk_options[product-single-modal][logo]" id="bwdk_image" value="<?php echo esc_attr($product_single_modal_logo_id); ?>">
                                <img id="bwdk_image_preview" src="<?php echo esc_url($product_single_modal_logo_link); ?>" style="max-width:150px; display:block; margin:10px 0;">
                                <button type="button" class="button" id="bwdk_image_button">انتخاب تصویر</button>
                                <button type="button" class="button" id="bwdk_image_remove">حذف</button>
                            </div>
                        </div>

                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">لینک مودال</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <input type="text"
                                       class="form-control form-control-solid"
                                       name="bwdk_options[product-single-modal][link]"
                                       value="<?php echo esc_attr($product_single_modal_link); ?>"
                                       dir="ltr"
                                >
                            </div>
                        </div>



                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">لیبل صفحه نمایش محصول</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[product-single-badge][status]" id="product_single_status_yes"
                                            <?php echo ($product_single_badge_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_single_badge_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[product-single-badge][status]" id="product_single_status_no"
                                            <?php echo ($product_single_badge_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="product_single_badge_status_no">غیرفعال</label>
                                    </div>
                                    <!--end::رادیو-->
                                </div>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">انتخاب جایگاه نمایش</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[product-single-badge][position]"
                                >
                                    <option value="woocommerce_before_single_product_summary"
                                        <?php echo ($product_single_badge_position == "woocommerce_before_single_product_summary") ? "selected" : ''; ?>
                                    >بر روی تصویر</option>
                                </select>
                            </div>
                        </div>



                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_thumbnail_single_badge]</code>
                            </div>
                        </div>


                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">صفحه سبدخرید</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[cart][status]" id="cart_status_yes"
                                            <?php echo ($cart_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="cart_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[cart][status]" id="cart_status_no"
                                            <?php echo ($cart_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="cart_status_no">غیرفعال</label>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">انتخاب جایگاه نمایش</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[cart][position]"
                                >
                                    <option value="woocommerce_before_cart_table"
                                        <?php echo ($cart_position == 'woocommerce_before_cart_table') ? 'selected' : ''; ?>
                                    >قبل از جدول محصولات</option>
                                </select>
                            </div>
                        </div>



                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_comp1]</code>
                            </div>
                        </div>


                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">صفحه تسویه حساب</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[checkout][status]" id="checkout_status_yes"
                                            <?php echo ($checkout_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="checkout_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[checkout][status]" id="checkout_status_no"
                                            <?php echo ($checkout_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="checkout_status_no">غیرفعال</label>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">انتخاب جایگاه نمایش</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <select class="form-select" aria-label="Select example"
                                        name="bwdk_options[checkout][position]"
                                >
                                    <option value="woocommerce_before_checkout_form"
                                        <?php echo ($checkout_position == 'woocommerce_before_checkout_form') ? 'selected' : ''; ?>
                                    >قبل از فرم های تسویه حساب</option>
                                    <option value="woocommerce_checkout_billing"
                                        <?php echo ($checkout_position == 'woocommerce_checkout_billing') ? 'selected' : ''; ?>
                                    >قبل از فیلد های تسویه حساب</option>
                                </select>
                            </div>
                        </div>



                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_comp1]</code>
                            </div>
                        </div>


                    </div>
                </div>

                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">پاپ آپ / ساید بار سبد خرید</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">نمایش خودکار</div>
                            </div>
                            <div class="col-xl-10 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <!--begin::رادیو-->
                                    <div class="form-check form-check-custom form-check-solid me-5">
                                        <input class="form-check-input" type="radio" value="1"
                                               name="bwdk_options[minicart][status]" id="minicart_status_yes"
                                            <?php echo ($minicart_status == '1') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="minicart_status_yes">فعال</label>
                                    </div>
                                    <div class="form-check form-check-custom form-check-solid">
                                        <input class="form-check-input" type="radio" value="0"
                                               name="bwdk_options[minicart][status]" id="minicart_status_no"
                                            <?php echo ($minicart_status == '0') ? 'checked' : ''; ?>>
                                        <label class="form-check-label" for="minicart_status_no">غیرفعال</label>
                                    </div>
                                </div>
                            </div>
                        </div>




                        <div class="row mb-8">
                            <div class="col-xl-2">
                                <div class="fs-6 fw-semibold mt-2 mb-3">کد کوتاه</div>
                            </div>
                            <div class="col-xl-10 fv-row">
                                <code>[bwdk_minicart]</code>
                            </div>
                        </div>


                    </div>
                </div>


                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">css سفارشی</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">

                            <div class="col-xl-12 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <textarea class="form-control min-h-500px form-control-solid" dir="ltr" name="bwdk_options[custom][css]" id=""  rows="50"><?php echo $custom_css; ?></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="bwdk-card mb-9">
                    <div class="bwdk-card-header">
                        <div class="bwdk-card-title fs-3 fw-bold">js سفارشی</div>
                    </div>
                    <div class="bwdk-card-body p-9">
                        <div class="row mb-8">

                            <div class="col-xl-12 fv-row fv-plugins-icon-container">
                                <div class="d-flex mt-3">
                                    <textarea class="form-control min-h-500px form-control-solid" dir="ltr" name="bwdk_options[custom][js]" id=""  rows="50"><?php echo $custom_js; ?></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <button type="submit" class="btn btn-primary" id="submit" name="submit">ذخیره
                تغییرات
            </button>


        </form>
    </div>
</div>
<script>
    jQuery(document).ready(function ($) {
        let frame;
        $('#bwdk_image_button').on('click', function (e) {
            e.preventDefault();

            if (frame) {
                frame.open();
                return;
            }

            frame = wp.media({
                title: 'انتخاب تصویر',
                button: { text: 'استفاده از این تصویر' },
                multiple: false
            });

            frame.on('select', function () {
                const attachment = frame.state().get('selection').first().toJSON();
                $('#bwdk_image').val(attachment.id);
                $('#bwdk_image_preview').attr('src', attachment.url).show();
            });

            frame.open();
        });

        $('#bwdk_image_remove').on('click', function (e) {
            e.preventDefault();
            $('#bwdk_image').val('');
            $('#bwdk_image_preview').attr('src', '').hide();
        });
    });

</script>