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

        // If the demo import is completed, display the "View Site" button
        if ($hr_management_consultancy_demo_import_completed) {
            echo '<p class="notice-text">' . esc_html__('Your demo import has been completed successfully.', 'hr-management-consultancy') . '</p>';
            echo '<span><a href="' . esc_url(home_url()) . '" class="button button-primary site-btn" target="_blank">' . esc_html__('View Site', 'hr-management-consultancy') . '</a></span>';
            echo '<span><a href="'. esc_url(admin_url('customize.php') ) .'" class="button button-primary demo-btn" target=_blank>'. esc_html__( 'Customize Your Site', 'hr-management-consultancy' ) .'</a></span>';
            echo '<span><a href="'. esc_url( 'https://preview.vwthemesdemo.com/docs/free-hr-management-consultancy/' ) .'" class="button button-primary doc-btn" target=_blank>'. esc_html__( 'Free Theme Documentation', 'hr-management-consultancy' ) .'</a></span>';
        }

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

            // Check if woocommerce is installed and activated
            if (!is_plugin_active('woocommerce/woocommerce.php')) {
              // Install the plugin if it doesn't exist
                $plugin_slug = 'woocommerce';
                $hr_management_consultancy_plugin_file = 'woocommerce/woocommerce.php';

              // Check if plugin is installed
              $hr_management_consultancy_installed_plugins = get_plugins();
              if (!isset($hr_management_consultancy_installed_plugins[$hr_management_consultancy_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
                  $hr_management_consultancy_upgrader = new Plugin_Upgrader();
                  $hr_management_consultancy_upgrader->install('https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip');
              }
              // Activate the plugin
              activate_plugin($hr_management_consultancy_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
              $hr_management_consultancy_plugin_slug = 'ibtana-visual-editor';
              $hr_management_consultancy_plugin_file = 'ibtana-visual-editor/plugin.php';

              // Check if plugin is installed
              $hr_management_consultancy_installed_plugins = get_plugins();
              if (!isset($hr_management_consultancy_installed_plugins[$hr_management_consultancy_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
                  $hr_management_consultancy_upgrader = new Plugin_Upgrader();
                  $hr_management_consultancy_upgrader->install('https://downloads.wordpress.org/plugin/ibtana-visual-editor.latest-stable.zip');
              }
              // Activate the plugin
              activate_plugin($hr_management_consultancy_plugin_file);
            }

            // ------- Create Nav Menu --------
            $hr_management_consultancy_menuname = 'Main Menus';
            $hr_management_consultancy_bpmenulocation = 'primary';
            $hr_management_consultancy_menu_exists = wp_get_nav_menu_object($hr_management_consultancy_menuname);

            if (!$hr_management_consultancy_menu_exists) {
                $hr_management_consultancy_menu_id = wp_create_nav_menu($hr_management_consultancy_menuname);

                // Create Home Page
                $hr_management_consultancy_home_title = 'Home';
                $hr_management_consultancy_home = array(
                    'post_type' => 'page',
                    'post_title' => $hr_management_consultancy_home_title,
                    'post_content' => '',
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_slug' => 'home'
                );
                $hr_management_consultancy_home_id = wp_insert_post($hr_management_consultancy_home);
                // Assign Home Page Template
                add_post_meta($hr_management_consultancy_home_id, '_wp_page_template', 'page-template/custom-home-page.php');
                // Update options to set Home Page as the front page
                update_option('page_on_front', $hr_management_consultancy_home_id);
                update_option('show_on_front', 'page');
                // Add Home Page to Menu
                wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title' => __('Home', 'hr-management-consultancy'),
                    'menu-item-classes' => 'home',
                    'menu-item-url' => home_url('/'),
                    'menu-item-status' => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_home_id,
                    'menu-item-object' => 'page',
                    'menu-item-type' => 'post_type'
                ));

                // Create Pages Page with Dummy Content
                $hr_management_consultancy_pages_title = 'Pages';
                $hr_management_consultancy_pages_content = '
                <p>Explore all the pages we have on our website. Find information about our services, company, and more.</p>

                 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> 

                  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.';
                $hr_management_consultancy_pages = array(
                    'post_type' => 'page',
                    'post_title' => $hr_management_consultancy_pages_title,
                    'post_content' => $hr_management_consultancy_pages_content,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_slug' => 'pages'
                );
                $hr_management_consultancy_pages_id = wp_insert_post($hr_management_consultancy_pages);
                // Add Pages Page to Menu
                wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title' => __('Pages', 'hr-management-consultancy'),
                    'menu-item-classes' => 'pages',
                    'menu-item-url' => home_url('/pages/'),
                    'menu-item-status' => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_pages_id,
                    'menu-item-object' => 'page',
                    'menu-item-type' => 'post_type'
                ));

                // Create Find Jobs Page with Dummy Content
                $hr_management_consultancy_about_title = 'Find Jobs';
                $hr_management_consultancy_about_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.';
                $hr_management_consultancy_about = array(
                    'post_type' => 'page',
                    'post_title' => $hr_management_consultancy_about_title,
                    'post_content' => $hr_management_consultancy_about_content,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_slug' => 'find-jobs'
                );
                $hr_management_consultancy_about_id = wp_insert_post($hr_management_consultancy_about);
                // Add Find Jobs Page to Menu
                wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title' => __('Find Jobs', 'hr-management-consultancy'),
                    'menu-item-classes' => 'find-jobs',
                    'menu-item-url' => home_url('/find-jobs/'),
                    'menu-item-status' => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_about_id,
                    'menu-item-object' => 'page',
                    'menu-item-type' => 'post_type'
                ));

                // Create Employer Page with Dummy Content
                $hr_management_consultancy_about_title = 'Employer';
                $hr_management_consultancy_about_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.';
                $hr_management_consultancy_about = array(
                    'post_type' => 'page',
                    'post_title' => $hr_management_consultancy_about_title,
                    'post_content' => $hr_management_consultancy_about_content,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_slug' => 'employer'
                );
                $hr_management_consultancy_about_id = wp_insert_post($hr_management_consultancy_about);
                // Add Employer Page to Menu
                wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title' => __('Employer', 'hr-management-consultancy'),
                    'menu-item-classes' => 'employer',
                    'menu-item-url' => home_url('/employer/'),
                    'menu-item-status' => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_about_id,
                    'menu-item-object' => 'page',
                    'menu-item-type' => 'post_type'
                ));

                // Create Candidates Page with Dummy Content
                $hr_management_consultancy_about_title = 'Candidates';
                $hr_management_consultancy_about_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.';
                $hr_management_consultancy_about = array(
                    'post_type' => 'page',
                    'post_title' => $hr_management_consultancy_about_title,
                    'post_content' => $hr_management_consultancy_about_content,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_slug' => 'candidates'
                );
                $hr_management_consultancy_about_id = wp_insert_post($hr_management_consultancy_about);
                // Add Candidates Page to Menu
                wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title' => __('Candidates', 'hr-management-consultancy'),
                    'menu-item-classes' => 'candidates',
                    'menu-item-url' => home_url('/candidates/'),
                    'menu-item-status' => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_about_id,
                    'menu-item-object' => 'page',
                    'menu-item-type' => 'post_type'
                ));
                
               // Create Blog Page 
                $hr_management_consultancy_blog_page_title = 'Blog';

                $hr_management_consultancy_blog_page_query = new WP_Query(array(
                    'post_type' => 'page',
                    'title' => $hr_management_consultancy_blog_page_title,
                    'post_status' => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$hr_management_consultancy_blog_page_query->have_posts()) {
                    $hr_management_consultancy_blog_page = array(
                    'post_type'   => 'page',
                    'post_title'  => $hr_management_consultancy_blog_page_title,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    );
                   $hr_management_consultancy_blog_page_id = wp_insert_post($hr_management_consultancy_blog_page);
                    update_option('page_for_posts', $hr_management_consultancy_blog_page_id);
                    wp_update_nav_menu_item($hr_management_consultancy_menu_id, 0, array(
                    'menu-item-title'   => __('Blog', 'hr-management-consultancy'),
                    'menu-item-url'     => home_url('/blog/'),
                    'menu-item-status'  => 'publish',
                    'menu-item-object-id' => $hr_management_consultancy_blog_page_id,
                    'menu-item-object'  => 'page',
                    'menu-item-type'    => 'post_type',
                ));
                }

                // Set the menu location if it's not already set
                if (!has_nav_menu($hr_management_consultancy_bpmenulocation)) {
                    $locations = get_theme_mod('nav_menu_locations'); // Use 'nav_menu_locations' to get locations array
                    if (empty($locations)) {
                        $locations = array();
                    }
                    $locations[$hr_management_consultancy_bpmenulocation] = $hr_management_consultancy_menu_id;
                    set_theme_mod('nav_menu_locations', $locations);
                }               
            }

           
            // Set the demo import completion flag
    		update_option('hr_management_consultancy_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.', 'hr-management-consultancy') . '</p>';
    		echo '<span><a href="' . esc_url(home_url()) . '" class="button button-primary site-btn" target="_blank">' . esc_html__('View Site', 'hr-management-consultancy') . '</a></span>';
            echo '<span><a href="'. esc_url(admin_url('customize.php') ) .'" class="button button-primary demo-btn" target=_blank>'. esc_html__( 'Customize Your Site', 'hr-management-consultancy' ) .'</a></span>';
            echo '<span><a href="'. esc_url( 'https://preview.vwthemesdemo.com/docs/free-hr-management-consultancy/' ) .'" class="button button-primary doc-btn" target=_blank>'. esc_html__( 'Free Theme Documentation', 'hr-management-consultancy' ) .'</a></span>';
            //end 


            // Top Bar //
            set_theme_mod( 'hr_management_consultancy_topbar_btn_text', 'Latest Opening' );  
            set_theme_mod( 'hr_management_consultancy_topbar_btn_link', '#' ); 
            set_theme_mod( 'hr_management_consultancy_myaccount_icon', 'fas fa-user' );  

            // slider section start // 
            set_theme_mod( 'hr_management_consultancy_slider_button_text', 'Search Jobs' );
            set_theme_mod( 'hr_management_consultancy_slider_button_url', '#' );
            
            for($hr_management_consultancy_i=1;$hr_management_consultancy_i<=4;$hr_management_consultancy_i++){
               $hr_management_consultancy_slider_title = 'Find A Peffect Candidate';
               $hr_management_consultancy_slider_content = 'Find jobs Employment & Career Opportunities.';
                  // Create post object
               $my_post = array(
               'post_title'    => wp_strip_all_tags( $hr_management_consultancy_slider_title ),
               'post_content'  => $hr_management_consultancy_slider_content,
               'post_status'   => 'publish',
               'post_type'     => 'page',
               );

               // Insert the post into the database
               $hr_management_consultancy_post_id = wp_insert_post( $my_post );

               if ($hr_management_consultancy_post_id) {
                 // Set the theme mod for the slider page
                 set_theme_mod('hr_management_consultancy_slider_page' . $hr_management_consultancy_i, $hr_management_consultancy_post_id);

                  $hr_management_consultancy_image_url = get_template_directory_uri().'/assets/images/slider'.$hr_management_consultancy_i.'.png';

                $hr_management_consultancy_image_id = media_sideload_image($hr_management_consultancy_image_url, $hr_management_consultancy_post_id, null, 'id');

                    if (!is_wp_error($hr_management_consultancy_image_id)) {
                        // Set the downloaded image as the post's featured image
                        set_post_thumbnail($hr_management_consultancy_post_id, $hr_management_consultancy_image_id);
                    }
                }
            }    
            

            // Popular Job Section //
            set_theme_mod( 'hr_management_consultancy_popular_heading', 'Most Popular Job' );
            set_theme_mod( 'hr_management_consultancy_popular_small_title', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry' );
            set_theme_mod('hr_management_consultancy_popular_category', 'postcategory1');
            set_theme_mod('hr_management_consultancy_brouse_btn_text', 'Browse All');
            set_theme_mod('hr_management_consultancy_brouse_btn_link', '#');

            // Define post category names and post titles
            $hr_management_consultancy_category_names = array('postcategory1', 'postcategory2');
            $hr_management_consultancy_title_array = array(
                array("General Ledger Accountant", "Finance Manager & Health"),
                array("Finance Manager & Health", "General Ledger Accountant")
            );

            foreach ($hr_management_consultancy_category_names as $hr_management_consultancy_index => $hr_management_consultancy_category_name) {
                // Create or retrieve the post category term ID
                $hr_management_consultancy_term = term_exists($hr_management_consultancy_category_name, 'category');
                if ($hr_management_consultancy_term === 0 || $hr_management_consultancy_term === null) {
                    // If the term does not exist, create it
                    $hr_management_consultancy_term = wp_insert_term($hr_management_consultancy_category_name, 'category');
                }
                if (is_wp_error($hr_management_consultancy_term)) {
                    error_log('Error creating category: ' . $hr_management_consultancy_term->get_error_message());
                    continue; // Skip to the next iteration if category creation fails
                }

                for ($hr_management_consultancy_i = 0; $hr_management_consultancy_i < 2; $hr_management_consultancy_i++) {
                    // Create post content
                    
                    $hr_management_consultancy_title = $hr_management_consultancy_title_array[$hr_management_consultancy_index][$hr_management_consultancy_i];

                    // Create post post object
                    $hr_management_consultancy_my_post = array(
                        'post_title'    => wp_strip_all_tags($hr_management_consultancy_title),
                        'post_status'   => 'publish',
                        'post_type'     => 'post', // Post type set to 'post'
                    );

                    // Insert the post into the database
                    $hr_management_consultancy_post_id = wp_insert_post($hr_management_consultancy_my_post);

                    update_post_meta($hr_management_consultancy_post_id, 'hr_management_consultancy_marketing', "Marketing");
                    update_post_meta($hr_management_consultancy_post_id, 'hr_management_consultancy_location', "Pune");
                    update_post_meta($hr_management_consultancy_post_id, 'hr_management_consultancy_price', "$120-$140");
                    update_post_meta($hr_management_consultancy_post_id, 'hr_management_consultancy_feature1', "Full Time");
                    update_post_meta($hr_management_consultancy_post_id, 'hr_management_consultancy_feature2', "Urgent");

                    if (is_wp_error($hr_management_consultancy_post_id)) {
                        error_log('Error creating post: ' . $hr_management_consultancy_post_id->get_error_message());
                        continue; // Skip to the next post if creation fails
                    }

                    // Assign the category to the post
                    wp_set_post_categories($hr_management_consultancy_post_id, array((int)$hr_management_consultancy_term['term_id']));

                    // Handle the featured image using media_sideload_image
                    $hr_management_consultancy_image_url = get_template_directory_uri() . '/assets/images/job' . ($hr_management_consultancy_i + 1) . '.png';
                    $hr_management_consultancy_image_id = media_sideload_image($hr_management_consultancy_image_url, $hr_management_consultancy_post_id, null, 'id');

                    if (is_wp_error($hr_management_consultancy_image_id)) {
                        error_log('Error downloading image: ' . $hr_management_consultancy_image_id->get_error_message());
                        continue; // Skip to the next post if image download fails
                    }
                    // Assign featured image to post
                    set_post_thumbnail($hr_management_consultancy_post_id, $hr_management_consultancy_image_id);
                }
            }  
                echo "<script>window.location.href='" . admin_url('themes.php?page=hr_management_consultancy_guide') . "';</script>"; 
                //Copyright Text
                set_theme_mod( 'hr_management_consultancy_footer_text', 'By VWThemes' );  
        
        }
    ?>

    <form action="<?php echo esc_url(home_url()); ?>/wp-admin/themes.php?page=hr_management_consultancy_guide" method="POST" onsubmit="return validate(this);">
        <?php if (!get_option('hr_management_consultancy_demo_import_completed')) : ?>
            <form method="post">
                <p class="run-import-text"><?php esc_html_e('Click On The Below Run Importer Button To Import Demo Content Of HR Management Consultancy','hr-management-consultancy'); ?></p>
                <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 HR Management Consultancy', 'hr-management-consultancy'); ?></p>
                <input class="run-import" type="submit" name="submit" value="<?php esc_attr_e('Run Importer', 'hr-management-consultancy'); ?>" class="button button-primary button-large">
            </form>    
        <?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?")) {
                document.getElementById('spinner').style.display = 'block';
                return true;
            } 
            else {
                return false;
            }
        }
    </script>
</div>

