<?php

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

// DEFAULT TEMPLATE DATA
$GLOBALS['theme_defaults']['template'] 		= "template_directory_theme";

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

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

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

// MAP
$GLOBALS['theme_defaults']['display_search_map'] = 3;

// SET HEADER
$GLOBALS['theme_defaults']["layout_header"] = 4;
					// SET MENU
$GLOBALS['theme_defaults']["layout_menu"] = 4;
					// SET RESPONISVE DESIGN
$GLOBALS['theme_defaults']["responsive"] = "1";
		 
 
					// SET WELCOME TEXT
$GLOBALS['theme_defaults']["header_welcometext"] = "Your own text could go here!";        
					// SET RATING
$GLOBALS['theme_defaults']["rating"] 		= "1";
$GLOBALS['theme_defaults']["rating_type"] 	= "1";

// BREADCRUMBS
$GLOBALS['theme_defaults']["breadcrumbs_inner"] 	= 1;
$GLOBALS['theme_defaults']["breadcrumbs_home"] 		= 0; 
$GLOBALS['theme_defaults']['search_searchbar'] 		= 0;
$GLOBALS['theme_defaults']['subcategories'] 		= 1;


					// TURN OFF CATEGORY DESCRIPTION
$GLOBALS['theme_defaults']["category_descrition"] 	= "1";	
					// GEO LOCATION
$GLOBALS['theme_defaults']["geolocation"] 	= "1";
$GLOBALS['theme_defaults']["geolocation_flag"] 	= "US";
$GLOBALS['theme_defaults']['google_coords'] = " 50.792047, 9.906235";
$GLOBALS['theme_defaults']['google_coords1'] = " 50.792047, 9.906235";

					// FOOTER SOCIAL ICONS
$GLOBALS['theme_defaults']["social"] 	= array(
					'twitter' => '##', 'twitter_icon' => 'fa-twitter', 
					'facebook' => '##', 'facebook_icon' => 'fa-facebook', 
					'dribbble' => '', 'dribbble_icon' => 'fa-google-plus', 
					'linkedin' => '##', 'linkedin_icon' => 'fa-linkedin', 
					'youtube' => '##', 'youtube_icon' => 'fa-youtube', 
					'rss' => '##', 'rss_icon' => 'fa-rss',         
					);
  
 // HOME PAGE OBJECT SETUP
$GLOBALS['theme_defaults']["homepage"]["widgetblock1"] = "text_39,homecatsd_38";	
					

$GLOBALS['theme_defaults']['widgetobject']['text']['39'] = array(
'text' => "<div class=\"home-banner clearfix\"></div><div class=\"home-features clearfix\"><div class=\"container\"><div class=\"row\"><div class=\"col-md-4\"><div class=\"features-intro clearfix\"><h2>Responsive HTML5 Directory Theme</h2>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.<a class=\"read-more\" href=\"".home_url()."/?s=\">View Our Listings</a></div></div><div class=\"col-md-8\"><div class=\"row\"><div class=\"col-sm-6 single-feature\"><div class=\"row\"><div class=\"col-sm-3 icon-wrapper\"><i class=\"fa fa-filter\"></i></div><div class=\"col-sm-9\"><h3>Search Filtering</h3>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod.</div></div></div><div class=\"col-sm-6 single-feature\"><div class=\"row\"><div class=\"col-sm-3 icon-wrapper\"><i class=\"fa fa-map-marker\"></i></div><div class=\"col-sm-9\"><h3>Google Maps</h3>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore.</div></div></div><div class=\"col-sm-6 single-feature\"><div class=\"row\"><div class=\"col-sm-3 icon-wrapper\"><i class=\"fa fa-users\"></i></div><div class=\"col-sm-9\"><h3>Members Area</h3>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore.</div></div></div><div class=\"col-sm-6 single-feature\"><div class=\"row\"><div class=\"col-sm-3 icon-wrapper\"><i class=\"fa fa-envelope\"></i></div><div class=\"col-sm-9\"><h3>Contact Forms</h3>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore.</div></div></div></div></div></div></div></div>",
'autop' => "1",
'fullw' => "yes",
);
 		


$GLOBALS['theme_defaults']['widgetobject']['homecatsd']['38'] = array(
'fullw' => "yes",
);	
					// SET ITEMCODE
						
// CONTENT LAYOUT / SINGLE LAYOUT
$GLOBALS['theme_defaults']['content_layout'] = "listing-directory";
$GLOBALS['theme_defaults']['single_layout'] = "content-listing-directory";


// TURN ON GALLEYRY MAP
$GLOBALS['theme_defaults']['default_gallery_map'] = 1;

$GLOBALS['theme_defaults']['header_accountdetails'] = 0;

 

	// 4. CUSTOM SUBMISSION FIELDS
	$submissionfields[0] = array(
	"name" => "Website Link", 
	"help" => "", 
	"fieldtype" => "input", 
	"values" => "", 
	"taxonomy" => "", 
	"key" => "url", 
	"order" => 1, 
	"required" => "yes", 
	"ID" => "0", 
	);
	$submissionfields[1] = array(
	"name" => "Phone Number", 
	"help" => "", 
	"fieldtype" => "input", 
	"values" => "", 
	"taxonomy" => "", 
	"key" => "phone", 
	"order" => 2, 
	"required" => "yes", 
	"ID" => 1, 
	);
	
	// SAVE ARRAY DATA		 
	update_option( "submissionfields", $submissionfields);
	 
	// 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'),
 
	);
	
	$cat_icons_small = array('','fa-car','fa-archive','fa-university','fa-coffee','fa-heart-o','fa-desktop','fa-cc-visa','fa-futbol-o','fa-bus');
	
	$ICONKEY = "c";
	
 
 
 
$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' =>  'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore.' ));
		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));
		}	
	}
}

$i=1;
while($i< 16){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Listing ".$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, "url", "http://www.premiumpress.com");	 
	add_post_meta($POSTID, "image", get_template_directory_uri()."/framework/img/demo/noimage.png");	
	add_post_meta($POSTID, "phone", "123-456-789");
	add_post_meta($POSTID, "featured", "no");
	
	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );	
	
	$i++;	
} 

// EXTRA DEMO CONTENT
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Directory Theme", "title2" => "HTML5 Responsive Directory Theme", "title3" => "This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.", "img" => get_template_directory_uri()."/templates/template_directory_theme/demo/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."  ),
);


 
// INSERT SAMPL BLOG POSTS

global $MEDIA;

$my_cat = array('cat_name' => 'Latest News', 'category_description' => 'A Cool Category', 'category_nicename' => 'category-slug', 'category_parent' => '');
$my_cat_id = wp_insert_category($my_cat);

$i=1;
while($i< 6){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Blog Post ".$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'] 		= "post";
	$my_post['post_status'] 	= "publish";
	$my_post['post_category'] 	= "";
	$my_post['tags_input'] 		= "";
	$POSTID 					= wp_insert_post( $my_post );
 
	// UPDATE CAT LIST
	wp_set_post_categories( $POSTID, array($my_cat_id) ) ;
	
	$i++;	
} 

} 

?>