<?php

add_action('hook_new_install','_newinstall');
function _newinstall(){ global $CORE, $wpdb;
 
$submissionfields[0] = array(
"name" => "Price", 
"help" => "", 
"fieldtype" => "input", 
"values" => "", 
"taxonomy" => "", 
"key" => "price", 
"order" => "1", 
"required" => "yes", 
"ID" => "0", 
);
 
 
update_option( "submissionfields", $submissionfields);

 
// 4. DEFAULT TEMPLATE DATA
$GLOBALS['theme_defaults']['template'] 		= "template_classifieds_theme";


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

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Classifieds Theme", "title2" => "HTML5 Responsive Classifieds Theme", "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."  ),

); 

// 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']["homepage"]["widgetblock1"] = "new8_0,categoryblock_1,carsousel_2";	
					
$GLOBALS['theme_defaults']['widgetobject']['new8']['0'] = array(
'text' => "<section><div class=\"wlt_object_head_1\"><div class=\"content_bottom\"><div id=\"banner1\" class=\"banner\"><div class=\"col-md-4 col-sm-4 col-xs-12\"><div class=\"s-desc\"><h3>Stuff to sell?</h3><h4>Get listed today</h4>List your classifieds here today</div></div><div class=\"col-md-4 col-sm-4 col-xs-12\"><div class=\"s-desc\"><h5>Call us now toll free:</h5><h3>0123-456-789</h3>Our team are standing by to help you</div></div><div class=\"col-md-4 col-sm-4 col-xs-12\"><div class=\"s-desc\"><h3>Join Now</h3><h5>REGISTRATION is free</h5>manage your classifieds and favourite items</div></div></div></div></div></section>",
'fullw' => "yes",
);
$GLOBALS['theme_defaults']['widgetobject']['categoryblock']['1'] = array(
'title' => "Popular Website Categories",
'btnview' => "yes",
'image' => "yes-side",
'desc' => "yes",
'iconsize' => "yes",
'catcount' => "yes",
'pcats' => "",
'subcats' => "3",
'subcatcount' => "yes",
'subcatempty' => "yes",
'fullw' => "yes",
);
$GLOBALS['theme_defaults']['widgetobject']['carsousel']['2'] = array(
'title' => "Recently Added Classifieds",
'query' => "",
'tax' => "",
'arrows' => "default",
'fullw' => "yes",
'perrow' => "4",
);	
 

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

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

$GLOBALS['theme_defaults']['itemcode'] 		= "[IMAGE]<span class='ftext'>[price]</span>[/IMAGE][RATING]<div class='caption'><h1>[TITLE]</h1><div class='hidden_details'>
<ul><li>[ICON id='fa fa-group' fa=1] [hits] user views [ICON id='fa fa-comments' fa=1] [COMMENT_COUNT] reviews <i class='fa fa-clock-o'></i> Added [DATE] </li> <li>  [LOCATION]  </li></ul>  
<hr />[EXCERPT size=260]... <div class='clearfix'></div><hr />[BUTTON] <span class='right hidden-xs hidden-sm' style='padding-right:20px; line-height:40px;'>[FAVS]</span>[ICON id='fa fa-tags' fa=true] [CATEGORY] [TAGS]  [DISTANCE] </div></div>"; 

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

$GLOBALS['theme_defaults']['listingcode']	= '<div class="block"><div class="pricestricker">[price]</div><div class="block-title"><h1><span>[TITLE]</span></h1></div><div class="block-content">[IMAGES]<hr /> [CONTACT button=1] [ICON id="map-marker"] [LOCATION]<hr /><div class="clearfix"></div>[DISTANCE]<ul class="nav nav-tabs" id="Tabs"><li class="active"><a href="#t1" data-toggle="tab">Description</a></li><li><a href="#t2" data-toggle="tab">Details</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]<h5>[TITLE]</h5>[CONTENT] [GOOGLEMAP] </div><div class="tab-pane" id="t2">[FIELDS hide="map"]</div> <div class="tab-pane" id="t4">[COMMENTS]</div></div></div></div>';

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


$GLOBALS['theme_defaults']['layout_menu'] = 4;
$GLOBALS['theme_defaults']['breadcrumbs_home'] = 0;

$GLOBALS['theme_defaults']['rating'] = 1;
 

