<div class="theme-offer">
	<?php 
        // Check if the demo import has been completed
        $vw_coaching_institute_demo_import_completed = get_option('vw_coaching_institute_demo_import_completed', false);

        // If the demo import is completed, display the "View Site" button
        if ($vw_coaching_institute_demo_import_completed) {
        echo '<p class="notice-text">' . esc_html__('Your demo import has been completed successfully.', 'vw-coaching-institute') . '</p>';
        echo '<span><a href="' . esc_url(home_url()) . '" class="button button-primary site-btn" target="_blank">' . esc_html__('View Site', 'vw-coaching-institute') . '</a></span>';
        }

		// POST and update the customizer and other related data
        if (isset($_POST['submit'])) {

        // Check if kk Star Ratings is installed and activated
        if (!is_plugin_active('kk-star-ratings/index.php')) {
            include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
            include_once(ABSPATH . 'wp-admin/includes/file.php');
            include_once(ABSPATH . 'wp-admin/includes/misc.php');
            include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
            include_once(ABSPATH . 'wp-admin/includes/plugin.php');

            // Define plugin variables
            $vw_coaching_institute_plugin_slug = 'kk-star-ratings';
            $vw_coaching_institute_plugin_file = 'kk-star-ratings/index.php';
            $vw_coaching_institute_plugin_url = 'https://downloads.wordpress.org/plugin/kk-star-ratings.latest-stable.zip';

            // Check if the plugin is installed
            $vw_coaching_institute_installed_plugins = get_plugins();
            if (!isset($vw_coaching_institute_installed_plugins[$vw_coaching_institute_plugin_file])) {
                // Install the plugin
                $vw_coaching_institute_upgrader = new Plugin_Upgrader();
                $vw_coaching_institute_upgrader->install($vw_coaching_institute_plugin_url);
            }

            // Check again if the plugin is installed and then activate it
            if (isset($vw_coaching_institute_installed_plugins[$vw_coaching_institute_plugin_file])) {
                activate_plugin($vw_coaching_institute_plugin_file);
            }
        }

        // Check if ibtana visual editor is installed and activated
        if (!is_plugin_active('ibtana-visual-editor/plugin.php')) {
          // Install the plugin if it doesn't exist
          $vw_coaching_institute_plugin_slug = 'ibtana-visual-editor';
          $vw_coaching_institute_plugin_file = 'ibtana-visual-editor/plugin.php';

          // Check if plugin is installed
          $vw_coaching_institute_installed_plugins = get_plugins();
          if (!isset($vw_coaching_institute_installed_plugins[$vw_coaching_institute_plugin_file])) {
              include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
              include_once(ABSPATH . 'wp-admin/includes/file.php');
              include_once(ABSPATH . 'wp-admin/includes/misc.php');
              include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');

              // Install the plugin
              $vw_coaching_institute_upgrader = new Plugin_Upgrader();
              $vw_coaching_institute_upgrader->install('https://downloads.wordpress.org/plugin/ibtana-visual-editor.latest-stable.zip');
          }
          // Activate the plugin
          activate_plugin($vw_coaching_institute_plugin_file);
        }
        
        // Create a front page and assign the template
        $vw_coaching_institute_home_page = null;
        // Using WP_Query instead of get_page_by_title()
        $vw_coaching_institute_home_query = new WP_Query(array(
           'post_type' => 'page',
           'title' => 'Home',
           'post_status' => 'publish',
           'posts_per_page' => 1
        ));
        if (!$vw_coaching_institute_home_query->have_posts()) {
           $vw_coaching_institute_home_title = 'Home';           
           // Create the page
           $vw_coaching_institute_home = array(
               'post_type' => 'page',
               'post_title' => $vw_coaching_institute_home_title,
               'post_status' => 'publish',
               'post_author' => 1,
               'post_slug' => 'home'
           );
           $vw_coaching_institute_home_id = wp_insert_post($vw_coaching_institute_home);
        } else {
           $vw_coaching_institute_home_page = $vw_coaching_institute_home_query->posts[0];
           $vw_coaching_institute_home_id = $vw_coaching_institute_home_page->ID;
        }

        // Set the home page template
        add_post_meta($vw_coaching_institute_home_id, '_wp_page_template', 'page-template/custom-home-page.php');

        // Set the static front page
        update_option('page_on_front', $vw_coaching_institute_home_id);
        update_option('show_on_front', 'page');

        // Create another page if needed
        $vw_coaching_institute_page_query = new WP_Query(array(
           'post_type' => 'page',
           'title' => 'About Us',
           'post_status' => 'publish',
           'posts_per_page' => 1
        ));

        if (!$vw_coaching_institute_page_query->have_posts()) {
           $vw_coaching_institute_page_title = 'About Us';
           $vw_coaching_institute_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...<br>

             Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960 with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br> 

                There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text.<br> 

                All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.';
           
            $vw_coaching_institute_page = array(
               'post_type' => 'page',
               'post_title' => $vw_coaching_institute_page_title,
               'post_content' => $vw_coaching_institute_content,
               'post_status' => 'publish',
               'post_author' => 1,
               'post_slug' => 'page'
            );
            $vw_coaching_institute_page_id = wp_insert_post($vw_coaching_institute_page);
        }

        // Create another page if needed
        $vw_coaching_institute_page_query = new WP_Query(array(
           'post_type' => 'page',
           'title' => 'Courses',
           'post_status' => 'publish',
           'posts_per_page' => 1
        ));

        if (!$vw_coaching_institute_page_query->have_posts()) {
           $vw_coaching_institute_page_title = 'Courses';
           $vw_coaching_institute_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...<br>

             Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960 with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br> 

                There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text.<br> 

                All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.';
           
            $vw_coaching_institute_page = array(
               'post_type' => 'page',
               'post_title' => $vw_coaching_institute_page_title,
               'post_content' => $vw_coaching_institute_content,
               'post_status' => 'publish',
               'post_author' => 1,
               'post_slug' => 'page'
            );
            $vw_coaching_institute_page_id = wp_insert_post($vw_coaching_institute_page);
        }
        
        // Create another page if needed
        $vw_coaching_institute_page_query = new WP_Query(array(
        'post_type' => 'page',
        'title' => 'Page',
        'post_status' => 'publish',
        'posts_per_page' => 1
        ));

        if (!$vw_coaching_institute_page_query->have_posts()) {
        $vw_coaching_institute_page_title = 'Page';
        $vw_coaching_institute_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...<br>

            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960 with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br> 

                There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text.<br> 

                All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.';
        
            $vw_coaching_institute_page = array(
            'post_type' => 'page',
            'post_title' => $vw_coaching_institute_page_title,
            'post_content' => $vw_coaching_institute_content,
            'post_status' => 'publish',
            'post_author' => 1,
            'post_slug' => 'page'
            );
            $vw_coaching_institute_page_id = wp_insert_post($vw_coaching_institute_page);
        }

        // Create Blog Page (Posts Page)
        $vw_coaching_institute_blog_title = 'Blog';
        $vw_coaching_institute_blog = array(
        'post_type'     => 'page',
        'post_title'    => $vw_coaching_institute_blog_title,
        'post_name'     => 'blog',
        'post_status'   => 'publish',
        'post_author'   => 1
        );
        $vw_coaching_institute_blog_id = wp_insert_post($vw_coaching_institute_blog);
        // Set Blog page as posts page
        update_option('page_for_posts', $vw_coaching_institute_blog_id);
        wp_update_nav_menu_item($vw_coaching_institute_menu_id, 0, array(
        'menu-item-title'     => __('Blog', 'vw-coaching-institute'),
        'menu-item-object-id' => $vw_coaching_institute_blog_id,
        'menu-item-object'    => 'page',
        'menu-item-type'      => 'post_type',
        'menu-item-status'    => 'publish'
        ));
        
        // Set the demo import completion flag
		update_option('vw_coaching_institute_demo_import_completed', true);
		// Display success message and "View Site" button
		echo '<p class="notice-text">' . esc_html__('Your demo import has been completed successfully.', 'vw-coaching-institute') . '</p>';
		echo '<span><a href="' . esc_url(home_url()) . '" class="button button-primary site-btn" target="_blank">' . esc_html__('View Site', 'vw-coaching-institute') . '</a></span>';
        //end 

        // Topbar
        set_theme_mod('vw_coaching_institute_topbar_section_hide_show',true);
        set_theme_mod( 'vw_coaching_institute_phone_icon', 'fa-solid fa-phone' );
        set_theme_mod( 'vw_coaching_institute_phone_number', '(123) 456-7890' );
        set_theme_mod( 'vw_coaching_institute_email_address_icon', 'fa-solid fa-envelope-open-text' );
        set_theme_mod( 'vw_coaching_institute_email_address', 'xyz123@example.com' );
        set_theme_mod( 'vw_coaching_institute_topbar_location_icon', 'fa-solid fa-location-dot' );
        set_theme_mod( 'vw_coaching_institute_topbar_location_text', '317 Sports road, Buffalo, NY 92648' );
        set_theme_mod( 'vw_coaching_institute_track_locatin_url', '#' );
        set_theme_mod( 'vw_coaching_institute_topbar_time_icon', 'fa-solid fa-clock' );
        set_theme_mod( 'vw_coaching_institute_topbar_time_text', 'Monday To Saturday 09.00AM To 05.00PM' );

        // Left Banner Settings
        set_theme_mod('vw_coaching_institute_show_hide_banner',true);
        set_theme_mod( 'vw_coaching_institute_subheading', 'Learn New Things Daily' );
        set_theme_mod( 'vw_coaching_institute_tagline_title', 'VW Education Perfect Place For Your Education Next Level' );
        set_theme_mod( 'vw_coaching_institute_designation_text', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type.' );
        set_theme_mod( 'vw_coaching_institute_banner_button_label', 'View Course' );
        set_theme_mod( 'vw_coaching_institute_top_button_url', '#' );
        set_theme_mod( 'vw_coaching_institute_banner_button_label1', 'Explore More' );
        set_theme_mod( 'vw_coaching_institute_top_button_url1', '#' );

        // Right Banner Settings
        set_theme_mod( 'vw_coaching_institute_about_icon', 'fa-solid fa-chalkboard-user' );
        set_theme_mod( 'vw_coaching_institute_about_title', 'Professional Mentor' );
        set_theme_mod( 'vw_coaching_institute_about_text', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text' );
        set_theme_mod( 'vw_coaching_institute_about_icon1', 'fa-solid fa-person-chalkboard' );
        set_theme_mod( 'vw_coaching_institute_about_title1', 'Offline & Online' );
        set_theme_mod( 'vw_coaching_institute_about_text1', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text' );
        set_theme_mod( 'vw_coaching_institute_add_image', get_template_directory_uri().'/assets/images/user1.png' );
        set_theme_mod( 'vw_coaching_institute_review_image', get_template_directory_uri().'/assets/images/user2.png' );
        set_theme_mod( 'vw_coaching_institute_review_img_title', '2k Reviews' );
        set_theme_mod( 'vw_coaching_institute_review_img_text', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.' );
        set_theme_mod( 'vw_coaching_institute_user_image', get_template_directory_uri().'/assets/images/profile-img.png' );
         
        for ($vw_coaching_institute_j = 1; $vw_coaching_institute_j <= 2; $vw_coaching_institute_j++) {
            if ($vw_coaching_institute_j === 1) {
                set_theme_mod('vw_coaching_institute_review_icon' . $vw_coaching_institute_j, 'fa-solid fa-award');
                set_theme_mod('vw_coaching_institute_review' . $vw_coaching_institute_j, '234+');
                set_theme_mod('vw_coaching_institute_review_text' . $vw_coaching_institute_j, 'Certified Students');
            } elseif ($vw_coaching_institute_j === 2) {
                set_theme_mod('vw_coaching_institute_review_icon' . $vw_coaching_institute_j, 'fa-solid fa-graduation-cap');
                set_theme_mod('vw_coaching_institute_review' . $vw_coaching_institute_j, '234 +');
                set_theme_mod('vw_coaching_institute_review_text' . $vw_coaching_institute_j, 'Academic Programs');
            }
        }

        // Courses Section
        set_theme_mod('vw_coaching_institute_courses_section_hide_show',true);
        set_theme_mod( 'vw_coaching_institute_courses_section_text', 'Courses' );
        set_theme_mod( 'vw_coaching_institute_courses_section_title', 'We Offer The Best Carrier' );
        set_theme_mod( 'vw_coaching_institute_courses_button_label', 'Explore More' );
        set_theme_mod( 'vw_coaching_institute_courses_button_url', '#' );

        set_theme_mod( 'vw_coaching_institute_claases_number', '3' );

        // select Post Box
        $vw_coaching_institute_title_array = array("The Complete HTML & CSS Bootcamp 2024 Edition", "The Complete HTML & CSS Bootcamp 2024 Edition", "The Complete HTML & CSS Bootcamp 2024 Edition");
        for ($vw_coaching_institute_i = 1; $vw_coaching_institute_i <= 3; $vw_coaching_institute_i++) {
          set_theme_mod( 'vw_coaching_institute_sale_price'.$vw_coaching_institute_i, '$90.00' );
          set_theme_mod( 'vw_coaching_institute_regular_price'.$vw_coaching_institute_i, '$100.00' );
          set_theme_mod( 'vw_coaching_institute_author_image'.$vw_coaching_institute_i, get_template_directory_uri().'/assets/images/author-img.png' );
          set_theme_mod( 'vw_coaching_institute_service_button_label'.$vw_coaching_institute_i, 'Enroll Now' );
            // Create post
            $vw_coaching_institute_title = $vw_coaching_institute_title_array[$vw_coaching_institute_i - 1];
            $vw_coaching_institute_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting.';            
            $vw_coaching_institute_my_post = array(
                 'post_title'   => wp_strip_all_tags($vw_coaching_institute_title),
                 'post_content' => $vw_coaching_institute_content,
                 'post_status'  => 'publish',
                 'post_type'    => 'post',
            );
            $vw_coaching_institute_post_id = wp_insert_post($vw_coaching_institute_my_post);
            set_theme_mod('vw_coaching_institute_services_category' . $vw_coaching_institute_i, $vw_coaching_institute_post_id);
            // Get image URL
            $vw_coaching_institute_image_url = get_template_directory_uri() . '/assets/images/post' . $vw_coaching_institute_i . '.png';
            $vw_coaching_institute_image_data = wp_remote_get($vw_coaching_institute_image_url);
            if (!is_wp_error($vw_coaching_institute_image_data)) {
                 $vw_coaching_institute_image_body = wp_remote_retrieve_body($vw_coaching_institute_image_data);
                 $vw_coaching_institute_upload_dir = wp_upload_dir();
                 $vw_coaching_institute_image_name = 'post' . $vw_coaching_institute_i . '.png';
                 $uploaded_file = wp_upload_bits($vw_coaching_institute_image_name, null, $vw_coaching_institute_image_body);
                 if (!$uploaded_file['error']) {
                     // Set attachment data
                     $attachment = array(
                         'post_mime_type' => $uploaded_file['type'],
                         'post_title'     => sanitize_file_name($vw_coaching_institute_image_name),
                         'post_content'   => '',
                         'post_status'    => 'inherit',
                     );
                     $vw_coaching_institute_attach_id = wp_insert_attachment($attachment, $uploaded_file['file'], $vw_coaching_institute_post_id);
                     require_once(ABSPATH . 'wp-admin/includes/image.php');
                     $vw_coaching_institute_attach_data = wp_generate_attachment_metadata($vw_coaching_institute_attach_id, $uploaded_file['file']);
                     wp_update_attachment_metadata($vw_coaching_institute_attach_id, $vw_coaching_institute_attach_data);
                     set_post_thumbnail($vw_coaching_institute_post_id, $vw_coaching_institute_attach_id);
                 }
            }
        } 

        //Copyright Text
        set_theme_mod( 'vw_coaching_institute_footer_text', 'By VWThemes' );  
 
        }
    ?>
  
	<p><?php esc_html_e('Please back up your website if it’s already live with data. This importer will overwrite your existing settings with the new customizer values for VW Coaching Institute', 'vw-coaching-institute'); ?></p>
    <form action="<?php echo esc_url(home_url()); ?>/wp-admin/themes.php?page=vw_coaching_institute_guide" method="POST" onsubmit="return validate(this);">
        <?php if (!get_option('vw_coaching_institute_demo_import_completed')) : ?>
            <input class="run-import" type="submit" name="submit" value="<?php esc_attr_e('Run Importer', 'vw-coaching-institute'); ?>" class="button button-primary button-large">
        <?php endif; ?>
        <div id="spinner" style="display:none;">         
            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/spinner.png" alt="" />
        </div>
    </form>
    <script type="text/javascript">
        function validate(form) {
            if (confirm("Do you really want to import the theme demo content?")) {
                // Show the spinner
                document.getElementById('spinner').style.display = 'block';
                // Allow the form to be submitted
                return true;
            } 
            else {
                return false;
            }
        }
    </script>
</div>
