<?php

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

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

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

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Micro Jobs Theme", "title2" => "HTML5 Responsive Micro Jobs Theme", 
"title3" => "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.", 
"img" => get_template_directory_uri()."/templates/template_microjob_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";
 
$GLOBALS['theme_defaults']['display']['default_gallery_style'] = "grid";
// SET BREADCRUMBS
$GLOBALS['theme_defaults']['breadcrumbs_inner'] = 1;
// SET HEADER
$GLOBALS['theme_defaults']['layout_header'] = 5;
// HEADER LAYOUT
$GLOBALS['theme_defaults']['header_accountdetails'] = 0;
// SET MENU
$GLOBALS['theme_defaults']['layout_menu'] = 3;

$GLOBALS['theme_defaults']['header_welcometext'] = "<i class='fa fa-phone-square'></i> Call Us +123-1234-1234-5555";

// 4. DEFAULT TEMPLATE DATA
$GLOBALS['theme_defaults']['template'] 		= "template_microjob_theme";
// RATING
$GLOBALS['theme_defaults']['rating_type'] = "3a";
// CONTENT LAYOUT / SINGLE LAYOUT
$GLOBALS['theme_defaults']['content_layout'] = "listing-microjobs";
$GLOBALS['theme_defaults']['single_layout'] = "content-listing-microjobs";
// ADD IN CUSTOM WIDGET BLOCK
$GLOBALS['theme_defaults']['widgetobject']["text"]["0"] = array(
			"fullw" => "yes",
			"text" =>  ""		
); 
$GLOBALS['theme_defaults']['widgetobject']["recentlisting"]["1"] 	= array(
		"style" => "grid",
		"title" => "", 
		"fullw" => "no",
		"perrow" => 3,
);
$GLOBALS['theme_defaults']['homepage'] 		= array("widgetblock1" => "text_0,recentlisting_1");
// PAGE COLUMNS
 

$GLOBALS['theme_defaults']['itemcode'] 		= "[IMAGE]<span class='ftext'>[price]</span>[/IMAGE]
<h2>[TITLE]</h2>

<div class='hidden_details'> [EXCERPT]</div> 

<div class='clearfix'></div>
<div style='border-top:1px solid #ddd; padding-top:10px;'>
<div class='col-md-7'>[AUTHORIMAGE] [AUTHOR] [AUTHOR-FLAG]</div>
<div class='col-md-5 text-right'> <i class='fa fa-shopping-cart'></i> [SALES] </div>
</div>"; 

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

$GLOBALS['theme_defaults']['listingcode']	= '<div class="row">
    <div class="col-md-6">    
    
    <div class="panel panel-default">
    <div class="panel-heading">{Attachments}</div>
    <div class="panel-body">
    [IMAGES]
    </div>
    </div>
    
    [AUTHORBOX]
    [COMMENTS box=true] 
    
    </div>
        
    <div class="col-md-6">
    <div class="panel panel-default">
    <div class="panel-heading">
    
    <span class="pull-right">[FAVS]</span>
    
    {Description}</div>
<h1 CLASS="text-center">[TITLE]</h1>
 
    [INFOBAR]
    <div class="panel-body">
    
    [CONTENT]
    </div>
    [BUYBAR]
    </div>
    </div>

</div>

<div class="clearfix"></div>';

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


// 5. REINSTALL THE SAMPLE DATA CATEGORIES 
$new_cat_array = array("website development","website design","identity design","seo","wordpress","logo","search marketing","social media marketing","web writing","graphics design","html","social media","article","illustration","video","photoshop","blog writing","link building","Other"); 
$saved_cats_array = array(); $i=1;
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'];
		$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()."/templates/template_microjob_theme/img/c".$i.".jpg";
		 
		
		$i++;
	}	
	
}
// 6. INSTALL THE SAMPLE DATA LISTINGS
$posts_array = array(
"1" => array("name" =>"I can create a professional whiteboard / digital doodle ","price" => "39", "days" => 5),
"2" => array("name" =>"I can create a link wheel to your website","price" => 30, "days" => 5),
"3" => array("name" =>"I can write a 400 word blog post or article for $20","price" => 20, "days" => 5),
"4" => array("name" =>"I can optimise the hell out of your Wordpress","price" => "77", "days" => 5),
"5" => array("name" =>"I can design a professional, double sided cards","price" => "44", "days" => 5),
"6" => array("name" =>"I can provide a 550+ words high quality article ","price" => "28", "days" => 5),
"7" => array("name" =>"I can write a 400 word blog post or article for $20","price" => "20", "days" => 5),
"8" => array("name" =>"I can add help promote your Facebook or Twitter","price" => "40", "days" => 5),
"9" => array("name" =>"I can update your website with the latest updates","price" => "10", "days" => 5),
 
);

$i=1;
foreach($posts_array as $np){
 
	$my_post = array();
	$my_post['post_title'] 		= "Example Micro Job ".$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'] 		= "listing_type";
	$my_post['post_status'] 	= "publish";
	$my_post['post_category'] 	= "";
	$my_post['tags_input'] 		= "";
	$POSTID 					= wp_insert_post( $my_post );	
	
	
	add_post_meta($POSTID, "map-country", "us");
	add_post_meta($POSTID, "price", $np['price']);
	add_post_meta($POSTID, "days", $np['days']);
	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 );	
	
	// COUNTER
	$i++;	
} 
 
} 

?>