<?php

/**
 * MultiDealer - AJAX Installer File
 *
 * This file handles the initial setup process for the Multi Dealer plugin,
 * guiding the user through a multi-step AJAX-powered installation wizard.
 * Last Updated: 25 June 2024
 */
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

/**
 * Registers the hidden installer admin page.
 * This page is only accessible if the setup is not yet complete.
 */
function multidealer_inst_add_admin_page()
{
    if (get_option('multidealer_setup_complete', false)) {
        return;
    }
    add_submenu_page(
        'tools.php',
        'MultiDealer Installer',
        'MultiDealer Installer',
        'manage_options',
        'multidealer-installer',
        'multidealer_inst_render_installer'
    );
}
add_action('admin_menu', 'multidealer_inst_add_admin_page');

/**
 * Enqueues CSS and JS for the installer page.
 *
 * @param string $hook The current admin page hook.
 */
function multidealer_inst_enqueue_scripts($hook)
{
    if ($hook !== 'tools_page_multidealer-installer') {
        return;
    }
    wp_enqueue_style(
        'multidealer-inst-styles',
        MULTIDEALERURL . 'includes/install/install.css',
        ['dashicons'],
        MULTIDEALERVERSION
    );
    wp_enqueue_script(
        'multidealer-inst-script',
        MULTIDEALERURL . 'includes/install/install.js',
        ['jquery'],
        MULTIDEALERVERSION,
        true
    );
    wp_localize_script(
        'multidealer-inst-script',
        'multidealer_installer_ajax',
        [
            'ajax_url'      => admin_url('admin-ajax.php'),
            'nonce'         => wp_create_nonce('multidealer-installer-ajax-nonce'),
            'initial_step'  => isset($_GET['step']) ? intval($_GET['step']) : 1,
            'dashboard_url' => admin_url('index.php'), // This can be updated to the final plugin page
            'import_nonce'  => wp_create_nonce('multidealer_import_nonce')
        ]
    );
}
add_action('admin_enqueue_scripts', 'multidealer_inst_enqueue_scripts');

/**
 * The main AJAX handler for navigating installer steps.
 * It processes the data from the previous step and loads the HTML for the next one.
 */
