<?php defined('ABSPATH') or die('No script kiddies please!!');
$ciws_main_settings = get_option('ciws_main_settings');

?>

<div class="wrap ciws-wrap">

    <?php include(CIWS_PATH . '/includes/views/backend/account-boxes/account-header.php'); ?>
    <!-- End of header section -->
    <?php
    if (!empty($_GET['message']) && $_GET['message'] == 1) {
        ?>
        <div class="notice notice-info is-dismissible inline">
            <p>
                <?php esc_html_e('Settings saved successfully.', 'chat-in-website'); ?>
            </p>
        </div>
        <?php
    }
    ?>
    <h2 class="nav-tab-wrapper wp-clearfix">
        <?php
        $ciws_tabs = array(

            'url' => array('label' => __('URL Settings', 'chat-in-website'), 'icon' => 'dashicons dashicons-admin-site'),
            'display' => array('label' => __('Display Settings', 'chat-in-website'), 'icon' => 'dashicons dashicons-welcome-view-site'),
            'woocommerce' => array('label' => __('WooCommerce Button Option', 'chat-in-website'), 'icon' => 'dashicons dashicons-cart'),

        );


        $ciws_tab_counter = 0;
        foreach ($ciws_tabs as $ciws_tab => $ciws_tab_detail) {
            $ciws_tab_counter++;
             // Only show WooCommerce tab if WooCommerce is installed and active
             if ($ciws_tab == 'woocommerce' && !class_exists('WooCommerce')) {
                continue; // Skip the WooCommerce tab if WooCommerce is not installed
            }
            ?>
            <a href="javascript:void(0);"
                class="nav-tab <?php echo ($ciws_tab_counter == 1) ? 'nav-tab-active' : ''; ?> ciws-tab-trigger"
                data-settings-ref="<?php echo esc_attr($ciws_tab); ?>"><span
                    class="<?php echo esc_attr($ciws_tab_detail['icon']); ?>"></span>
                <?php echo esc_attr($ciws_tab_detail['label']); ?>
            </a>

            <?php
        }
        ?>

    </h2>
    <div class="ciws-settings-wrap">

        <form method="post" class="ciws-form" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
            <?php wp_nonce_field('ciws_main_settings_nonce', 'ciws_main_settings_nonce_field'); ?>
            <input type="hidden" name="action" value="ciws_main_action" />
            <?php

            include(CIWS_PATH . '/includes/views/backend/settings-boxes/ciws-url-settings.php');
            include(CIWS_PATH . '/includes/views/backend/settings-boxes/ciws-display-settings.php');
            include(CIWS_PATH . '/includes/views/backend/settings-boxes/ciws-woocommerce-settings.php');

            ?>
            <div class="ciws-field-wrap">

                <div class="ciws-field-wrap  ciws-settings-action">
                    <label></label>
                    <div class="ciws-field">
                        <input type="submit" class="button-primary"
                            value="<?php esc_html_e('Save', 'chat-in-website'); ?>" />
                    </div>
                </div>
            </div>
        </form>

    </div>
</div>