<?php

add_action('hook_new_install','_newinstall');
function _newinstall(){ global $CORE, $wpdb;


// 4. DEFAULT TEMPLATE DATA
$GLOBALS['theme_defaults']['template'] 		= "template_shop_theme";
// HOME PAGE LAYOUT
$GLOBALS['theme_defaults']['homepage_layout'] = "layout-shop1";

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array(

	"title1" => "Shopping Cart Theme", 
	"title2" => "HTML5 Responsive Shoopping Cart Theme", 
	"title3" => "This is a clean, simple and easy to use shopping cart theme for WordPress. All you have todo is install and add your products.",

		"stxt1" => "Your Text Here",
		"stxt2" => "Your Text Here",
		"stxt3" => "Your Text Here",
		
		"sdesc1" => "your sub description here",
		"sdesc2" => "your sub description here",
		"sdesc3" => "your sub description here",
		
		"img" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/banner.jpg', 		
		"img1" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b1.jpg', 
		"img2" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b2.jpg',  
		"img3" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b3.jpg', 

 ),


"t1" => array("title1" => "Your Amazing Title Text Here", "title2" => "You can customize this area and enter your own title text via the admin area of the theme."  ),
"t2" => array("title1" => "Your Amazing Title Text Here", "title2" => "You can customize this area and enter your own title text via the admin area of the theme."  ),


	"t3" => array(
		"img1" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/c1.jpg', 
		"img2" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/c2.jpg',  
		"img3" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/c3.jpg', 
	),
); 

 

// WEBSITE LOGO
$GLOBALS['theme_defaults']['logo_text1'] 	= "Website Logo";
$GLOBALS['theme_defaults']['logo_text2'] 	= "Your company slogan";
$GLOBALS['theme_defaults']['logo_icon'] 	= "2";


$GLOBALS['theme_defaults']['shop_languagedropdown'] = 1;
$GLOBALS['theme_defaults']['shop_currencydropdown'] = 1;
 
// BREADCRUMBS
$GLOBALS['theme_defaults']['breadcrumbs_inner'] 	= 2;
$GLOBALS['theme_defaults']['breadcrumbs_home'] 		= 0;
		

// SET HEADER
$GLOBALS['theme_defaults']['layout_menu'] = 2;
$GLOBALS['theme_defaults']['layout_header'] = 6;


// HOME PAGE
$GLOBALS['theme_defaults']['widgetobject']["slider1"][0] 	= array(
		"fullw" => "yes",
); 
$GLOBALS['theme_defaults']['home']['slider_item_1'] = get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/demo/slide.jpg';


$GLOBALS['theme_defaults']['widgetobject']["new3"][1] 	= array(
		"text" => '<section><div class="wlt_object_head_3">
<div class="row">
<ul>

    <li class="col-xs-3">
    <a href="#" class="item-link">
    <img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/demo/b1.jpg" alt="" class="wltatt_id" >
    <div class="item-html">
    <h2><span>WINTER HAT COLLECTION</span></h2>
    </div>
    </a>
    </li>
    
    <li class="col-xs-3">
    <a href="#" class="item-link">
    <img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/demo/b2.jpg" alt="" class="wltatt_id">
    <div class="item-html">
    <h2><span>SUIT AND TIE SPECIALS</span></h2>
    </div>
    </a>
    </li>
    
    <li class="col-xs-3">
    <a href="#" class="item-link">
    <img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/demo/b3.jpg" alt="" class="wltatt_id">
    <div class="item-html">
    <h2><span>FOOTWEAR COLLECTION</span></h2>
    </div>
    </a>
    </li>
    
    <li class="col-xs-3">
    <a href="#" class="item-link">
    <img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/demo/b4.jpg" alt="" class="wltatt_id">
    <div class="item-html">
    <h2><span>JEANS AND MORE JEANS!</span></h2>
    </div>
    </a>
    </li>
 
</ul>
</div></div>
</section>',
		 
		"fullw" => "yes",
	
); 

$GLOBALS['theme_defaults']['widgetobject']["tabs"][2] 	= array(
		"title1" => "Featured Products",
		"query1" => "&order=asc&posts_per_page=8",
		"title2" => "Recently Added",
		"query2" => "&order=desc",
		"fullw" => "yes",
	
); 
$GLOBALS['theme_defaults']['homepage'] 		= array("widgetblock1"=>"slider1_0,new3_1,tabs_2");

// CONTENT LAYOUT / SINGLE LAYOUT
$GLOBALS['theme_defaults']['content_layout'] = "listing-shop";
$GLOBALS['theme_defaults']['single_layout'] = "content-listing-shop";



$GLOBALS['theme_defaults']['display'] 			= array('default_gallery_style' => 'grid');


$GLOBALS['theme_defaults']['layout_columns'] 	= array('style' => 'fixed',  '2columns' => '1', 'homepage' => 3, 'search' => 2, 'single' => 2, 'page' => 2, 'search_2columns' => 2, 'homepage_2columns' => 2,   'page_2columns' => 2,  'single_2columns' => 2);
 