function multidealer_ajax_installer_handler()
{
    check_ajax_referer('multidealer-installer-ajax-nonce', 'nonce');
    if (!current_user_can('manage_options')) {
        wp_send_json_error(['message' => 'Permission denied.']);
    }

    $step_to_load = isset($_POST['step_to_load']) ? intval($_POST['step_to_load']) : 1;
    $direction    = isset($_POST['direction']) ? sanitize_key($_POST['direction']) : 'next';

    if ($direction === 'next') {
        $step_to_process = $step_to_load - 1;
        switch ($step_to_process) {
            case 1:
                // No data to process from the welcome step.
                break;
            case 2:
                // Process data from Step 2 (Settings).
                $allowed_currencies = ['USD', 'AED', 'AOA', 'AFN', 'ARS', 'AUD', 'BRL', 'BGN', 'CAD', 'CNY', 'HRK', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'INR', 'RIAL', 'ILS', 'JPY', 'KRW', 'MYR', 'MXN', 'NZD', 'NOK', 'PKR', 'PHP', 'PLN', 'GBP', 'RON', 'RUB', 'SAR', 'CHF', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'VND', ' YEN', 'ZAR', 'Universal'];
                if (isset($_POST['MultiDealercurrency']) && in_array($_POST['MultiDealercurrency'], $allowed_currencies, true)) {
                    update_option('MultiDealercurrency', sanitize_text_field($_POST['MultiDealercurrency']));
                }

                $allowed_measures = ['Miles', 'Kms', 'Hours'];
                if (isset($_POST['multidealer_measure']) && in_array($_POST['multidealer_measure'], $allowed_measures, true)) {
                    update_option('multidealer_measure', sanitize_text_field($_POST['multidealer_measure']));
                }

                $allowed_liters = ['Liters', 'Gallons'];
                if (isset($_POST['multidealer_liter']) && in_array($_POST['multidealer_liter'], $allowed_liters, true)) {
                    update_option('multidealer_liter', sanitize_text_field($_POST['multidealer_liter']));
                }

                $allowed_quantities = ['3', '6', '9', '12', '15', '18'];
                if (isset($_POST['multidealer_quantity']) && in_array($_POST['multidealer_quantity'], $allowed_quantities, true)) {
                    update_option('multidealer_quantity', sanitize_text_field($_POST['multidealer_quantity']));
                }

                $yes_no = ['yes', 'no'];
                if (isset($_POST['multidealer_overwrite_gallery']) && in_array($_POST['multidealer_overwrite_gallery'], $yes_no, true)) {
                    update_option('multidealer_overwrite_gallery', sanitize_text_field($_POST['multidealer_overwrite_gallery']));
                }

                if (isset($_POST['multidealer_googlemapsapi'])) {
                    update_option('multidealer_googlemapsapi', sanitize_text_field($_POST['multidealer_googlemapsapi']));
                }

                if (isset($_POST['multidealer_widget_show_orderby']) && in_array($_POST['multidealer_widget_show_orderby'], $yes_no, true)) {
                    update_option('multidealer_widget_show_orderby', sanitize_text_field($_POST['multidealer_widget_show_orderby']));
                }

                $allowed_sizes = ['300', '350', '400'];
                if (isset($_POST['multidealer_image_size']) && in_array($_POST['multidealer_image_size'], $allowed_sizes, true)) {
                    update_option('multidealer_image_size', sanitize_text_field($_POST['multidealer_image_size']));
                }
                break;

            case 3:
                // Process data from Step 3 (Page Setup).
                $page_title = isset($_POST['multidealer_main_page_name']) ? sanitize_text_field($_POST['multidealer_main_page_name']) : 'Show Room';
                $page_slug = sanitize_title($page_title);

                $existing_page = get_page_by_path($page_slug, OBJECT, 'page');

                if (null === $existing_page) {
                    // Page does not exist, create it.
                    $page_data = [
                        'post_title'    => $page_title,
                        'post_content'  => '[multi_dealer]',
                        'post_status'   => 'publish',
                        'post_author'   => get_current_user_id(),
                        'post_type'     => 'page',
                    ];
                    wp_insert_post($page_data);
                } else {
                    // Page exists, check if shortcode is present.
                    if (!has_shortcode($existing_page->post_content, 'multidealer')) {
                        // Add shortcode to existing page content.
                        $updated_content = $existing_page->post_content . "\n\n" . '[multi_dealer]';
                        $page_data = [
                            'ID'           => $existing_page->ID,
                            'post_content' => $updated_content,
                        ];
                        wp_update_post($page_data);
                    }
                }
                break;

            case 4:
                // Final step: mark as complete and set up redirect.
                update_option('multidealer_setup_complete', true);
                $redirect_url = admin_url('admin.php?page=multi_dealer_plugin');
                wp_send_json_success(['redirect' => esc_url_raw($redirect_url)]);
                break;
        }
    }

    ob_start();
    multidealer_inst_render_step_html($step_to_load);
    $html = ob_get_clean();
    wp_send_json_success(['html' => $html]);
}
add_action('wp_ajax_multidealer_installer_step', 'multidealer_ajax_installer_handler');


/**
 * AJAX handler specifically for importing demo data.
 */
