<?php
// Do not allow directly accessing this file.
if (!defined('ABSPATH')) {
	exit();
}
/**
 * @Packge    : daltech
 * @version   : 1.0
 * @Author    : Daltech
 * @Author URI: https://themeforest.net/user/ModinaTheme/portfolio
 */

// demo import file
function daltech_import_files()
{


	return array(
		array(
			'import_file_name'             => esc_html__('Daltech Demo', 'daltech'),
			'import_file_url'            =>  'https://modinatheme.com/daltech/demo/daltech_content.xml',
			'import_widget_file_url'     =>  'https://modinatheme.com/daltech/demo/daltech_widget.wie',
			'local_import_redux'           => array(
				array(
					'file_path'   => trailingslashit(get_template_directory()) . '/inc/demo-data/redux_options_demo.json',
					'option_name' => 'daltech_opt',
				),
			),
		),
	);
}
add_filter('pt-ocdi/import_files', 'daltech_import_files');

// demo import setup
function daltech_after_import_setup()
{
	// Assign menus to their locations.
	$main_menu   = get_term_by('name', 'Primary Menu', 'nav_menu');

	set_theme_mod(
		'nav_menu_locations',
		array(
			'primary-menu'   	=> $main_menu->term_id,
		)
	);

	// Assign front page and posts page (blog page).
	$front_page_id 	= get_page_by_title('Home One');
	$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);
}
add_action('pt-ocdi/after_import', 'daltech_after_import_setup');


//disable the branding notice after successful demo import
add_filter('pt-ocdi/disable_pt_branding', '__return_true');

//change the location, title and other parameters of the plugin page
function daltech_import_plugin_page_setup($default_settings)
{
	$default_settings['parent_slug'] = 'themes.php';
	$default_settings['page_title']  = esc_html__('Daltech Demo Import', 'daltech');
	$default_settings['menu_title']  = esc_html__('Import Demo Data', 'daltech');
	$default_settings['capability']  = 'import';
	$default_settings['menu_slug']   = 'daltech-demo-import';

	return $default_settings;
}
add_filter('pt-ocdi/plugin_page_setup', 'daltech_import_plugin_page_setup');

// Enqueue scripts
function daltech_demo_import_custom_scripts()
{
	if (isset($_GET['page']) && $_GET['page'] == 'daltech-demo-import') {
		// style
		wp_enqueue_style('daltech-demo-import', DALTECH_DEMO_DIR_URI . 'css/daltech.demo.import.css', array(), '1.0', false);
	}
}
add_action('admin_enqueue_scripts', 'daltech_demo_import_custom_scripts');
