<?php
// Do not allow directly accessing this file.
if (! defined('ABSPATH')) {
    exit();
}
// demo import file
function cleeny_import_files() {
    return array(
        array(
            'import_file_name'             =>  esc_html__('Cleeny Demo', 'cleeny'),
            'local_import_file'            =>  DREAMIT_DIR_PATH . 'inc/demo-data/cleeny-demo.xml',
            'local_import_customizer_file' =>  DREAMIT_DIR_PATH . 'inc/demo-data/cleeny_customizer.dat',
            'local_import_widget_file'     =>  DREAMIT_DIR_PATH . 'inc/demo-data/cleeny-widgets-demo.wie',
            'local_import_redux'           => array(
                array(
                    'file_path'   =>   DREAMIT_DIR_PATH . 'inc/demo-data/redux_options_demo.json',
                    'option_name' => 'cleeny_opt',
                ),
            ),
            'import_notice' => esc_html__('Please keep patients while importing sample data.', 'cleeny'),
        ),
    );
}
add_filter('pt-ocdi/import_files', 'cleeny_import_files');

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

    set_theme_mod(
        'nav_menu_locations',
        array(
            'menu-1'    => $main_menu->term_id,
            'one-pages' =>  $main_menu->term_id,
            'menu-3' =>  $main_menu->term_id,
            'menu-4' =>  $main_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 List');

    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', 'cleeny_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 cleeny_import_plugin_page_setup($default_settings) {
    $default_settings['parent_slug'] = 'themes.php';
    $default_settings['page_title']  = esc_html__('Cleeny Demo Import', 'cleeny');
    $default_settings['menu_title']  = esc_html__('Import Demo Data', 'cleeny');
    $default_settings['capability']  = 'import';
    $default_settings['menu_slug']   = 'cleeny-demo-import';

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