function multidealer_ajax_import_demo_data_handler()
{
    check_ajax_referer('multidealer_import_nonce', 'nonce');

    if (!current_user_can('import')) {
        wp_send_json_error('Error: You do not have permission to import content.', 403);
        return;
    }

    $importer_dir = MULTIDEALERPATH . 'includes/install/step3/';
    $xml_file_path = $importer_dir . 'multi-dealer-demo-data.xml';

    if (!file_exists($xml_file_path)) {
        wp_send_json_error('Error: The demo data file could not be found.');
        return;
    }

    if (!defined('WP_LOAD_IMPORTERS')) {
        define('WP_LOAD_IMPORTERS', true);
    }

    if (!class_exists('WP_Importer')) {
        $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($class_wp_importer)) {
            require_once $class_wp_importer;
        } else {
            wp_send_json_error('Error: WP_Importer class not found.');
            return;
        }
    }

    $wordpress_importer_file = $importer_dir . 'wordpress-importer.php';
    $parsers_file = $importer_dir . 'parsers.php';

    if (file_exists($wordpress_importer_file) && file_exists($parsers_file)) {
        require_once $wordpress_importer_file;
        require_once $parsers_file;
    } else {
        wp_send_json_error('Error: Importer classes not found.');
        return;
    }

    if (!class_exists('WP_Import')) {
        wp_send_json_error('Error: WP_Import class failed to load.');
        return;
    }

    try {
        ob_start();

        $importer = new WP_Import();
        $importer->fetch_attachments = true;
        $importer->import($xml_file_path);

        ob_end_clean(); // Discard the importer's direct output.

        update_option('multidealer_demo_imported', 'true');
        wp_send_json_success('Demo data imported successfully!');
    } catch (Exception $e) {
        ob_end_clean();
        wp_send_json_error('An error occurred during import: ' . esc_html($e->getMessage()));
    }

    wp_die();
}
add_action('wp_ajax_multidealer_import_demo_data', 'multidealer_ajax_import_demo_data_handler');

/**
 * Renders the main installer shell (header and content area).
 */
function multidealer_inst_render_installer()
{
    if (!current_user_can('manage_options')) {
        wp_die('You do not have sufficient permissions to access this page.');
    }
?>
    <div class="multidealer-inst-wrap">
        <header class="multidealer-inst-header">
            <img id="multidealer-inst-logo" alt="MultiDealer Logo" src="<?php echo esc_url(MULTIDEALERIMAGES . 'logosmall.png'); ?>" width="250px" />
            <img id="multidealer-inst-step-indicator" alt="Step Indicator" src="<?php echo esc_url(MULTIDEALERIMAGES . '/header-install-step-1.png'); ?>" />
        </header>
        <main id="multidealer-inst-content-container" class="multidealer-inst-content">
            <div class="multidealer-inst-loader">
                <span class="spinner is-active"></span>
                <p><?php esc_html_e('Loading', 'multidealer'); ?>...</p>
            </div>
        </main>
    </div>
    <?php
}

/**
 * Renders the HTML content for a specific installer step.
 *
 * @param int $step The step number to render.
 */
