/*
Theme Name: Avada Child
Description: Child theme for Avada theme
Author: ThemeFusion
Author URI: https://theme-fusion.com
Template: Avada
Version: 1.0.0
Text Domain:  Avada
*/

function custom_excel_upload_form() {
    ?>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="excel_file" accept=".xls,.xlsx">
        <input type="submit" name="upload_excel" value="Upload Excel">
    </form>
    <?php
    if (isset($_POST['upload_excel']) && !empty($_FILES['excel_file'])) {
        $uploaded_file = wp_handle_upload($_FILES['excel_file'], array('test_form' => false));
        if ($uploaded_file && !isset($uploaded_file['error'])) {
            echo "File uploaded successfully!";
            // Process the file (Read Excel)
            custom_process_excel_file($uploaded_file['file']);
        } else {
            echo "Error uploading file: " . $uploaded_file['error'];
        }
    }
}
add_action('admin_menu', function () {
    add_menu_page('Upload Excel', 'Upload Excel', 'manage_options', 'upload_excel', 'custom_excel_upload_form');
});
