<?php 
include_once 'Framework.php';
class Dummy extends Framework {
        
    public function select() {
        return get_option('anps_dummy');
    }
    
    public function save() {        
        $date = explode("/",date("Y/m"));
        $dummy_xml = "dummy1";
        if(isset($_POST['dummy1'])) {
            $dummy_xml = "dummy1";
            $menu_style = "2";
            $media_info = array(
                'logo' => 'http://anpsthemes.com/kataleya/restaurant/wp-content/uploads/2014/07/logo_head_big1.png'
            );
        } elseif(isset($_POST['dummy2'])) {
            $dummy_xml = "dummy2";
            $menu_style = "2";
            $media_info = array(
                'logo' => 'http://anpsthemes.com/kataleya/restaurant/wp-content/uploads/2014/07/logo_head_big1.png'
            );
        } elseif(isset($_POST['dummy3'])) {
            $dummy_xml = "dummy3";
            $menu_style = "3";
            $media_info = array(
                'logo' => 'http://anpsthemes.com/kataleya/coffee-shop/wp-content/uploads/2014/07/logo-head-big-dark.png',
                'secondary_logo' => 'http://anpsthemes.com/kataleya/coffee-shop/wp-content/uploads/2014/07/logo_sticky1.png',
                'sticky_logo' => 'http://anpsthemes.com/kataleya/coffee-shop/wp-content/uploads/2014/07/logo_sticky1.png'
            );
        } elseif(isset($_POST['dummy4'])) {
            $dummy_xml = "dummy4";
            $menu_style = "2";
            $media_info = array(
                'logo' => 'http://anpsthemes.com/kataleya/restaurant/wp-content/uploads/2014/07/logo_head_big1.png'
            );
        } elseif(isset($_POST['dummy5'])) {
            $dummy_xml = "dummy5";
            $menu_style = "4";
            $media_info = array(
                'logo' => 'http://anpsthemes.com/kataleya/pub/wp-content/uploads/2014/11/logo-head-big-dark21.png',
                'secondary_logo' => 'http://anpsthemes.com/kataleya/pub/wp-content/uploads/2014/11/logo_footer_big2.png',
                'sticky_logo' => 'http://anpsthemes.com/kataleya/pub/wp-content/uploads/2014/11/logo-head-big-dark21.png'
            );
        }

        /* Insert social media informations */
        $social_info = array(
            'google_analytics'=>'UA-YOUR CODE'
        );
                
        update_option($this->prefix.'social_info', $social_info);
        update_option($this->prefix.'media_info', $media_info);
        
        if($dummy_xml=="dummy4") {
            $shop_arr = array(
                "shop_columns" => 3,
                "shop_per_page" => 6,
                "shop_related_per_page" => 3,
                "shop_category" => "on"
            );
            update_option($this->prefix.'shop_setup', $shop_arr);
        }
        
        if($dummy_xml=="dummy3" || $dummy_xml=="dummy4" || $dummy_xml=="dummy5") {
            update_option("anps_order_disable", "on");
        }
        
        /* set dummy to 1 */
        update_option('anps_dummy', 1);
        /* Import dummy xml */
        include_once 'importer/wordpress-importer.php';
        $parse = new WP_Import();
        $parse->import(TEMPLATEPATH . "/anps-framework/classes/importer/$dummy_xml.xml");
        global $wp_rewrite;
        $error_id = get_page_by_title("404 Page")->ID;
        $first_id = get_page_by_title("Home")->ID;
        $arr = array(
            'sticky_menu' => "on",
            'footer_disable' => "on",
            'copyright_footer' => "2",
            'menu_style' => $menu_style,
            'error_page'=>$error_id
            );
        
        update_option($this->prefix.'page_setup', $arr); 
        update_option('page_on_front', $first_id);                                
        update_option('show_on_front', 'page'); 
        update_option('permalink_structure', '/%postname%/'); 
        $wp_rewrite->set_permalink_structure('/%postname%/');    
        $wp_rewrite->flush_rules();
        
        /* Set menu as primary */
	$menu_id = wp_get_nav_menus();
        $locations = get_theme_mod('nav_menu_locations');
        $locations['primary'] = $menu_id[0]->term_id;
        set_theme_mod('nav_menu_locations', $locations);
        update_option('menu_check', true);

    }
}
$dummy = new Dummy();