function multidealer_inst_render_step_html($step = 1)
{
    if ($step < 1 || $step > 4) $step = 1;
    switch ($step):
        case 1:
    ?>
            <h1>1. <?php esc_html_e('Welcome', 'multidealer'); ?></h1>
            <p><?php esc_html_e('Thank you for choosing MultiDealer plugin. Multi Dealer is the easiest way to manage, list and sell your products online.', 'multidealer'); ?></p>
            <p><?php esc_html_e('Please follow steps 1 through 4 to complete the plugin installation. This installer will allow you to install the software more securely, easily, and quickly.', 'multidealer'); ?></p>
            <p>
                <?php
                printf(
                    wp_kses(
                        __('By using our plugins and themes, you agree to the <a href="%s" target="_blank" rel="noopener noreferrer">terms of use</a>.', 'multidealer'),
                        ['a' => ['href' => [], 'target' => [], 'rel' => []]]
                    ),
                    esc_url('https://siterightaway.net/terms-of-use-of-our-plugins-and-themes/')
                );
                ?>
            </p>
            <form id="multidealer-installer-form" data-step="1">
                <div class="multidealer-inst-buttons">
                    <button type="submit" class="multidealer-inst-button multidealer-inst-next"><?php esc_html_e('Next', 'multidealer'); ?></button>
                </div>
            </form>
        <?php
            break;
        case 2:
            // Get current saved values, with defaults.
            $currency          = get_option('MultiDealercurrency', 'USD');
            $measure           = get_option('multidealer_measure', 'Miles');
            $liter_measure     = get_option('multidealer_liter', 'Liters');
            $quantity          = get_option('multidealer_quantity', 9);
            $overwrite_gallery = get_option('multidealer_overwrite_gallery', 'yes');
            $google_api        = get_option('multidealer_googlemapsapi', '');
            $show_orderby      = get_option('multidealer_widget_show_orderby', 'yes');
            $image_size        = get_option('multidealer_image_size', '300');
        ?>
            <h1>2. <?php esc_html_e('Plugin Settings', 'multidealer'); ?></h1>
            <p><?php esc_html_e('Choose your currency, measurement systems, and other basic settings. You can change all of these later in the plugin options page.', 'multidealer'); ?></p>

            <form id="multidealer-installer-form" data-step="2">

                <!-- Currency -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Currency', 'multidealer'); ?></h3>
                    <select name="MultiDealercurrency" id="MultiDealercurrency">
                        <option value="USD" <?php selected($currency, 'USD'); ?>>US Dollars ($)</option>
                        <option value="AED" <?php selected($currency, 'AED'); ?>>United Arab Emirates Dirham (د.إ)</option>
                        <option value="AOA" <?php selected($currency, 'AOA'); ?>>Angolan Kwanza</option>
                        <option value="AFN" <?php selected($currency, 'AFN'); ?>>Afghan Afghani (؋)</option>
                        <option value="ARS" <?php selected($currency, 'ARS'); ?>>Argentine Pesos ($)</option>
                        <option value="AUD" <?php selected($currency, 'AUD'); ?>>Australian Dollars ($)</option>
                        <option value="BRL" <?php selected($currency, 'BRL'); ?>>Brazilian Real (R$)</option>
                        <option value="BGN" <?php selected($currency, 'BGN'); ?>>Bulgarian Lev</option>
                        <option value="CAD" <?php selected($currency, 'CAD'); ?>>Canadian Dollars ($)</option>
                        <option value="CNY" <?php selected($currency, 'CNY'); ?>>Chinese Yuan (¥)</option>
                        <option value="HRK" <?php selected($currency, 'HRK'); ?>>Croatian Kuna</option>
                        <option value="CZK" <?php selected($currency, 'CZK'); ?>>Czech Koruna</option>
                        <option value="DKK" <?php selected($currency, 'DKK'); ?>>Danish Krone</option>
                        <option value="EUR" <?php selected($currency, 'EUR'); ?>>Euros (€)</option>
                        <option value="HKD" <?php selected($currency, 'HKD'); ?>>Hong Kong Dollar ($)</option>
                        <option value="HUF" <?php selected($currency, 'HUF'); ?>>Hungarian Forint</option>
                        <option value="INR" <?php selected($currency, 'INR'); ?>>Indian Rupee (₹)</option>
                        <option value="RIAL" <?php selected($currency, 'RIAL'); ?>>Iranian Rial (﷼)</option>
                        <option value="ILS" <?php selected($currency, 'ILS'); ?>>Israeli Shekel (₪)</option>
                        <option value="JPY" <?php selected($currency, 'JPY'); ?>>Japanese Yen (¥)</option>
                        <option value="KRW" <?php selected($currency, 'KRW'); ?>>South Korean Won (₩)</option>
                        <option value="MYR" <?php selected($currency, 'MYR'); ?>>Malaysian Ringgits</option>
                        <option value="MXN" <?php selected($currency, 'MXN'); ?>>Mexican Peso ($)</option>
                        <option value="NZD" <?php selected($currency, 'NZD'); ?>>New Zealand Dollar ($)</option>
                        <option value="NOK" <?php selected($currency, 'NOK'); ?>>Norwegian Krone</option>
                        <option value="PKR" <?php selected($currency, 'PKR'); ?>>Pakistani Rupee (₨)</option>
                        <option value="PHP" <?php selected($currency, 'PHP'); ?>>Philippine Pesos</option>
                        <option value="PLN" <?php selected($currency, 'PLN'); ?>>Polish Zloty</option>
                        <option value="GBP" <?php selected($currency, 'GBP'); ?>>Pound Sterling (£)</option>
                        <option value="RON" <?php selected($currency, 'RON'); ?>>Romanian Leu</option>
                        <option value="RUB" <?php selected($currency, 'RUB'); ?>>Russian Rubles</option>
                        <option value="SAR" <?php selected($currency, 'SAR'); ?>>Saudi Riyal (﷼)</option>
                        <option value="CHF" <?php selected($currency, 'CHF'); ?>>Swiss Franc</option>
                        <option value="SEK" <?php selected($currency, 'SEK'); ?>>Swedish Krona</option>
                        <option value="SGD" <?php selected($currency, 'SGD'); ?>>Singapore Dollar ($)</option>
                        <option value="THB" <?php selected($currency, 'THB'); ?>>Thai Baht (฿)</option>
                        <option value="TRY" <?php selected($currency, 'TRY'); ?>>Turkish Lira (₺)</option>
                        <option value="TWD" <?php selected($currency, 'TWD'); ?>>Taiwan New Dollars</option>
                        <option value="VND" <?php selected($currency, 'VND'); ?>>Vietnamese Dong (₫)</option>
                        <option value=" YEN" <?php selected($currency, ' YEN'); ?>>Yen (¥)</option>
                        <option value="ZAR" <?php selected($currency, 'ZAR'); ?>>South African Rand</option>
                        <option value="Universal" <?php selected($currency, 'Universal'); ?>>Universal</option>
                    </select>
                </div>

                <!-- Measurement System -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Miles - Km', 'multidealer'); ?></h3>
                    <select name="multidealer_measure" id="multidealer_measure">
                        <option value="Miles" <?php selected($measure, 'Miles'); ?>>Miles</option>
                        <option value="Kms" <?php selected($measure, 'Kms'); ?>>Kms</option>
                        <option value="Hours" <?php selected($measure, 'Hours'); ?>>Hours</option>
                    </select>
                </div>

                <!-- Liquid Measurement -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Liters - Gallons', 'multidealer'); ?></h3>
                    <select name="multidealer_liter" id="multidealer_liter">
                        <option value="Liters" <?php selected($liter_measure, 'Liters'); ?>>Liters</option>
                        <option value="Gallons" <?php selected($liter_measure, 'Gallons'); ?>>Gallons</option>
                    </select>
                </div>

                <!-- Products Per Page -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('How many products would you like to display per page?', 'multidealer'); ?></h3>
                    <select name="multidealer_quantity" id="multidealer_quantity">
                        <option value="3" <?php selected($quantity, '3'); ?>>3</option>
                        <option value="6" <?php selected($quantity, '6'); ?>>6</option>
                        <option value="9" <?php selected($quantity, '9'); ?>>9</option>
                        <option value="12" <?php selected($quantity, '12'); ?>>12</option>
                        <option value="15" <?php selected($quantity, '15'); ?>>15</option>
                        <option value="18" <?php selected($quantity, '18'); ?>>18</option>
                    </select>
                </div>

                <!-- Overwrite Gallery -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Replace the Wordpress Gallery with Flexslider Gallery?', 'multidealer'); ?></h3>
                    <label><input type="radio" name="multidealer_overwrite_gallery" value="yes" <?php checked($overwrite_gallery, 'yes'); ?> /> <?php esc_html_e('Yes', 'multidealer'); ?></label>
                    <label><input type="radio" name="multidealer_overwrite_gallery" value="no" <?php checked($overwrite_gallery, 'no'); ?> /> <?php esc_html_e('No', 'multidealer'); ?></label>
                </div>

                <!-- Google Maps API Key -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Optional. Fill out your Google API to use with yours maps (google maps)', 'multidealer'); ?></h3>
                    <input type="text" name="multidealer_googlemapsapi" id="multidealer_googlemapsapi" value="<?php echo esc_attr($google_api); ?>" class="widefat" />
                </div>

                <!-- Show Order By -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Show the Order By Control in the Search Bar?', 'multidealer'); ?></h3>
                    <label><input type="radio" name="multidealer_widget_show_orderby" value="yes" <?php checked($show_orderby, 'yes'); ?> /> <?php esc_html_e('Yes', 'multidealer'); ?></label>
                    <label><input type="radio" name="multidealer_widget_show_orderby" value="no" <?php checked($show_orderby, 'no'); ?> /> <?php esc_html_e('No', 'multidealer'); ?></label>
                </div>

                <!-- Image Size -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('In Show Room Page, Template List View or Grid, Choose the thumbnail image size (width) - Only Premium:', 'multidealer'); ?></h3>
                    <label><input type="radio" name="multidealer_image_size" value="300" <?php checked($image_size, '300'); ?> /> 300px</label>
                    <label><input type="radio" name="multidealer_image_size" value="350" <?php checked($image_size, '350'); ?> /> 350px</label>
                    <label><input type="radio" name="multidealer_image_size" value="400" <?php checked($image_size, '400'); ?> /> 400px</label>
                </div>

                <div class="multidealer-inst-buttons">
                    <button type="button" class="multidealer-inst-button multidealer-inst-back" data-step="1"><?php esc_html_e('Back', 'multidealer'); ?></button>
                    <button type="submit" class="multidealer-inst-button multidealer-inst-next"><?php esc_html_e('Next', 'multidealer'); ?></button>
                </div>
            </form>
        <?php
            break;
        case 3:
            $demo_imported = get_option('multidealer_demo_imported', 'false');
        ?>
            <h1>3. <?php esc_html_e('Page Setup & Demo Content', 'multidealer'); ?></h1>
            <p><?php esc_html_e('Configure the main page for your vehicle listings and optionally import demo content to get started quickly.', 'multidealer'); ?></p>

            <form id="multidealer-installer-form" data-step="3">

                <!-- Main Page Creation -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Main Page Creation', 'multidealer'); ?></h3>
                    <label for="multidealer_main_page_name"><?php esc_html_e('Choose a name for your main page', 'multidealer'); ?></label>
                    <select name="multidealer_main_page_name" id="multidealer_main_page_name">
                        <option value="Show Room">Show Room</option>
                        <option value="Multi Dealer Show">Multi Dealer Show</option>
                        <option value="Inventory">Inventory</option>
                    </select>
                    <p class="description"><?php esc_html_e('A new page with this title and the [multi_dealer] shortcode will be created. You can change the page name later in your WordPress settings.', 'multidealer'); ?></p>
                </div>

                <!-- Demo Data Import -->
                <div class="multidealer-inst-field">
                    <h3><?php esc_html_e('Demo Data Import', 'multidealer'); ?></h3>
                    <div id="multidealer-importer-section">
                        <?php if ($demo_imported === 'true') : ?>
                            <p class="multidealer-inst-success">✔ <?php esc_html_e('Demo data has already been imported.', 'multidealer'); ?></p>
                        <?php else : ?>
                            <label>
                                <input type="checkbox" id="multidealer-import-checkbox" />
                                <?php esc_html_e('Would you like to import demo data?', 'multidealer'); ?>
                            </label>
                            <div id="multidealer-import-controls" style="display: none; margin-top: 15px;">
                                <button type="button" id="multidealer-import-button" class="button button-secondary">
                                    <?php esc_html_e('Import Demo Data', 'multidealer'); ?>
                                </button>
                                <span class="spinner" style="float: none; vertical-align: middle; margin-left: 10px;"></span>
                                <div id="multidealer-import-feedback" style="margin-top: 10px; color: green;"></div>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>

                <div class="multidealer-inst-buttons">
                    <button type="button" class="multidealer-inst-button multidealer-inst-back" data-step="2"><?php esc_html_e('Back', 'multidealer'); ?></button>
                    <button type="submit" class="multidealer-inst-button multidealer-inst-next"><?php esc_html_e('Next', 'multidealer'); ?></button>
                </div>
            </form>
        <?php
            break;
        case 4:
        ?>
            <form id="multidealer-installer-form" data-step="4">
                <h1>4. <?php esc_html_e('All Done!', 'multidealer'); ?></h1>
                <p><?php esc_html_e("MultiDealer has been successfully configured! You are all set. You can now start adding your products. Don't forget to add the new page to your site's main menu.", 'multidealer'); ?></p>
                <div class="multidealer-inst-buttons">
                    <button type="button" class="multidealer-inst-button multidealer-inst-back" data-step="3"><?php esc_html_e('Back', 'multidealer'); ?></button>
                    <button type="submit" class="multidealer-inst-button multidealer-inst-next"><?php esc_html_e('Go to Multi Dealer Dashboard', 'multidealer'); ?></button>
                </div>
            </form>
<?php
            break;
    endswitch;
}
