<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

/**
* Init demo import for OCDI work with Merlin
*
* @since Campoal 1.0.0
*/
function conikal_import_demo_files() {
  $import_notice = esc_html__( 'Be sure all required and recommend plugins is installed before import demo. After imported demo, all your settings and customization before will be overwritten.', 'campoal' );

  return array(
    array(
      'import_file_name'             => 'Peach Demo',
      'categories'                   => array( 'Platform' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/peace/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/peace/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/peace/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/peace/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/peace/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/',
    ),
    array(
      'import_file_name'             => 'Movement Demo',
      'categories'                   => array( 'Platform' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/movement/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/movement/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/movement/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/movement/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/movement/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/movement/',
    ),
    array(
      'import_file_name'             => 'Young Demo',
      'categories'                   => array( 'Platform' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/young/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/young/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/young/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/young/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/young/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/young/',
    ),
    array(
      'import_file_name'             => 'Green Demo',
      'categories'                   => array( 'Platform' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/green/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/green/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/green/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/green/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/green/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/green/',
    ),
    array(
      'import_file_name'             => 'Simple Demo',
      'categories'                   => array( 'Platform' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/simple/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/simple/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/simple/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/simple/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/simple/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/simple/',
    ),
    array(
      'import_file_name'             => 'Foundation Demo',
      'categories'                   => array( 'Foundation' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/foundation/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/foundation/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/foundation/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/foundation/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/foundation/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/foundation/',
    ),
    array(
      'import_file_name'             => 'Single Campaign Demo',
      'categories'                   => array( 'One Page' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/single/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/single/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/single/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/single/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/single/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/single/',
    ),
    array(
      'import_file_name'             => 'Right to Left Demo',
      'categories'                   => array( 'Right to Left' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'inc/demo/rtl/content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'inc/demo/rtl/widgets.wie',
      'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'inc/demo/rtl/customizer.dat',
      'local_import_redux'           => array(
        array(
          'file_path'   => trailingslashit( get_template_directory() ) . 'inc/demo/rtl/redux.json',
          'option_name' => 'campoal_options',
        ),
      ),
      'import_preview_image_url'     => trailingslashit( get_template_directory_uri() ) . 'inc/demo/rtl/preview.png',
      'import_notice'                => $import_notice,
      //'preview_url'                  => '//campoal.com/single/',
    ),
  );
}
add_filter( 'pt-ocdi/import_files', 'conikal_import_demo_files' );


/**
* Assign menus and front page after imported
*
* @since Campoal 1.0.0
*/
function conikal_after_import_setup() {
    // Assign menus to their locations.
    $top_menu       = get_term_by( 'name', 'Top Menu', 'nav_menu' );
    $primary_menu   = get_term_by( 'name', 'Primary Menu', 'nav_menu' );
    $category_menu  = get_term_by( 'name', 'Category Menu', 'nav_menu' );
    $footer_menu    = get_term_by( 'name', 'Footer Menu', 'nav_menu' );
    $mobile_menu    = get_term_by( 'name', 'Mobile Menu', 'nav_menu' );

    set_theme_mod( 'nav_menu_locations', array(
          'top_menu'    => $top_menu->term_id,
          'primary'     => $primary_menu->term_id,
          'category'    => $category_menu->term_id,
          'footer'      => $footer_menu->term_id,
          'mobile'      => $mobile_menu->term_id,
        )
    );

    // Assign front page and posts page (blog page).
    $front_page_id = get_page_by_title( 'Homepage' );
    $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', 'conikal_after_import_setup' );


/**
* Disable one click demo import brand
*
* @since Campoal 1.2.4
*/
add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' );
?>
