<?php

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




// HOME PAGE LAYOUT
$GLOBALS['theme_defaults']['homepage_layout'] = "layout-comparison1";

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Comparison Theme", "title2" => "HTML5 Responsive Comparison Theme", "title3" => "Save $$$ online now with our product comparison website",
"img" =>  get_template_directory_uri()."/templates/template_comparison_theme/img/banner.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."  ),
);

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

// FEEDBACK SYSTEM
$GLOBALS['theme_defaults']['feedback_enable'] = 0;

// GOOGLE
$GLOBALS['theme_defaults']['google'] = 0;
$GLOBALS['theme_defaults']['geolocation'] = 0;

// CONTENT LAYOUT / SINGLE LAYOUT
$GLOBALS['theme_defaults']['content_layout'] = "listing-comparison";
$GLOBALS['theme_defaults']['single_layout'] = "content-listing-comparison";
// TEMPLATE NAME
$GLOBALS['theme_defaults']['template'] 		= "template_comparison_theme"; 
// SET HEADER
$GLOBALS['theme_defaults']['layout_header'] = 1;
// SET MENU
$GLOBALS['theme_defaults']['layout_menu'] = 2;
// SET COLUMNS
$GLOBALS['theme_defaults']['layout_columns'] = array('homepage' => 3, 'search' => '1', 'single' => 1, 'page' => '1', 'footer' => '4', '2columns' => 1, '3columns' => '', 'contentwidth' => 1,
'homepage_2columns' => 2, 'search_2columns' => 2,  'page_2columns' => 2,  'single_2columns' => 2 );
// SET RATING
$GLOBALS['theme_defaults']['rating'] = 1;
$GLOBALS['theme_defaults']['rating_type'] 	= 1;
$GLOBALS['theme_defaults']['rating_as'] 	= 1;
// BREADCRUMBS
$GLOBALS['theme_defaults']['breadcrumbs_inner'] 	= 1;
$GLOBALS['theme_defaults']['breadcrumbs_home'] = 0;
// WELCOME TEXT
$GLOBALS['theme_defaults']['header_welcometext'] 	= "Your own text could go here!";
// TURN ON FAVS
$GLOBALS['theme_defaults']['show_account_favs'] 	= 1;	
// DEFAULT DISPLAY
$GLOBALS['theme_defaults']['display'] 	= array('default_gallery_style' => 'grid');	 
// ADD IN CUSTOM WIDGET BLOCK
$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/slide1.jpg'; 
 	
$GLOBALS['theme_defaults']['widgetobject']["text"]["1"] = array(
	"fullw" => "yes",
	"text" => '
<div id="banner0" class="bannerbox row">			
<div class="col-sm-4">
	<a href="#"><img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b1.jpg" alt="">
		<div class="desc">
		<h1>Mens</h1>
		<h2>Watches</h2>
		</div>
	</a>
</div>
<div class="col-sm-4">
	<a href="#"><img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b2.jpg" alt="">
	<div class="desc">
		<h1>Womens</h1>
		<h2>Watches</h2>
	</div>
	</a>
</div>
<div class="col-sm-4">
	<a href="#"><img src="'.get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/b3.jpg" alt="">
		<div class="desc">
		<h1>Kids</h1>
		<h2>Watches</h2>
		</div>
	</a>
</div>
</div>',			 
);

		$GLOBALS['theme_defaults']['widgetobject']["recentlisting"]["2"] = array(
			"fullw" => "no",
			"title" => "Recently Added Listings",
			"query" => "orderby=rand&posts_per_page=8",
			"style" => "grid",
			"perrow" => "4"
		);
 
		
		$GLOBALS['theme_defaults']['homepage']['widgetblock1'] = 'slider1_0,text_1,recentlisting_2';	



