<?php

add_action('hook_new_install','_newinstall');
function _newinstall(){ global $CORE, $wpdb;
  
$GLOBALS['theme_defaults']['template'] 		= "template_video_theme";


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

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

// DEFAULTS FOR HOME PAGE OBJECTS
$GLOBALS['theme_defaults']['hdata'] = array(
"j1" => array("title1" => "Video Theme", "title2" => "HTML5 Responsive Video Theme", "title3" => "Share your videos with the world today!", ),
"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";

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

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

$GLOBALS['theme_defaults']['require_image'] 	= 1;
$GLOBALS['theme_defaults']['allow_video'] 		= 1;
$GLOBALS['theme_defaults']['allow_audio'] 		= 0;
$GLOBALS['theme_defaults']['allow_docs'] 		= 0;

$GLOBALS['theme_defaults']['videoteaser'][0]['time'] = 4;
$GLOBALS['theme_defaults']['videoteaser'][0]['html'] = '<div class="well text-center">
<h1>Please Upgrade Now!!</h1>
<h2>Upgrade your account to continue watching...</h2>
<br>
<h4><u>This is a popular theme option!</u> Limit how long users can watch videos for!</h4> 
<hr />
<p>Set a time limit in the admin for how long guests and non paying members can watch videos. Once that time period has reached your custom message will display here.</p>
<hr>
<p>You can customize this message with text, images or even another video!</p>
<hr>
<a href="" class="btn btn-success btn-lg">Subscribe Now</a>
</div>';

$GLOBALS['theme_defaults']['videoteaser'][1]['time'] = 4;
$GLOBALS['theme_defaults']['videoteaser'][1]['html'] = '<div class="well text-center">
<h1>Please Upgrade Now!!</h1>
<h2>Upgrade your account to continue watching...</h2>
<br>
<h4><u>This is a popular theme option!</u> Limit how long users can watch videos for!</h4> 
<hr />
<p>Set a time limit in the admin for how long guests and non paying members can watch videos. Once that time period has reached your custom message will display here.</p>
<hr>
<p>You can customize this message with text, images or even another video!</p>
<hr>
<a href="" class="btn btn-success btn-lg">Subscribe Now</a>
</div>';
 


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

 // SET HEADER
$GLOBALS['theme_defaults']['layout_header'] = 5;
// SET MENU
$GLOBALS['theme_defaults']['layout_menu'] = 2;
// HOME PAGE

$GLOBALS['theme_defaults']['widgetobject']["slider6"][0] 	= array(

		"query" => "post_type=listing_type&orderby=rand",
		"fullw" => "yes",	
);
$GLOBALS['theme_defaults']['widgetobject']["recentlisting"][1] 	= array(
		"title1" => "Recently Added Videos",
		"query1" => "post_type=listing_type&order=asc&posts_per_page=8",
		"style" => "grid",
		"fullw" => "no",
); 
 

$GLOBALS['theme_defaults']['homepage'] 		= array("widgetblock1" => "slider6_0,recentlisting_1");

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

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

$GLOBALS['theme_defaults']['display'] 	= array('default_gallery_style' => 'grid');

$GLOBALS['theme_defaults']['layout_columns'] 	= array('style' => 'fixed', 'homepage' => 3, 'search' => 2, 'single' => 2, 'page' => 2, 'page_2columns' => 1, 'single_2columns' => 1, 'search_2columns' => 1, 'homepage_2columns' => 1);
 

$GLOBALS['theme_defaults']['itemcode'] 		= "[IMAGE]<div class='overlay-video fa fa-play'></div>[/IMAGE]<h1>[TITLE]</h1> <hr>[RATING]<div class='hidden_details'><div class='ev'>  [CATEGORY] <b>[hits] views</b> <b>[COMMENT_COUNT] comments</b> </div><hr /> [EXCERPT size=300] </div>"; 

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


$GLOBALS['theme_defaults']['listingcode']	= '<div class="block"><div class="block-title"><h1>[TITLE]</h1></div><div class="block-content"> [VIDEO] <hr /> [CONTENT]  [GOOGLEMAP]  <div class="clearfix"></div> </div> </div> [RELATED] [COMMENTS box=1]';

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

 


// 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'),
);


$saved_cats_array = array();
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 ));
		
		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;
		}	
	}
	 
	/* 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 Video 1", "image" => "http://i.ytimg.com/vi/kffacxfA7G4/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=kffacxfA7G4&feature=youtube_gdata_player"),
"2" => array("name" =>"Example Video 2", "image" => "http://i.ytimg.com/vi/t4H_Zoh7G5A/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=t4H_Zoh7G5A&feature=youtube_gdata_player"),
"3" => array("name" =>"Example Video 3", "image" => "http://i.ytimg.com/vi/uelHwf8o7_U/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=uelHwf8o7_U&feature=youtube_gdata_player"),
"4" => array("name" =>"Example Video 4", "image" => "http://i.ytimg.com/vi/KQ6zr6kCPj8/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=KQ6zr6kCPj8&feature=youtube_gdata_player"),
"5" => array("name" =>"Example Video 5", "image" => "http://i.ytimg.com/vi/My2FRPA3Gf8/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=My2FRPA3Gf8&feature=youtube_gdata_player"),
"6" => array("name" =>"Example Video 6", "image" => "http://i.ytimg.com/vi/qrO4YZeyl0I/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=fWNaR-rxAic&feature=youtube_gdata_player"),
"7" => array("name" =>"Example Video 7", "image" => "http://i.ytimg.com/vi/7zp1TbLFPp8/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=7zp1TbLFPp8&feature=youtube_gdata_player"),
"8" => array("name" =>"Example Video 8", "image" => "http://i.ytimg.com/vi/QK8mJJJvaes/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=QK8mJJJvaes&feature=youtube_gdata_player"),
"9" => array("name" =>"Example Video 9", "image" => "http://i.ytimg.com/vi/QJO3ROT-A4E/0.jpg", "Youtube_link" => "http://www.youtube.com/watch?v=QJO3ROT-A4E&feature=youtube_gdata_player")

);

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, "image", $np['image']);
	add_post_meta($POSTID, "Youtube_link", $np['Youtube_link']);

	// UPDATE CAT LIST
	wp_set_post_terms( $POSTID, $saved_cats_array, THEME_TAXONOMY );		
} 
	
 
} 

?>