<?php

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

 
$GLOBALS['theme_defaults']['coupon'] = array('code_link' => 'link', 'code_key' => 'code');

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

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

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

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

// LAYOUT
$GLOBALS['theme_defaults']["layout_columns"] = array('homepage' => 0, 'search' => 1, 'single' => 1, 'page' => 1, 'footer' => 5, '2columns' => '0', 'style' => 'fluid', '3columns' => '', 'contentwidth' => 1,
'homepage_2columns' => 0, 'search_2columns' => 0,  'page_2columns' => 0,  'single_2columns' => 0);

$GLOBALS['theme_defaults']['layout_footer'] = 5;

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Coupon Theme", "title2" => "Affiliate Coupon Websites in Minutes!", "title3" => "This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.", ),
"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."  ),

);

// SET HEADER
$GLOBALS['theme_defaults']['layout_header'] = 4;
$GLOBALS['theme_defaults']['addthis'] = 0;

// SET MENU
$GLOBALS['theme_defaults']['layout_menu'] = 3;
// 4. DEFAULT TEMPLATE DATA
$GLOBALS['theme_defaults']['template'] 		= "template_coupon_theme";
// RATING
$GLOBALS['theme_defaults']['rating_type'] = "3a";
 
 
		// ADD IN CUSTOM WIDGET BLOCK
$GLOBALS['theme_defaults']['widgetobject']["text"]["0"] = array(
			"fullw" => "yes",
			"text" =>  "
			<img src='".get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/icon1.png' class='right mainimg hidden-xs' alt='img' />
			<div style='padding-left:15px;padding-right:15px;'>			 
			<h1>Welcome to our coupon website!</h1>
			<h2>Great savings all year round!</h2>
			<h4>We provide a collection of the latest coupon and offers helping you make great savings online.</h4>
			<p>Below are a collection of our most popular stores;</p>
			</div>		
			<div class='clearfix'></div>	
			[STORES limit=12 perrow=6 icon=yes]"		
		); 
$GLOBALS['theme_defaults']['widgetobject']["recentlisting"]["1"] 	= array(
		"style" => "list",
		"title" => "Latest Coupons", 
		"fullw" => "no",
);
$GLOBALS['theme_defaults']['homepage'] 		= array("widgetblock1" => "text_0,recentlisting_1");

 

$GLOBALS['theme_defaults']['itemcode'] 		= "<div class='frame1'>[IMAGE link=0] <div class='desc'>[STORE text='more from ']</div> </div>
<h1>[TITLE-NOLINK]</h1>
<div class='hidden_details'>
<i class='fa fa-clock-o'></i> Expires in [COUPON_END]
<hr>
 [EXCERPT]</div> 
<div class='clearfix'></div>
<div class='highlight' >
<div class='col-md-4 hidden-sm hidden-xs'>
<div class='row'> [RATING] </div>
</div>
<div class='col-md-5 hidden-sm hidden-xs'>
<i class='fa fa-check-square-o'></i> used [hits] times   <i class='fa fa-comments'></i> [COMMENT_AJAX]
</div>
<div class='col-md-3 col-sm-3'>[CBUTTON]</div>
<div class='clearfix'></div></div>"; 

update_option('wlt_reset_itemcode', $GLOBALS['theme_defaults']['itemcode']);

$GLOBALS['theme_defaults']['listingcode']	= '<div class="block"><div class="block-title"><h1><span>[TITLE]</span></h1></div><div class="block-content"><div class="couponcontent">[IMAGE]<div class="caption"><h1>[TITLE]</h1><i class="fa fa-clock-o"></i> Expires in [COUPON_END]<hr /><div class="details"><div class="hidden_details">[CONTENT] [FIELDS] [GOOGLEMAP] </div>[CBUTTON]</div></div></div></div></div>[COMMENTS][RELATED]';

update_option('wlt_reset_listingcode', $GLOBALS['theme_defaults']['listingcode']);
 


// 5. REINSTALL THE SAMPLE DATA CATEGORIES 
$new_cat_array = array("Coupons","Printable Coupons","Offers","Other"); 
$saved_cats_array = array();
foreach($new_cat_array as $cat){
	if ( is_term( $cat , THEME_TAXONOMY ) ){
	$term = get_term_by('slug', $cat, THEME_TAXONOMY);
	$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'];
		}else{
		$saved_cats_array[] = $cat_id->term_id;
		}	
	}	
}
 

$i=1;
while($i < 17){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Coupon ".$i;
	$my_post['post_content'] 	= "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. ";
	$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, "link", "http://www.premiumpress.com");
	add_post_meta($POSTID, "code", wp_generate_password( $length=8, $include_standard_special_chars=false ));
	add_post_meta($POSTID, "start_date", date("Y-m-d H:i:s"));
	add_post_meta($POSTID, "expiry_date",  date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s") . " +7 days")));
 
	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );	
	
	$i++;	
} 
 
} 

?>