<?php
//
//defined( 'DS' ) OR define( 'DS', DIRECTORY_SEPARATOR );
//
//$demo_datas_dir = THIM_DIR . 'inc' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'data';
//
//$demo_datas = array(
//	'demo-01' => array(
//		'data_dir'      => $demo_datas_dir . DS . 'demo-01',
//		'thumbnail_url' => THIM_URI . 'inc/admin/data/demo-01.jpg',
//		'title'         => esc_html__( 'Demo 01', 'cakeart' )
//	)
//);


// disable import demo data in thim-framework
function thim_disable_import_demo() {
	return 'yes';
}

add_filter( 'disable_import_demo', 'thim_disable_import_demo' );


//////////////////////////////////////////////////////////////////
/////////// Import demo data
//////////////////////////////////////////////////////////////////
function cakeart_importer_demo_data() {
	define( 'DATA_DEMO_DIR', trailingslashit( get_template_directory() ) . 'inc/admin/data/' );
	define( 'DATA_DEMO_URL', trailingslashit( get_template_directory_uri() ) . 'inc/admin/data/' );

	return array(
		array(
			'import_file_name'             => 'Demo-01',
			'local_import_file'            => DATA_DEMO_DIR . 'demo-01/demodata.xml',
			'local_import_widget_file'     => DATA_DEMO_DIR . 'demo-01/widgets.wie',
			'local_import_customizer_file' => DATA_DEMO_DIR . 'demo-01/customizer-setting.dat',
			'import_preview_image_url'     => DATA_DEMO_URL . 'demo-01/demo-01.jpg',
		),
	);
}

add_filter( 'pt-ocdi/import_files', 'cakeart_importer_demo_data' );
function cakeart_after_import_setup( $selected_import ) {
	// Assign menus to their locations.
	$main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' );
	set_theme_mod(
		'nav_menu_locations', array(
		'primary' => $main_menu->term_id,
	)
	);
	$front_page_id = get_page_by_title( 'Home' );

 	if ( class_exists( 'RevSlider' ) ) {
		$slider = new RevSlider();
		$slider->importSliderFromPost( true, true, DATA_DEMO_DIR . "revslider/home-01.zip" );
	}

	$blog_page_id = get_page_by_title( 'Blog' );
	$shop_id      = get_page_by_title( 'Shop' );
	$cart_id      = get_page_by_title( 'Cart' );
	$checkout_id  = get_page_by_title( 'Checkout' );
	$account_id   = get_page_by_title( 'My account' );

	update_option( 'show_on_front', 'page' );
	update_option( 'page_on_front', $front_page_id->ID );
	update_option( 'page_for_posts', $blog_page_id->ID );
	update_option( 'woocommerce_shop_page_id', $shop_id->ID );
	update_option( 'woocommerce_cart_page_id', $cart_id->ID );
	update_option( 'woocommerce_checkout_page_id', $checkout_id->ID );
	update_option( 'woocommerce_myaccount_page_id', $account_id->ID );
}

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

function ocdi_plugin_page_setup( $default_settings ) {
	$default_settings['menu_slug'] = 'cakeart-onclick-demo-import';

	return $default_settings;
}

add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );
add_filter( 'pt-ocdi/disable_pt_branding', 'pt_ocdi_disable_pt_branding' );
function pt_ocdi_disable_pt_branding() {
	return true;
}