// ITEM CODE
$GLOBALS['theme_defaults']['itemcode'] 		= '[IMAGE][RATING][price]<h2>[TITLE]</h2>[EXCERPT]<hr />[BUTTON]'; 
update_option('wlt_reset_itemcode', $GLOBALS['theme_defaults']['itemcode']);
// LISTING CODE
$GLOBALS['theme_defaults']['listingcode']		= '<div class="block"> <div class="block-content">
<div class="col-md-6">[IMAGE gallery=true] </div>
<div class="col-md-6"><h3>[TITLE-NOLINK]</h3>[EXCERPT size=500 end=...] 
<hr /> [CATEGORY]  [RATING]<hr /> 
 [SOCIAL] 
</div>
<div class="clearfix"></div>
<hr /><ul class="nav nav-tabs navstyle1" id="Tabs">
  <li  class="active"><a href="#t1" data-toggle="tab">{Comparisons}</a></li>
  <li><a href="#t3" data-toggle="tab">{Description}</a></li> 
  <li><a href="#t2" data-toggle="tab">{Details}</a></li>   
   <li><a href="#t5" data-toggle="tab">{Related}</a></li>  
</ul>
<div class="tab-content">
  <div class="tab-pane active" id="t1">
  [COMPARISONTABLE] 
  </div> 
  <div class="tab-pane" id="t3">
  [TOOLBOX]
  <h5>[TITLE]</h5>
  [CONTENT]  
  [GOOGLEMAP] 
  <div class="clearfix"></div>
  </div>
  <div class="tab-pane" id="t2">
  [FIELDS hide="map"]
  </div>
 
  <div class="tab-pane" id="t5">
  [RELATED view=grid]
  <div class="clearfix"></div>
  </div>  
</div>  
</div></div>
[COMMENTS box=1] '; 
update_option('wlt_reset_listingcode', $GLOBALS['theme_defaults']['listingcode']);


// 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));
		}	
	}
}

// ADD 10 NEW STORES
register_taxonomy( 'store', 'cproduct_type', array( 'hierarchical' => true, 'labels' => array('name' => 'Stores') , 'query_var' => true, 'rewrite' => true, 'rewrite' => array('slug' => 'store') ) );  
$storeaa = array();
$i=1;
while($i < 11){
 
	$cat_id = wp_insert_term('Example Store '.$i, 'store', array('cat_name' => 'Example Store '.$i ));
 
	if(!is_object($cat_id) && isset($cat_id['term_id'])){	
		$nparent = $cat_id['term_id'];
	}else{	
		$nparent = $cat_id->term_id;
	}
	$storeaa[] = $nparent;
 	
	$GLOBALS['theme_defaults']['category_icon_'.$nparent] = get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template'].'/img/store'.$i.'.gif';
	$GLOBALS['theme_defaults']['category_website_'.$nparent] = "http://premiumpress.com";
	
$i++;
}




 

$i=1;
while($i < 10){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Compared Item ".$i;
	$my_post['post_content'] 	= "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus eleifend risus ut congue.";
	$my_post['post_type'] 		= "cproduct_type";
	$my_post['post_status'] 	= "publish";
	$my_post['post_category'] 	= "";
	$my_post['tags_input'] 		= "";
	$POSTID 					= wp_insert_post( $my_post );
	
	$COMPAREDIDS[$POSTID] = $POSTID; 
	
	 
	add_post_meta($POSTID, "price", rand(80, 500));
	add_post_meta($POSTID, "buy_url", "http://www.premiumpress.com");
 
	// UPDATE CAT LIST
	if(isset($storeaa[$i])){
	wp_set_post_terms( $POSTID, $storeaa[$i], 'store' );
	}
	$d++;	
	$i++;	
} 




// 6. INSTALL THE SAMPLE DATA LISTINGS 


$g=1;
while($g < 16){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Product ".$g;
	$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 );
	
	$g++;
		

	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, "buy_url", "http://www.premiumpress.com");
	add_post_meta($POSTID, "listing_expiry_date", date('Y-m-d H:i:s', strtotime("+3".$g." days")));	
	
	add_post_meta($POSTID, "related_to", $COMPAREDIDS );
	
	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );
	$d++;	
		
} 


 
} 

?>