$GLOBALS['theme_defaults']['itemcode'] 		= '[IMAGE]
<div class="caption">
<h2>[TITLE]</h2>
[EXCERPT]            
<hr />
<div class="col-xs-6 col-md-5 lead">[price]</div>
<div class="col-xs-6 col-md-2"> [ADD] </div>
</div>';
update_option('wlt_reset_itemcode', $GLOBALS['theme_defaults']['itemcode']);
 
$GLOBALS['theme_defaults']['listingcode']		= '<div class="panel panel-default"><div class="panel-body"><h1>[TITLE-NOLINK]</h1>
<hr />
<div class="row">
<div class="col-md-6">[IMAGES]</div>        
<div class="col-md-6"> [EXCERPT] <hr /> [ADDBIG]</div></div>
<hr />
<ul class="nav nav-tabs navstyle1" id="Tabs">
  <li class="active"><a href="#t1" data-toggle="tab">Product Description</a></li>
  <li><a href="#t4" data-toggle="tab">Comments</a></li>
</ul> 
<div class="tab-content">
  <div class="tab-pane active" id="t1">
  [TOOLBOX]
  [CONTENT]  
  [GOOGLEMAP] 
  </div>
  <div class="tab-pane" id="t4"><br />
  [COMMENTS] 
  </div>  
</div> 
</div> </div> 
<h4>Related Products</h4><div class="clearfix"></div><hr>
[RELATED carousel=true]'; 
update_option('wlt_reset_listingcode', $GLOBALS['theme_defaults']['listingcode']);


$GLOBALS['theme_defaults']['menucategoryicon'] = 1;
 
// 5. REINSTALL THE SAMPLE DATA CATEGORIES 
 
$new_cat_array = array(
	"Example Category 1" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 2" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 2" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 3" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 4" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 5" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 6" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 7" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 8" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 9" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 10" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
	"Example Category 11" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
 	"Example Category 12" => array ('Sub Cat 1','Sub Cat 2', 'Sub Cat 3'),
);

$saved_cats_array = array(); $ff=1;
foreach($new_cat_array as $cat=>$catlist){
	if ( is_term( $cat , THEME_TAXONOMY ) ){	
		$term = get_term_by('slug', $cat, THEME_TAXONOMY);		 
		$nparent  = $term->term_id;
		$saved_cats_array[] = $term->term_id;	
	}else{
	
		$cat_id = wp_insert_term($cat, THEME_TAXONOMY, array('cat_name' => $cat ));
 
		if(!is_object($cat_id) && isset($cat_id['term_id'])){
		$saved_cats_array[] = $cat_id['term_id'];
		$nparent = $cat_id['term_id'];
		}else{
		$saved_cats_array[] = $cat_id->term_id;
		$nparent = $cat_id->term_id;
		}
		$ff++; 
	}
	
	// add in icon for this cat		
	$GLOBALS['theme_defaults']['category_icon_'.$nparent] = get_template_directory_uri()."/framework/img/demo/noimage.png";
	
	/* SUB CATS */
	if(is_array($catlist)){
		foreach($catlist as $newcat){
		wp_insert_term($newcat, THEME_TAXONOMY, array('cat_name' => $newcat,'parent' => $nparent));
		}	
	}
}
 
$i=1;
while($i < 16){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Product ".$i;
	$my_post['post_content'] 	= "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue. Pellentesque nec lacus elit. Pellentesque convallis nisi ac augue pharetra eu tristique neque consequat. Mauris ornare tempor nulla, vel sagittis diam convallis eget.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue. Pellentesque nec lacus elit. Pellentesque convallis nisi ac augue pharetra eu tristique neque consequat. Mauris ornare tempor nulla, vel sagittis diam convallis eget.</p><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p><small>Someone famous <cite title='Source Title'>Source Title</cite></small>
</blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue. Pellentesque nec lacus elit. Pellentesque convallis nisi ac augue pharetra eu tristique neque consequat. Mauris ornare tempor nulla, vel sagittis diam convallis eget.</p><dl class='dl-horizontal'>
				<dt>Description lists</dt>
				<dd>A description list is perfect for defining terms.</dd>
				<dt>Euismod</dt>
				<dd>Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.</dd>
				<dd>Donec id elit non mi porta gravida at eget metus.</dd>
				<dt>Malesuada porta</dt>
				<dd>Etiam porta sem malesuada magna mollis euismod.</dd>
				<dt>Felis euismod semper eget lacinia</dt>
				<dd>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</dd>
			  </dl>";
	$my_post['post_type'] 		= THEME_TAXONOMY."_type";
	$my_post['post_status'] 	= "publish";
	$my_post['post_category'] 	= "";
	$my_post['tags_input'] 		= "";
	$POSTID 					= wp_insert_post( $my_post );	
	
	add_post_meta($POSTID, "image", get_template_directory_uri()."/framework/img/demo/noimage.png");
	add_post_meta($POSTID, "price", rand(80, 500));
	add_post_meta($POSTID, "qty", rand(0, 10));
	if($i > 10){
	add_post_meta($POSTID, "featured", "yes");
	}
	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );
	$i++;		
} 
 
} 

?>