// 5. REINSTALL THE SAMPLE DATA CATEGORIES 
$new_cat_array = array(
"Jobs" => array ('General Jobs','Training & HR','Other'),
"Business" => array ('Accounting','Aerospace and Defense','Agriculture and Forestry'),
"Computers" => array ('Laptops','Desktops','Parts for sale'),
"Games" => array ('xbox','Pc &amp; Mac','Playstation'),
"Health" => array ('Skincare','Medicine','Pills and Potions'),
"Home" => array ('Furniture','Decorations','Misc'),
"Kids and Teens" => array ('Clothes','Shoes','Outdoors'),
"Arts" => array ('Paints','Crft Items','Misc'),
"Books" => array ('Kindle Books','Magazines','Textbooks'),
"Sports" => array ('Outdoor','Indoor','Misc'),
"Electronics" => array ('Dvd Players','TVs','Mics'),
"Clothing & Jewelry" => array ('Clothing','Jewelry','Accessories'),

"Flats &amp; Houses" => array ('Flats for Sale','Houses for Sale','Rentable'),
"Services" => array ('Tuition &amp; Lessons','Health & Beauty','Building &amp; Home'),
"Pets" => array ('Pets for Sale','Equipment &amp; Accessories','Other'),
//"Community" => array ('Artists &amp; Theatres','Fitness &amp; Health','Other'),
);
  $cat_icons_small = array('','fa-car','fa-archive','fa fa-sitemap','fa fa-soccer-ball-o','fa-heart-o','fa-desktop','fa-child','fa-tint','fa-file-text','fa-google-wallet','fa-twitch','fa-yelp','fa-plug','fa-bullhorn','fa-paw');

$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, 'description' => 'This is a sample category description. You can add your own text or images for each category via the admin area. This is a sample category description. You can add your own text or images for each category via the admin area.' ));
	 
		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;
		}			
		// add in icon for this cat		
		$GLOBALS['theme_defaults']['category_icon_'.$nparent] = get_template_directory_uri()."/framework/img/demo/noimage.png";
		$GLOBALS['theme_defaults']['category_icon_small_'.$nparent] = $cat_icons_small[$ff];
		
		$ff++; 
	}
	/* SUB CATS */
	if(is_array($catlist)){
		foreach($catlist as $newcat){
		wp_insert_term($newcat, THEME_TAXONOMY, array('cat_name' => $newcat,'parent' => $nparent));
		}	
	}
}
 
// 6. INSTALL THE SAMPLE DATA LISTINGS
$posts_array = array(
"1" => array("name" =>"Example Listing 1","price" => "200", "tagline"=> "this is an example tag line", "map-lat"=> "48.69096039092549", "map-log" => "16.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/1.jpg"),
"2" => array("name" =>"Example Listing 2","price" => "26", "tagline"=> "this is an example tag line", "map-lat"=> "46.69096039092549", "map-log" => "17.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/2.jpg"),
"3" => array("name" =>"Example Listing 3","price" => "763", "tagline"=> "this is an example tag line", "map-lat"=> "45.69096039092549", "map-log" => "18.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/3.jpg"),
"4" => array("name" =>"Example Listing 4","price" => "66", "tagline"=> "this is an example tag line", "map-lat"=> "44.69096039092549", "map-log" => "14.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/4.jpg"),
"5" => array("name" =>"Example Listing 5","price" => "99", "tagline"=> "this is an example tag line", "map-lat"=> "43.69096039092549", "map-log" => "15.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/5.jpg"),
"6" => array("name" =>"Example Listing 6","price" => "148", "tagline"=> "this is an example tag line", "map-lat"=> "33.69096039092549", "map-log" => "22.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/6.jpg"),
"7" => array("name" =>"Example Listing 7","price" => "299", "tagline"=> "this is an example tag line", "map-lat"=> "45.69096039092549", "map-log" => "34.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/7.jpg"),
"8" => array("name" =>"Example Listing 8","price" => "399", "tagline"=> "this is an example tag line", "map-lat"=> "40.69096039092549", "map-log" => "46.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/8.jpg"),
"9" => array("name" =>"Example Listing 9","price" => "99", "tagline"=> "this is an example tag line", "map-lat"=> "41.69096039092549", "map-log" => "22.23876953125", "image" => get_template_directory_uri()."/templates/".$GLOBALS['theme_defaults']['template']."/img/demo/9.jpg")
);

foreach($posts_array as $np){
 
	$my_post = array();
	$my_post['post_title'] 		= $np['name'];
	$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, "price", rand(80, 500));
	add_post_meta($POSTID, "map-lat", $np['map-lat']);
	add_post_meta($POSTID, "map-log", $np['map-log']);
	add_post_meta($POSTID, "image", get_template_directory_uri()."/framework/img/demo/noimage.png");
	
	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );		
} 
 

} 

?>