<?php 
	if(isset($_GET['import-demo']) && $_GET['import-demo'] == true){
		// ------- Create Nav Menu --------
		$transport_solutions_menuname ='Main Menus';
	    $transport_solutions_bpmenulocation = 'main-menu';
	    $transport_solutions_menu_exists = wp_get_nav_menu_object( $transport_solutions_menuname );
	    if( !$transport_solutions_menu_exists){
	        $transport_solutions_menu_id = wp_create_nav_menu($transport_solutions_menuname);
	        $transport_solutions_home_parent = wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
				'menu-item-title' =>  __('Home','transport-solutions'),
				'menu-item-classes' => 'home',
				'menu-item-url' =>home_url( '/' ),
				'menu-item-status' => 'publish')
			);

			wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('Services','transport-solutions'),
	            'menu-item-classes' => 'services',
	            'menu-item-url' => home_url( '//services/' ),
	            'menu-item-status' => 'publish'));

	        wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('Vehicle Fleet','transport-solutions'),
	            'menu-item-classes' => 'vehicle-fleet',
	            'menu-item-url' => home_url( '//vehicle-fleet/' ), 
	            'menu-item-status' => 'publish'));

			wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('Company','transport-solutions'),
	            'menu-item-classes' => 'company',
	            'menu-item-url' => home_url( '//company/' ), 
	            'menu-item-status' => 'publish'));

			wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('News','transport-solutions'),
	            'menu-item-classes' => 'news',
	            'menu-item-url' => home_url( '//news/' ), 
	            'menu-item-status' => 'publish'));

			wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('Resources','transport-solutions'),
	            'menu-item-classes' => 'resources',
	            'menu-item-url' => home_url( '//resources/' ), 
	            'menu-item-status' => 'publish'));

			wp_update_nav_menu_item($transport_solutions_menu_id, 0, array(
	            'menu-item-title' =>  __('Contact','transport-solutions'),
	            'menu-item-classes' => 'contact',
	            'menu-item-url' => home_url( '//contact/' ), 
	            'menu-item-status' => 'publish'));
	        
			if( !has_nav_menu( $transport_solutions_bpmenulocation ) ){
	            $locations = get_theme_mod('nav_menu_locations');
	            $locations[$transport_solutions_bpmenulocation] = $transport_solutions_menu_id;
	            set_theme_mod( 'nav_menu_locations', $locations );
	        }
	    }
	    $transport_solutions_home_id='';
		$transport_solutions_home_content = '';
		$transport_solutions_home_title = 'Home';
		$home = array(
			'post_type' => 'page',
			'post_title' => $transport_solutions_home_title,
			'post_content' => $transport_solutions_home_content,
			'post_status' => 'publish',
			'post_author' => 1,
			'post_slug' => 'home'
		);
		$transport_solutions_home_id = wp_insert_post($home);
	    
		add_post_meta( $transport_solutions_home_id, '_wp_page_template', 'frontpage.php' );

		update_option( 'page_on_front', $transport_solutions_home_id );
		update_option( 'show_on_front', 'page' );

		//---Header--//

		set_theme_mod( 'transport_solutions_top_header_text', 'Transport Itd. inc. 300 US - Los Angeles');

		set_theme_mod('transport_solutions_social_links_settings', array(
            array(
                "link_text" => "fab fa-facebook-f",
                "link_url" => "#"
            ),
            array(
                "link_text" => "fab fa-twitter",
                "link_url" => "#"
            ),
            array(
                "link_text" => "fab fa-linkedin",
                "link_url" => "#"
            ),
            array(
                "link_text" => "fab fa-youtube",
                "link_url" => "#"
            ),
            array(
                "link_text" => "fab fa-instagram",
                "link_url" => "#"
            )
        ));

        set_theme_mod( 'transport_solutions_top_header_text', 'Transport Itd. inc. 300 US - Los Angeles');

        set_theme_mod( 'transport_solutions_header_button_text', 'Track Your Order');

        set_theme_mod( 'transport_solutions_header_button_url', '#');

        set_theme_mod( 'transport_solutions_header_phone_number', 'Call Us: +12-345-678-90');

        set_theme_mod( 'transport_solutions_header_email_address', 'Send Us Email: info@detail.com');

        set_theme_mod( 'transport_solutions_header_open_timings', 'Sun to Sat Timings: 8:00 am-8:00 pm');

		//-----Slider-----//

		set_theme_mod( 'transport_solutions_blog_box_enable', true);

		set_theme_mod( 'transport_solutions_blog_slide_number', '3' );
		$transport_solutions_latest_post_category = wp_create_category('Slider Post');
			set_theme_mod( 'transport_solutions_blog_slide_category', 'Slider Post' );

			set_theme_mod( 'transport_solutions_slider_button_2_link', '#' );

			set_theme_mod( 'transport_solutions_slider_button_text', 'Get a Quote' );

		for($i=1; $i<=3; $i++) {

			$slider_title=array('World wide Transport within 24 Hours', 'Global Delivery in Just 24 Hours', 'Worldwide Shipping in Under 24 Hours');

			$content = 'Representative logistics operator providing full range of service in the sphere of customs clearance and transportation worldwide.';

			// Create post object
			$transport_solutions_my_post = array(
				'post_title'    => wp_strip_all_tags( $slider_title[$i-1] ),
				'post_content'  => $content,
				'post_status'   => 'publish',
				'post_type'     => 'post',
				'post_category' => array($transport_solutions_latest_post_category) 
			);

			// Insert the post into the database
			$transport_solutions_post_id = wp_insert_post( $transport_solutions_my_post );

			$transport_solutions_image_url = get_template_directory_uri().'/assets/images/slider'.$i.'.png';

			$transport_solutions_image_name= 'slider'.$i.'.png';
			$transport_solutions_upload_dir       = wp_upload_dir(); 
			// Set upload folder
			$transport_solutions_image_data       = file_get_contents($transport_solutions_image_url); 
			 
			// Get image data
			$transport_solutions_unique_file_name = wp_unique_filename( $transport_solutions_upload_dir['path'], $transport_solutions_image_name ); 
			// Generate unique name
			$filename= basename( $transport_solutions_unique_file_name ); 
			// Create image file name
			// Check folder permission and define file location
			if( wp_mkdir_p( $transport_solutions_upload_dir['path'] ) ) {
				$file = $transport_solutions_upload_dir['path'] . '/' . $filename;
			} else {
				$file = $transport_solutions_upload_dir['basedir'] . '/' . $filename;
			}
			file_put_contents( $file, $transport_solutions_image_data );
			$wp_filetype = wp_check_filetype( $filename, null );
			$transport_solutions_attachment = array(
				'post_mime_type' => $wp_filetype['type'],
				'post_title'     => sanitize_file_name( $filename ),
				'post_content'   => '',
				'post_type'     => 'post',
				'post_status'    => 'inherit'
			);
			$attach_id = wp_insert_attachment( $transport_solutions_attachment, $file, $transport_solutions_post_id );
			require_once(ABSPATH . 'wp-admin/includes/image.php');
			$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
				wp_update_attachment_metadata( $attach_id, $attach_data );
				set_post_thumbnail( $transport_solutions_post_id, $attach_id );
		}

		// //-----Services Section-----//


		set_theme_mod( 'transport_solutions_services_box_enable', true);

		set_theme_mod( 'transport_solutions_services_number', '4' );
		$transport_solutions_latest_post_category_1 = wp_create_category('Services');
			set_theme_mod( 'transport_solutions_services_category', 'Services' );

			set_theme_mod( 'transport_solutions_services_button_text', 'Learn More');

		for($i=1; $i<=4; $i++) {

			$title=array('Movers and Packers', 'Air Freight', 'Ocean Freight', 'Wearhousing Services');

			$service_content = 'Our Air Freight service is fastest moving. Our global logistics expertise, advanced supply chain technology & customized logistics solutions will help you analyze.';

			// Create post object
			$transport_solutions_my_post_1 = array(
				'post_title'    => wp_strip_all_tags( $title[$i-1] ),
				'post_content'  => $service_content,
				'post_status'   => 'publish',
				'post_type'     => 'post',
				'post_category' => array($transport_solutions_latest_post_category_1) 
			);

			// Insert the post into the database
			$transport_solutions_post_id_1 = wp_insert_post( $transport_solutions_my_post_1 );

			$transport_solutions_image_url = get_template_directory_uri().'/assets/images/service'.$i.'.png';

			$transport_solutions_image_name_1= 'service'.$i.'.png';

			$transport_solutions_upload_dir_1       = wp_upload_dir(); 
			// Set upload folder
			$transport_solutions_image_data_1       = file_get_contents($transport_solutions_image_url); 
			 
			// Get image data
			$transport_solutions_unique_file_name_1 = wp_unique_filename( $transport_solutions_upload_dir_1['path'], $transport_solutions_image_name_1 ); 
			// Generate unique name
			$filename= basename( $transport_solutions_unique_file_name_1 ); 
			// Create image file name
			// Check folder permission and define file location
			if( wp_mkdir_p( $transport_solutions_upload_dir_1['path'] ) ) {
				$file = $transport_solutions_upload_dir_1['path'] . '/' . $filename;
			} else {
				$file = $transport_solutions_upload_dir_1['basedir'] . '/' . $filename;
			}
			file_put_contents( $file, $transport_solutions_image_data_1 );
			$wp_filetype = wp_check_filetype( $filename, null );
			$transport_solutions_attachment_1 = array(
				'post_mime_type' => $wp_filetype['type'],
				'post_title'     => sanitize_file_name( $filename ),
				'post_content'   => '',
				'post_type'     => 'post',
				'post_status'    => 'inherit'
			);
			$attach_id = wp_insert_attachment( $transport_solutions_attachment_1, $file, $transport_solutions_post_id_1 );
			require_once(ABSPATH . 'wp-admin/includes/image.php');
			$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
				wp_update_attachment_metadata( $attach_id, $attach_data );
				set_post_thumbnail( $transport_solutions_post_id_1, $attach_id );
		}
	}
?>