<?php

add_action('hook_new_install','_newinstall');
function _newinstall(){ global $CORE, $wpdb;
 
//$GLOBALS['theme_defaults']['links']['signup'] 		= $page_links['tpl-page-signup.php'];

// WEBSITE URL
$GLOBALS['theme_defaults']['logo_url'] 			= get_template_directory_uri()."/_directory/template/images/logo.png";

//$GLOBALS['theme_defaults']['fallback_image'] 			= get_template_directory_uri()."/_directory/template/images/default.jpg";
 
 $GLOBALS['theme_defaults']['color_primary'] 			= "#287CD6";
$GLOBALS['theme_defaults']['color_secondary'] = "";
$GLOBALS['theme_defaults']['page_columns'] = "3";  
$GLOBALS['theme_defaults']['page_layout'] = "0";      
$GLOBALS['theme_defaults']['search_item_style'] = "2";
$GLOBALS['theme_defaults']['header_hometransparent'] = "0";
$GLOBALS['theme_defaults']['header_topnav'] = ""; 
$GLOBALS['theme_defaults']['header_topnavstyle'] = "header-top1"; 
$GLOBALS['theme_defaults']['header_topnavhome'] 	= "0";
$GLOBALS['theme_defaults']['header_topnavbg'] 	= "default"; 
$GLOBALS['theme_defaults']['header_topnavborderbottom'] = "0";
$GLOBALS['theme_defaults']['header_style'] = "0"; 
$GLOBALS['theme_defaults']['header_shadow'] = "0"; 
$GLOBALS['theme_defaults']['header_bg'] 	= "default"; 
$GLOBALS['theme_defaults']['header_sep'] = "0";
$GLOBALS['theme_defaults']['header_button'] = "0";
$GLOBALS['theme_defaults']['header_buttontext'] = "Post Ad";        
$GLOBALS['theme_defaults']['headernav_bg'] = "default";         
$GLOBALS['theme_defaults']['breadcrumbs'] = "0";
$GLOBALS['theme_defaults']['breadcrumbs_style'] 	= "1";
$GLOBALS['theme_defaults']['footer_blockstyle'] = "0";
$GLOBALS['theme_defaults']['footer_bg'] = "default";

 

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

$GLOBALS['theme_defaults']['google'] = 1;
$GLOBALS['theme_defaults']['comments'] = 1;
$GLOBALS['theme_defaults']['businesshours'] = 1;
$GLOBALS['theme_defaults']['claimlisting'] = 1;
$GLOBALS['theme_defaults']['amenities'] = 1;
 

	$vals = array(        
		__("Accepts Credit Cards","premiumpress"),
		__("Air Conditioning","premiumpress"),
		__("Washer/Dryer Hookups","premiumpress"),
		__("Furniture","premiumpress"),
		__("Patio/Balcony","premiumpress"),
		__("Hardwood Floors","premiumpress"),
		__("Dishwasher","premiumpress"),
		__("Stunning Views","premiumpress"),
		__("Walk-in Closets","premiumpress"),
		__("Wireless Internet","premiumpress"),		
		__("Pet Friendly","premiumpress"),
		__("Fitness Center/Gym","premiumpress"),
		__("Swimming Pool","premiumpress"),
		__("Car Park","premiumpress"),
		__("Nearby Shops &amp; Restaurants","premiumpress"),
		__("Bike Storage","premiumpress"),
		__("Large Public Spaces","premiumpress"),
		__("Meeting Rooms","premiumpress"),
		__("24/7 Building Security Staff","premiumpress"), 
		__("Nearby Public Transport","premiumpress") ,
		__("Good Mobile Coverage","premiumpress"),
		 		
		);
$savemd = array(); $i=1;
foreach($vals as $k){
$savemd['name'][] 	= $k;
$savemd['key'][] 	= "ami".$i;
$savemd['search'][] = "yes";
$i++;}
		
update_option('dtamenitites', $savemd );


$new_cat_array = array( 
"Garage",
"Nightlife",
"Shopping",
"Hair &amp; Nails",
"Breakfast",
"Gym",
"Dry Cleaners",
"Dentists",
"Book Shops",
"Tackel Shops",
"Construction",
"Banks",
"Home &amp; Garden",
"Computers &amp; IT",
"Home &amp; Office",
"Cinemas",
"Estate Agents",
"Travel Agents",
"Food",
"Coffee"
);

$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',

'fa-car',
'fa-archive',
'fa-university',
'fa-coffee',
'fa-heart-o',
'fa-desktop',
'fa-cc-visa',
'fa-futbol-o',
'fa-bus',

'fa-car',
'fa-archive',
'fa-university',
'fa-coffee',
'fa-heart-o',
'fa-desktop',
'fa-cc-visa',
'fa-futbol-o',
'fa-bus',
);

$saved_cats_array = array(); $ff=0; $counter = 1;

foreach($new_cat_array as $cat ){

	if ( term_exists( $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, 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.' ));

		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] = "http:///www.premiumpress.com/_demoimages/stockphotography/cat".$ff.".jpg";
		$GLOBALS['theme_defaults']['category_icon_small_'.$nparent] = $cat_icons_small[$ff];
		$ff++;
	}
	
	
	$i=1;
	while($i < 3){
	 
		$my_post = array();
		$my_post['post_title'] 		= "Sample Business ".$counter;
		$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>";
		$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, "hits", rand(1, 100));
		
		add_post_meta($POSTID, "phone", "15664 21365");
		add_post_meta($POSTID, "email", "example@example.com");
		add_post_meta($POSTID, "website", "www.examplewebsite.com");

		//add_post_meta($POSTID, "Youtube_link", 'https://www.youtube.com/watch?v=MHG3n_-Y33A');
		
		add_post_meta($POSTID, "amenities", array(0 => "ami1", 1 => "ami2", 2 => "ami3", 3 => "ami4", 4 => "ami5", 5 => "ami6"));
		 
		// FEATURED
		$strings = array('yes', 'no');
		$random_str = $strings[array_rand($strings)];
		add_post_meta($POSTID, "featured", $random_str );
				 
		add_post_meta($POSTID, "image",  "https://www.premiumpress.com/_demoimages/directoryv9/".$counter.".jpg"); 
		
		
add_post_meta($POSTID, "map-city", "London");
add_post_meta($POSTID, "map-country", "GB");
add_post_meta($POSTID, "map-lat", "51.46972611851386");
add_post_meta($POSTID, "map-log", "-0.19092968671875488");
add_post_meta($POSTID, "map-location", "237B Wandsworth Bridge Rd, Fulham, London SW6 2TU, UK");

   
$businesshours = array(
    'start' => array
        (
            0 => '09:00',
            1 => '09:00',
            2 => '12:00',
            3 => '09:45',
            4 => '09:00',
            5 => '09:00',
            6 => '06:45',
        ),

    'end' => array
        (
            0 => '18:00',
            1 => '18:00',
            2 => '18:00',
            3 => '18:00',
            4 => '18:00',
            5 => '18:00',
            6 => '18:00',
        ),

    'active' => array
        (
            0 => '1',
            1 => '1',
            2 => '1',
            3 => '1',
            4 => '1',
            5 => '1',
            6 => '0',
        ),

);
         add_post_meta($POSTID, "businesshours", $businesshours );
       
            
		
		// UPDATE CAT LIST
		wp_set_post_terms( $POSTID, $nparent, THEME_TAXONOMY );  
		
		
		$i++;	 $counter++;
	} 
	 
 
}
} 

?>