<?php

add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' );
add_filter( 'pt-ocdi/regenerate_thumbnails_in_content_import', '__return_false' );

if ( ! function_exists( 'kktfwp_import_files' ) ) :

	function kktfwp_import_files() {
		return array(
			array(
				'import_file_name'             => 'Pioniq Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Pioniq.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/pioniq.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/pioniq.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo6.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo-1/',
			),
			array(
				'import_file_name'             => 'Cremona Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Cremona.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/cremona.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/cremona.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo4.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo-4/',
			),
	 
		   array(
				'import_file_name'             => 'Florrie Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Florrie.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/florrie.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/florrie.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo1.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo/',
			),
			
			array(
				'import_file_name'             => 'Swory Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Swory.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/swory.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/swory.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo2.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo-2/',
			),
			
			array(
				'import_file_name'             => 'Frezo Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Frezo.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/frezo.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/frezo.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo3.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo-3/',
			),
			
			array(
				'import_file_name'             => 'Aminio Demo',
				'import_file_url'              => 'http://easysite.by/temp/toppic/Aminio.xml',
				'import_widget_file_url' 	   => 'http://easysite.by/temp/toppic/aminio.wie',
				'import_customizer_file_url'   => 'http://easysite.by/temp/toppic/aminio.dat',
				'import_preview_image_url'     => 'http://themes.easysite.by/toppic-overview/img/demo5.jpg',
				'import_notice'                => esc_html__( 'Please waiting for a few minutes, do not close the window or refresh the page until the data is imported.', 'toppic' ),
				'preview_url'                  => 'http://themes.easysite.by/toppic-demo-5/',
			),
		);
	}
	add_filter( 'pt-ocdi/import_files', 'kktfwp_import_files' );
	
endif;

if ( ! function_exists( 'kktfwp_after_import' ) ) :

	function kktfwp_after_import( $selected_import ) {
	 
		$demo = $selected_import['import_file_name'];
		
		switch ($demo) {
			case 'Frezo Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
				
			case 'Pioniq Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				$footer_menu = get_term_by( 'name', 'Footer menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id,
					  'footer-menu' => $footer_menu->term_id 
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
				
			case 'Cremona Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				$footer_menu = get_term_by( 'name', 'Footer menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id,
					  'footer-menu' => $footer_menu->term_id 
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
				
			case 'Florrie Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				$footer_menu = get_term_by( 'name', 'Footer menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id,
					  'footer-menu' => $footer_menu->term_id 
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
				
			case 'Swory Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				$footer_menu = get_term_by( 'name', 'Footer menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id,
					  'footer-menu' => $footer_menu->term_id 
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
				
			case 'Aminio Demo':
				//Set Menu
				$top_menu = get_term_by( 'name', 'Main menu', 'nav_menu' );
				set_theme_mod( 'nav_menu_locations' , array( 
					  'main-menu' => $top_menu->term_id,
					 ) 
				);			
				// Assign front page and posts page (blog page).
				$front_page_id = get_page_by_title( 'Home' );
				$blog_page_id  = get_page_by_title( 'Blog' );

				update_option( 'show_on_front', 'page' );
				update_option( 'page_on_front', $front_page_id->ID );
				update_option( 'page_for_posts', $blog_page_id->ID );
				
				break;
		}
		
	}

	add_action( 'pt-ocdi/after_import', 'kktfwp_after_import' );

endif;