<?php 
/**
 * Trending news customizer
**/ 
?>
<?php 
function trendingnews_customize( $wp_customize ) {
	//  = Trending news: Sections =
	
	$wp_customize->get_section('title_tagline')->title = '[TN] Site Title, Tagline & Footer copyright text' ;
	$wp_customize->get_section('title_tagline')->priority = '1';

	$wp_customize->get_section('header_image')->title = '[TN] Logo, Favicon, Apple touch icon' ;
	$wp_customize->get_section('header_image')->priority = '2';	
	
	$wp_customize->get_section('colors')->title = '[TN] Theme Colors and Design' ;
	$wp_customize->get_section('colors')->priority = '3';

	$wp_customize->add_section('tn_home_slider' , array(
			'title' => '[TN] Home Slider and Ticker',
			'priority' => '4'
	));	

	$wp_customize->add_section('tn_post_page_options' , array(
			'title' => '[TN] Post page option',
			'priority' => '5'
	));

	$wp_customize->add_section('tn_translate' , array(
			'title' => '[TN] Translate',
			'priority' => '6'
	));
	
	$wp_customize->add_section('tn_social' , array(
			'title' => '[TN] Social settings',
			'priority' => '7'
	));
	
	$wp_customize->add_section('tn_ads_options' , array(
			'title' => '[TN] Ads and tracking',
			'priority' => '8'
	));
		

	
	//  = Trending news: Colors =
	
	$colors = array();

	$colors[] = array(
			'slug'=>'tn_header_color',
			'default' => '#000000',
			'label' => 'Header background color', 
			'section' => 'colors',
			'priority' => '1'
	);

	$colors[] = array(
			'slug'=>'tn_menu_background',
			'default' => '#000000',
			'label' => 'Menu background color', 
			'section' => 'colors',
			'priority' => '2'
	);

	$colors[] = array(
			'slug'=>'tn_menu_color',
			'default' => '#FFFFFF',
			'label' => 'Menu font color', 
			'section' => 'colors',
			'priority' => '3'
	);

	$colors[] = array(
			'slug'=>'tn_footer_background',
			'default' => '#000000',
			'label' => 'Footer background color', 
			'section' => 'colors',
			'priority' => '4'
	);

	$colors[] = array(
			'slug'=>'tn_footer_color',
			'default' => '#FFFFFF',
			'label' => 'Footer font color', 
			'section' => 'colors',
			'priority' => '4'
	);
	
	$colors[] = array(
			'slug'=>'tn_border_color',
			'default' => '#000000',
			'label' => 'Widget border color', 
			'section' => 'colors',
			'priority' => '4'
	);

	$colors[] = array(
			'slug'=>'tn_hover_color',
			'default' => '#0099ff',
			'label' => 'Hover color', 
			'section' => 'colors',
			'priority' => '5'
	);
	
		$colors[] = array(
			'slug'=>'tn_menu_symbol_color',
			'default' => '#0099ff',
			'label' => 'Menu symbol color', 
			'section' => 'colors',
			'priority' => '2'
	);

	foreach( $colors as $color ) {
		$wp_customize->add_setting(
				$color['slug'], array(
						'default' => $color['default'],
						'type' => 'option',
						'capability' =>'edit_theme_options'
				)
		);

		$wp_customize->add_control(
				new WP_Customize_Color_Control(
						$wp_customize,
						$color['slug'],
						array('label' => $color['label'],
								'section' => $color['section'],
								'settings' => $color['slug'],
								'priority' => $color['priority'])
				)
		);
	}
	


		//  = Trending news: Images =

		
		$tnimages = array();
		$bloginfo = get_template_directory_uri();

		
		$tnimages[] = array(
				'slug'=>'tn_apple_touch_icon',
				'default' => $bloginfo.'/images/apple-touch-icon.png',
				'label' => 'Apple touch icon: 129x129 px PNG/JPG image.',
				'priority' => '30'
		);
		
		$tnimages[] = array(
				'slug'=>'tn_favicon',
				'default' => $bloginfo.'/images/favicon.png',
				'label' => 'Favicon: 16x16 px PNG/GIF image.',
				'priority' => '20'
		);
		
		foreach( $tnimages as $tnimage ) {		
		
		
		$wp_customize->add_setting($tnimage['slug'], array(
				'capability'        => 'edit_theme_options',
				'type'           => 'option',
				'default' => $tnimage['default'],
		));
		
		$wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, $tnimage['slug'], array(
				'label'    => $tnimage['label'],
				'section'  => 'header_image',
				'settings' => $tnimage['slug'],
				'priority' => $tnimage['priority']
		)));
	
	
	
		}
	
	
		//  = Trending news: Text =
		
		
		$tntext = array();
	
		$tntext[] = array(
				'slug'=>'tn_facebook',
				'default' => '',
				'label' => 'Facebook:', 
				'section' => 'tn_social',
				'priority' => '1'
		);
		
		$tntext[] = array(
				'slug'=>'tn_twitter',
				'default' => '',
				'label' => 'Twitter:', 
				'section' => 'tn_social',
				'priority' => '2'
		);
		
		$tntext[] = array(
				'slug'=>'tn_pinterest',
				'default' => '',
				'label' => 'Pinterest:', 
				'section' => 'tn_social',
				'priority' => '3'
		);
		
		$tntext[] = array(
				'slug'=>'tn_google',
				'default' => '',
				'label' => 'Google:', 
				'section' => 'tn_social',
				'priority' => '4'
		);
		
		$tntext[] = array(
				'slug'=>'tn_youtube',
				'default' => '',
				'label' => 'Youtube:', 
				'section' => 'tn_social',
				'priority' => '5'
		);
		
		$tntext[] = array(
				'slug'=>'tn_instagram',
				'default' => '',
				'label' => 'Instagram:', 
				'section' => 'tn_social',
				'priority' => '6'
		);

		$tntext[] = array(
				'slug'=>'tn_word_before_author',
				'default' => 'by',
				'label' => 'Word before author(eg. by, from, posted by)', 
				'section' => 'tn_translate',
				'priority' => '1'
		);
		
		$tntext[] = array(
				'slug'=>'tn_word_before_category',
				'default' => 'Latest in:',
				'label' => 'Category page:Word before Category title', 
				'section' => 'tn_translate',
				'priority' => '1'
		);
			
		$tntext[] = array(
				'slug'=>'tn_today_date',
				'default' => 'Todays Date',
				'label' => 'Todays Date', 
				'section' => 'tn_translate',
				'priority' => '2'
		);
			
		$tntext[] = array(
				'slug'=>'tn_post_tags_title',
				'default' => 'Tags',
				'label' => 'Post page: Tags title', 
				'section' => 'tn_translate',
				'priority' => '4'
		);

		$tntext[] = array(
				'slug'=>'tn_share_this_article',
				'default' => 'SHARE THIS ARTICLE',
				'label' => 'Post page: share', 
				'section' => 'tn_translate',
				'priority' => '4'
		);
		
		$tntext[] = array(
				'slug'=>'tn_share_this_video',
				'default' => 'SHARE THIS VIDEO',
				'label' => 'TV page: share', 
				'section' => 'tn_translate',
				'priority' => '4'
		);
		
		$tntext[] = array(
				'slug'=>'tn_older_article',
				'default' => 'OLDER ARTICLE',
				'label' => 'Post page: Older article', 
				'section' => 'tn_translate',
				'priority' => '5'
		);
		
		$tntext[] = array(
				'slug'=>'tn_next_article',
				'default' => 'NEXT ARTICLE',
				'label' => 'Post page: next article', 
				'section' => 'tn_translate',
				'priority' => '6'
		);
		
		
		$tntext[] = array(
				'slug'=>'tn_related_by',
				'default' => 'RELATED BY',
				'label' => 'Post page: related widget title', 
				'section' => 'tn_translate',
				'priority' => '7'
		);

		$tntext[] = array(
				'slug'=>'tn_post_page_related_tags',
				'default' => 'TAGS',
				'label' => 'Related widget: Title tags', 
				'section' => 'tn_translate',
				'priority' => '8'
		);
		
		$tntext[] = array(
				'slug'=>'tn_post_page_related_category',
				'default' => 'CATEGORY',
				'label' => 'Related widget: Title category', 
				'section' => 'tn_translate',
				'priority' => '9'
		);
		
		$tntext[] = array(
				'slug'=>'tn_post_page_related_author',
				'default' => 'AUTHOR',
				'label' => 'Related widget: Title author', 
				'section' => 'tn_translate',
				'priority' => '10'
		);
		
		$tntext[] = array(
				'slug'=>'tn_tv_carousel_title',
				'default' => 'BROWSE MORE VIDEOS',
				'label' => 'Tv carousel title', 
				'section' => 'tn_translate',
				'priority' => '10'
		);
		
			
		$tntext[] = array(
				'slug'=>'tn_comments_post_comment',
				'default' => 'Post comment',
				'label' => 'Comments: Post comment', 
				'section' => 'tn_translate',
				'priority' => '12'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_post_reply',
				'default' => 'Leave a Reply',
				'label' => 'Comments: Leave a Reply', 
				'section' => 'tn_translate',
				'priority' => '13'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_post_reply_to',
				'default' => 'Leave a Reply to',
				'label' => 'Comments: Leave a Reply to', 
				'section' => 'tn_translate',
				'priority' => '14'
		);
		
		
		$tntext[] = array(
				'slug'=>'tn_comments_cancel_reply',
				'default' => 'Cancel reply',
				'label' => 'Comments: Cancel reply', 
				'section' => 'tn_translate',
				'priority' => '15'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_name',
				'default' => 'Name',
				'label' => 'Comments: Name', 
				'section' => 'tn_translate',
				'priority' => '16'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_email',
				'default' => 'Email',
				'label' => 'Comments: Email', 
				'section' => 'tn_translate',
				'priority' => '17'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_website',
				'default' => 'Website',
				'label' => 'Comments: Website', 
				'section' => 'tn_translate',
				'priority' => '18'
		);
				
		$tntext[] = array(
				'slug'=>'tn_comments_no_comment',
				'default' => 'No Comment',
				'label' => 'Comments: No Comment', 
				'section' => 'tn_translate',
				'priority' => '19'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_one_comment',
				'default' => 'One Comment',
				'label' => 'Comments: One Comment', 
				'section' => 'tn_translate',
				'priority' => '20'
		);
		
		$tntext[] = array(
				'slug'=>'tn_comments_number_comments',
				'default' => 'Comments on this post.',
				'label' => 'Comments: Number of comments on this post.(the line after the number)', 
				'section' => 'tn_translate',
				'priority' => '21'
		);
		
		$tntext[] = array(
				'slug'=>'tn_breadcrumbs_home',
				'default' => 'Home',
				'label' => 'Breadcrumbs: Home', 
				'section' => 'tn_translate',
				'priority' => '22'
		);	
		
		
		$tntext[] = array(
				'slug'=>'tn_ticker_number',
				'default' => '5',
				'label' => 'Ticker number of posts to display', 
				'section' => 'tn_home_slider',
				'priority' => '100'
		);	
		
		$tntext[] = array(
				'slug'=>'tn_sign_before_link',
				'default' => '+',
				'label' => 'Symbol before post links', 
				'section' => 'colors',
				'priority' => '100'
		);			
		
		$tntext[] = array(
				'slug'=>'tn_copyright',
				'default' => 'Copyright 2013 Trending news Theme.Powered by Wordpress.',
				'label' => 'Footer copyright text', 
				'section' => 'title_tagline',
				'priority' => '10'
		);
	
		foreach( $tntext as $tn_text ) {
			
			
			$wp_customize->add_setting($tn_text['slug'], array(
					'default'        => $tn_text['default'],
					'capability'     => 'edit_theme_options',
					'type'           => 'option',
			
			));
			
			$wp_customize->add_control($tn_text['slug'], array(
					'label'      => $tn_text['label'],
					'section'    => $tn_text['section'],
					'settings'   => $tn_text['slug'],
					'priority'   => $tn_text['priority'],
			));
					
		}
		
		
		
		
		
		
		
		//  = Trending news: Dropdown =
		
		$tn_tags = array();
		
		$tn_tags_obj = get_tags('hide_empty=0');
		
		foreach ($tn_tags_obj as $tn_tag) {
		
			$tn_tags[$tn_tag->slug] = $tn_tag->slug;}
		
			$tags_tmp = array_unshift($tn_tags, 'Select a tag:');
			
			
			
			$fonts_list = array(
				'Asap' => 'Asap',
				'Asul' => 'Asul',		
				'Bitter' => 'Bitter',
				'Caudex' => 'Caudex',
				'Droid Sans' => 'Droid Sans',
				'Droid Serif' => 'Droid Serif',
				'Electrolize' => 'Electrolize',
				'Hanuman' => 'Hanuman',
				'Jura' => 'Jura',
				'Kameron' => 'Kameron',
				'Kotta One' => 'Kotta One',
				'Lato' => 'Lato',
				'Lora' => 'Lora',
				'Magra' => 'Magra',
				'Maven Pro' => 'Maven Pro',
				'Metrophobic' => 'Metrophobic',
				'Molengo' => 'Molengo',
				'Open Sans' => 'Open Sans',
				'PT Sans' => 'PT Sans',
				'PT Serif' => 'PT Serif',
				'Play' => 'Play',
				'Podkova' => 'Podkova',
				'Pontano Sans' => 'Pontano Sans',
				'Quattrocento Sans' => 'Quattrocento Sans',
				'Raleway' => 'Raleway',
				'Rosario' => 'Rosario',
				'Shanti' => 'Shanti',
				'Share' => 'Share',
				'Signika' => 'Signika',
				'Telex' => 'Telex',
				'Tinos' => 'Tinos',
				'Ubuntu' => 'Ubuntu',
				'Vidaloka' => 'Vidaloka',
				'Viga' => 'Viga'				
			);
			
			
			$tn_dropdowns = array();
					
			$tn_dropdowns[] = array(
					'slug'=>'tn_wide_switch',
					'default' => 'true',
					'label' => 'Home slider', 
					'section' => 'tn_home_slider',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
		
					));		
		
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_wide_tags',
					'default' => 'Select a tag:',
					'label' => 'Home Slider posts tag:', 
					'section' => 'tn_home_slider',
					'choices' => $tn_tags,
			);
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_ticker_tags',
					'default' => 'Select a tag:',
					'label' => 'Ticker posts tag:', 
					'section' => 'tn_home_slider',
					'choices' => $tn_tags,
			);
				
			$tn_dropdowns[] = array(
					'slug'=>'tn_slider_picker',
					'default' => 'fade',
					'label' => 'Slider transition', 
					'section' => 'tn_home_slider',
					'choices'    => array(
							'slide' => 'Slide Transition',
							'fade' => 'Fade Transition',
								
					));
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_layout',
					'default' => 'left',
					'label' => 'Layout', 
					'section' => 'colors',
					'choices'    => array(
							'left' => 'Sidebar right',
							'right' => 'Sidebar left',
		
					));
					
			$tn_dropdowns[] = array(
					'slug'=>'tn_social_color',
					'default' => '',
					'label' => 'Social Icons Color', 
					'section' => 'colors',
					'choices'    => array(
							'-black' => 'Black',
							'' => 'White',
		
					));
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_fonts',
					'default' => 'Open Sans',
					'label' => 'Main Font', 
					'section' => 'colors',
					'choices'    => $fonts_list
	
					);
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_menu_font',
					'default' => 'Open Sans',
					'label' => 'Menu Font', 
					'section' => 'colors',
					'choices'    => $fonts_list
			
			);
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_share_post',
					'default' => 'true',
					'label' => 'Share buttons', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
		
					));			
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_post_tags',
					'default' => 'true',
					'label' => 'Post tags', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
		
					));			
	
			$tn_dropdowns[] = array(
					'slug'=>'tn_author_box',
					'default' => 'true',
					'label' => 'Author-box', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
		
					));
			
			$tn_dropdowns[] = array(
					'slug'=>'tn_show_comments',
					'default' => 'true',
					'label' => 'Comments', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
			
					));
					
			$tn_dropdowns[] = array(
					'slug'=>'tn_next_prev_links',
					'default' => 'true',
					'label' => 'Navigation Links', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
			
					));					
			
		
			$tn_dropdowns[] = array(
					'slug'=>'tn_related_tabber',
					'default' => 'true',
					'label' => 'Related Tabber', 
					'section' => 'tn_post_page_options',
					'choices'    => array(
							'true' => 'Show',
							'false' => 'Hide',
			
					));

					
			foreach( $tn_dropdowns as $tn_dropdown ) {
					
					
				$wp_customize->add_setting($tn_dropdown['slug'], array(
						'default'        => $tn_dropdown['default'],
						'capability'     => 'edit_theme_options',
						'type'           => 'option',
							
				));
					
				$wp_customize->add_control($tn_dropdown['slug'], array(
						'label'      => $tn_dropdown['label'],
						'section'    => $tn_dropdown['section'],
						'settings'   => $tn_dropdown['slug'],
						'choices' => $tn_dropdown['choices'],
						'type'    => 'select',
				));
					
			}
		
			
			
			//  = Trending news: Dropdown =
			
			class textarea_control extends WP_Customize_Control {
				public $type = 'textarea';
					
				public function render_content() {
					?>
						        <label>
						        <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
						        <textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
						        </label>
						        <?php
						    }
						}			
			
			
			$tntextareas = array();
					
			$tntextareas[] = array(
					'slug'=>'tn_post_ad',
					'default' => '<img src="'.$bloginfo.'/images/300x250.jpg" alt="336x280ad">',
					'label' => 'Post page ad 300x250', 'trendingnews',
					'section' => 'tn_ads_options',
			);
			
			$tntextareas[] = array(
					'slug'=>'tn_category_ad',
					'default' => '<img src="'.$bloginfo.'/images/300x250.jpg" alt="336x280ad">',
					'label' => 'Category page ad 300x250', 'trendingnews',
					'section' => 'tn_ads_options',
			);
			
			$tntextareas[] = array(
					'default' => '',
					'slug'=>'tn_tracking',
					'label' => 'Paste your Google Analytics (or other) tracking code here.',
					'section' => 'tn_ads_options'
			);
			
		foreach( $tntextareas as $tntextarea ) {
			
			$wp_customize->add_setting($tntextarea['slug'], array(
					'default'        => $tntextarea['default'],
					'capability'     => 'edit_theme_options',
					'type'           => 'option',
			) );
			
			$wp_customize->add_control( new textarea_control( $wp_customize, $tntextarea['slug'], array(
					'label'   => $tntextarea['label'],
					'section' => 'tn_ads_options',
					'settings'   => $tntextarea['slug'],
			) ) );
			
		}
			
			
			
		
}
add_action( 'customize_register', 'trendingnews_customize' );
?>