<?php
/**
 *	Featured Areas
 */
function phnewsfeed_featured_areas_customize_register( $wp_customize ) {
	
	
	//Featured Areas
	$wp_customize->add_panel(
		'phnewsfeed-featured-areas', array(
			'title'		=>	__('Featured Areas', 'ph-news-feed'),
			'priority'	=>	30
		)
	);
	
	//Ticker
	$wp_customize->add_section(
		'phnewsfeed-ticker', array(
			'title'		=>	__('Featured Ticker', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-featured-areas'
		)
		);
		
	$wp_customize->add_setting(
		'phnewsfeed-enable-ticker', array(
			'default'		=>	0,
			'sanitize_callback'	=>	'absint' 
		)
	);
		
	$wp_customize->add_control(
		'phnewsfeed-enable-ticker', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewsfeed-ticker',
			  'label' => __( 'Enable ticker (Homepage Only)','ph-news-feed' ),
			  'description' => __( 'Animated Ticker generally used to show viral or trending content.','ph-news-feed' ),
			)	
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-enable-ticker-sitewide', array(
			'default'		=>	0,
			'sanitize_callback'	=>	'absint' 
		)
	);
		
	$wp_customize->add_control(
		'phnewsfeed-enable-ticker-sitewide', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewsfeed-ticker',
			  'label' => __( 'Enable Ticker (Sitewide)','ph-news-feed' ),
			)	
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-ticker-label', array(
			'default'		=>	__('Latest Posts', 'ph-news-feed'),
			'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
		
	$wp_customize->add_control(
		'phnewsfeed-ticker-label', array(
			  'type' => 'text',
			  'section'		=>	'phnewsfeed-ticker',
			  'label' => __( 'Ticker Label','ph-news-feed' ),
			)	
	);
		
	$wp_customize->add_setting(
		'phnewsfeed-ticker-cat', array(
			'default'		=>	0,
			'sanitize_callback'	=>	'absint'
		)
	);
	
		
	$wp_customize->add_control(
		new phnewsfeed_WP_Customize_Category_Control(
			$wp_customize, 'phnewsfeed-ticker-cat', array(
				'label'		=>	__('Category', 'ph-news-feed'),
				'description'	=>	__('Category whose posts need to be featured..', 'ph-news-feed'),
				'priority'		=>	10,
				'section'		=>	'phnewsfeed-ticker'
				
			)
		)
	);
		
	$wp_customize->add_setting(
		'phnewsfeed-ticker-count', array(
			'default'		=>	6,
			'sanitize_callback'	=>	'absint'
		)
	);
		
	$wp_customize->add_control( new WP_Customize_Control(
		$wp_customize,
		'phnewsfeed-ticker-count',
			array(
				'label'    => __( 'No. of Posts', 'ph-news-feed' ),
				'description'    => __( 'Recommended to set this value to 6 or more.', 'ph-news-feed' ),
				'section'  => 'phnewsfeed-ticker',
				'settings' => 'phnewsfeed-ticker-count',
				'type'     => 'number'
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-ticker-disable-phone', array(
			'default'		=>	1,
			'sanitize_callback'	=>	'absint' 
		)
	);
	$wp_customize->add_control(
		'phnewsfeed-ticker-disable-phone', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewsfeed-ticker',
			  'label' => __( 'Disable ticker on Mobile Devices','ph-news-feed' ),
			  'description' => __( 'The Slider Ticker may not produce the desired effect on Mobile as it does on Desktop Devices. Use this to disable Ticker on Phone. (Recommended)','ph-news-feed' ),
			)	
	);
	
	
		
	//Carousel
	$wp_customize->add_section(
		'phnewsfeed-carousel', array(
			'title'		=>	__('Featured Carousel', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-featured-areas'
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-enable-carousel', array(
			'default'		=>	0,
			'sanitize_callback'	=>	'absint' 
		)
	);
	
	$wp_customize->add_control(
		'phnewsfeed-enable-carousel', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewsfeed-carousel',
			  'label' => __( 'Enable Carousel','ph-news-feed' ),
			  'description' => __( 'A Sliding Carousel appears at the top of the Homepage, below the Menu Bar.','ph-news-feed' ),
			)	
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-carousel-cat', array(
			'default'		=>	0,
			'sanitize_callback'	=>	'absint'
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_WP_Customize_Category_Control(
			$wp_customize, 'phnewsfeed-carousel-cat', array(
				'label'		=>	__('Category', 'ph-news-feed'),
				'description'	=>	__('Category whose posts need to be featured..', 'ph-news-feed'),
				'priority'		=>	10,
				'section'		=>	'phnewsfeed-carousel'
				
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-carousel-count', array(
			'default'		=>	6,
			'sanitize_callback'	=>	'absint'
		)
	);
	
	$wp_customize->add_control( new WP_Customize_Control(
		$wp_customize,
		'phnewsfeed-carousel-count',
			array(
				'label'    => __( 'No. of Posts', 'ph-news-feed' ),
				'description'    => __( 'Recommended to set this value to 6 or more.', 'ph-news-feed' ),
				'section'  => 'phnewsfeed-carousel',
				'settings' => 'phnewsfeed-carousel-count',
				'type'     => 'number'
			)
		)
	);
	
	//Featured Areas Section Generator
	$i = 0;
	for ($i = 1; $i < 6; $i++) :
		$wp_customize->add_section(
			'phnewsfeed-fa-'.$i, array(
				'title'		=>	__('Featured Posts Area - ', 'ph-news-feed').$i,
				'priority'	=>	10,
				'panel'		=>	'phnewsfeed-featured-areas'
			)
		);
		
		//Enable
		$wp_customize->add_setting(
			'phnewsfeed-fa-enable-'.$i, array(
				'default'		=>	0,
				'sanitize_callback'	=>	'absint' 
			)
		);
		
		$wp_customize->add_control(
			'phnewsfeed-fa-enable-'.$i, array(
				  'type' => 'checkbox',
				  'section'		=>	'phnewsfeed-fa-'.$i,
				  'label' => __( 'Enable','ph-news-feed' ),
				  'description' => __( 'Enable this Featured Area.','ph-news-feed' ),
				)	
		);
		
		//Category Select Box
		$wp_customize->add_setting(
			'phnewsfeed-fa-cat-'.$i, array(
				'default'		=>	0,
				'sanitize_callback'	=>	'absint' 
			)
		);
		
		$wp_customize->add_control(
			new phnewsfeed_WP_Customize_Category_Control(
				$wp_customize, 'phnewsfeed-fa-cat-'.$i, array(
					'label'		=>	__('Category', 'ph-news-feed'),
					'description'	=>	__('Category whose posts need to be featured', 'ph-news-feed'),
					'priority'		=>	10,
					'section'		=>	'phnewsfeed-fa-'.$i,
				)
			)
		);
		
		//Show Title Checkbox
		$wp_customize->add_setting(
			'phnewsfeed-fa-show-title-'.$i, array(
				'default'		=>	0,
				'sanitize_callback'	=>	'absint' 
			)
		);
		
		$wp_customize->add_control(
			'phnewsfeed-fa-show-title-'.$i, array(
				  'type' => 'checkbox',
				  'section'		=>	'phnewsfeed-fa-'.$i,
				  'label' => __( 'Show Title','ph-news-feed' ),
				  'description' => __( 'By Default, the category name will appear as the title above the featured section.','ph-news-feed' ),
				)	
		);
		
		$wp_customize->add_setting(
			'phnewsfeed-fa-style-'.$i, array(
				'default' => 'style1',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_fa_style'
			)
		);
		
		$wp_customize->add_control(
			new phnewsfeed_Image_Radio_Control($wp_customize, 
				'phnewsfeed-fa-style-'.$i, array(
					'type' => 'radio',
					'label' => esc_html__('Select Featured Area Style', 'ph-news-feed'),
					'section' => 'phnewsfeed-fa-'.$i,
					'settings' => 'phnewsfeed-fa-style-'.$i,
					'choices' => array(
						'style1' => get_template_directory_uri() . '/inc/customizer/images/fa-style1.png',
						'style2' => get_template_directory_uri() . '/inc/customizer/images/fa-style2.png',
						'style3' => get_template_directory_uri() . '/inc/customizer/images/fa-style3.png',
						'style4' => get_template_directory_uri() . '/inc/customizer/images/fa-style4.png',
					)
				)
			)
		);
		
		
	endfor;	
	
}
add_action('customize_register', 'phnewsfeed_featured_areas_customize_register');