<?php
/**
 *	Basic Settings
 *  Background Image
 *  Homepage
 *  Archives
 *  Search Results Page
 *  Page Settings
 *  Single Post Settings
 *  404 Error Page
 */ 
function phnewsfeed_basic_settings_customize_register( $wp_customize ) {
	
	$wp_customize->add_panel(
		'phnewsfeed-basic-settings', array(
			'title'		=>	__('Basic Settings', 'ph-news-feed'),
			'priority'	=>	20
		)
	);
	
	//Homepage Settings
	$wp_customize->add_section(
		'phnewsfeed-homepage', array(
			'title'		=>	__('Homepage (Blog)', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-latest-post-title', array(
			'default'		=>	__('Latest Posts','ph-news-feed'),
			'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		'phnewsfeed-latest-post-title', array(
			  'type' => 'text',
			  'section'		=>	'phnewsfeed-homepage',
			  'label' => __( 'Latest Posts Heading','ph-news-feed' ),
			  'description' => __( 'The Heading of the Section which displays the latest posts on the homepage. Below all featured areas.','ph-news-feed' ),
			)	
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-home-layout', array(
			'default' => 'style4',
			'sanitize_callback'	=>	'phnewsfeed_sanitize_fa_style'
		)
	);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-home-layout', array(
				'type' => 'radio',
				'label' => esc_html__('Latest Posts Style', 'ph-news-feed'),
				'section' => 'phnewsfeed-homepage',
				'settings' => 'phnewsfeed-home-layout',
				'input_attrs' => array('class' => 'blog_layout_chooser'),
				'choices' => array(
					'style1' => get_template_directory_uri() . '/inc/customizer/images/content-style1.png',
					'style2' => get_template_directory_uri() . '/inc/customizer/images/content-style2.png',
					'style3' => get_template_directory_uri() . '/inc/customizer/images/content-style3.png',
					'style4' => get_template_directory_uri() . '/inc/customizer/images/content-style4.png',
				)
			)
		)
	);
	
		
		
	$wp_customize->add_setting(
			'phnewsfeed-primary-width-home', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-primary-width-home', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-feed'),
				'section' => 'phnewsfeed-homepage',
				'settings' => 'phnewsfeed-primary-width-home',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'no-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no.jpg',
					'right-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right.jpg',
					'right-sidebar-narrow' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right-narrow.jpg',
					'no-sidebar-narrow-primary' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no-narrow-primary.jpg',
				)
			)
		)
	);
	
	//Background Image
	$wp_customize->get_section('background_image')->panel = 'phnewsfeed-basic-settings';
	$wp_customize->get_section('background_image')->priority = 5;
	
	//Archives
	$wp_customize->add_section(
		'phnewsfeed-archives', array(
			'title'		=>	__('Archives (Category/Tags)', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-archive-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Custom_Notice_Control(
			$wp_customize, 'pixahive-archive-message', array(
				'label'		=>	__('Archive Settings', 'ph-news-feed'),
				'description'	=>	__('Use this section to customize the layout of Category and Tag Archive pages. This will also support any other custom taxonomies. Navigate to an archive page to view changes on the right side.', 'ph-news-feed'),
				'priority'		=>	1,
				'section'		=>	'phnewsfeed-archives',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-archives-layout', array(
			'default' => 'style4',
			'sanitize_callback'	=>	'phnewsfeed_sanitize_fa_style'
		)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-archives-layout', array(
				'type' => 'radio',
				'label' => esc_html__('Select Content Style', 'ph-news-feed'),
				'section' => 'phnewsfeed-archives',
				'settings' => 'phnewsfeed-archives-layout',
				'input_attrs' => array('class' => 'blog_layout_chooser'),
				'choices' => array(
					'style1' => get_template_directory_uri() . '/inc/customizer/images/content-style1.png',
					'style2' => get_template_directory_uri() . '/inc/customizer/images/content-style2.png',
					'style3' => get_template_directory_uri() . '/inc/customizer/images/content-style3.png',
					'style4' => get_template_directory_uri() . '/inc/customizer/images/content-style4.png',
				)
			)
		)
	);
		
		
	$wp_customize->add_setting(
			'phnewsfeed-primary-width-archives', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-primary-width-archives', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-feed'),
				'section' => 'phnewsfeed-archives',
				'settings' => 'phnewsfeed-primary-width-archives',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'no-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no.jpg',
					'right-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right.jpg',
					'right-sidebar-narrow' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right-narrow.jpg',
					'no-sidebar-narrow-primary' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no-narrow-primary.jpg',
				)
			)
		)
	);
		
	//Page Settings.
	$wp_customize->add_section(
		'phnewsfeed-page-settings', array(
			'title'		=>	__('Pages', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-page-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Custom_Notice_Control(
			$wp_customize, 'pixahive-page-message', array(
				'label'		=>	__('Page Settings', 'ph-news-feed'),
				'description'	=>	__('Use this section to customize the layout of pages of your site.', 'ph-news-feed'),
				'priority'		=>	1,
				'section'		=>	'phnewsfeed-page-settings',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-primary-width-page', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-primary-width-page', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-feed'),
				'section' => 'phnewsfeed-page-settings',
				'settings' => 'phnewsfeed-primary-width-page',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'no-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no.jpg',
					'right-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right.jpg',
					'right-sidebar-narrow' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right-narrow.jpg',
					'no-sidebar-narrow-primary' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no-narrow-primary.jpg',
				)
			)
		)
	);
	
	//Single Post Settings.
	$wp_customize->add_section(
		'phnewsfeed-single-post', array(
			'title'		=>	__('Single Posts', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-single-post-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Custom_Notice_Control(
			$wp_customize, 'pixahive-single-post-message', array(
				'label'		=>	__('Single Post Settings', 'ph-news-feed'),
				'description'	=>	__('Use this section to customize the layout of Single Posts. Navigate to one of the published posts to view changes on the right side.', 'ph-news-feed'),
				'priority'		=>	1,
				'section'		=>	'phnewsfeed-single-post',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-single-post-style', array(
				'default'	=>	'style2',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_fa_style'
			)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-single-post-style', array(
				'type' => 'radio',
				'label' => esc_html__('Post Style', 'ph-news-feed'),
				'section' => 'phnewsfeed-single-post',
				'settings' => 'phnewsfeed-single-post-style',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'style1' => get_template_directory_uri() . '/inc/customizer/images/single-style1.png',
					'style2' => get_template_directory_uri() . '/inc/customizer/images/single-style2.png',
				)
			)
		)
	);	
	
	$wp_customize->add_setting(
		'phnewsfeed-primary-width-single-post', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewsfeed_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-primary-width-single-post', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-feed'),
				'section' => 'phnewsfeed-single-post',
				'settings' => 'phnewsfeed-primary-width-single-post',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'no-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no.jpg',
					'right-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right.jpg',
					'right-sidebar-narrow' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right-narrow.jpg',
					'no-sidebar-narrow-primary' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no-narrow-primary.jpg',
				)
			)
		)
	);	
	
	//Search Results Page
	$wp_customize->add_section(
		'phnewsfeed-search-results', array(
			'title'		=>	__('Search Results Page', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-search-results-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Custom_Notice_Control(
			$wp_customize, 'pixahive-search-results-message', array(
				'label'		=>	__('Search Results Settings', 'ph-news-feed'),
				'description'	=>	__('Use this section to customize the layout of results on Search Pages. Perform a search on the right hand side so you can view changes.', 'ph-news-feed'),
				'priority'		=>	1,
				'section'		=>	'phnewsfeed-search-results',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-search-results-layout', array(
			'default' => 'style4',
			'sanitize_callback'	=>	'phnewsfeed_sanitize_fa_style'
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-search-results-layout', array(
				'type' => 'radio',
				'label' => esc_html__('Select Content Style', 'ph-news-feed'),
				'section' => 'phnewsfeed-search-results',
				'settings' => 'phnewsfeed-search-results-layout',
				'input_attrs' => array('class' => 'blog_layout_chooser'),
				'choices' => array(
					'style1' => get_template_directory_uri() . '/inc/customizer/images/content-style1.png',
					'style2' => get_template_directory_uri() . '/inc/customizer/images/content-style2.png',
					'style3' => get_template_directory_uri() . '/inc/customizer/images/content-style3.png',
					'style4' => get_template_directory_uri() . '/inc/customizer/images/content-style4.png',
				)
			)
		)
	);
	
	
	$wp_customize->add_setting(
		'phnewsfeed-primary-width-search', array(
			'default'	=>	'no-sidebar-narrow-primary',
			'sanitize_callback'	=>	'phnewsfeed_sanitize_sidebar_layout'
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Image_Radio_Control($wp_customize, 
			'phnewsfeed-primary-width-search', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-feed'),
				'section' => 'phnewsfeed-search-results',
				'settings' => 'phnewsfeed-primary-width-search',
				'input_attrs' => array('class' => 'sidebar_layout_chooser'),
				'choices' => array(
					'no-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no.jpg',
					'right-sidebar' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right.jpg',
					'right-sidebar-narrow' => get_template_directory_uri() . '/inc/customizer/images/sidebar-right-narrow.jpg',
					'no-sidebar-narrow-primary' => get_template_directory_uri() . '/inc/customizer/images/sidebar-no-narrow-primary.jpg',
				)
			)
		)
	);
	
	
	//404 Error Page Settings.
	$wp_customize->add_section(
		'phnewsfeed-404-error', array(
			'title'		=>	__('404 Error Page', 'ph-news-feed'),
			'priority'	=>	10,
			'panel'		=>	'phnewsfeed-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-404page-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewsfeed_Custom_Notice_Control(
			$wp_customize, 'pixahive-404page-message', array(
				'label'		=>	__('404 Page', 'ph-news-feed'),
				'description'	=>	__('Use this page to customize the 404 Error Page.', 'ph-news-feed'),
				'priority'		=>	1,
				'section'		=>	'phnewsfeed-404-error',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewsfeed-enable-404-posts', array(
			'default'		=>	1,
			'sanitize_callback'	=>	'absint' 
		)
	);
		
	$wp_customize->add_control(
		'phnewsfeed-enable-404-posts', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewsfeed-404-error',
			  'label' => __( 'Show Latest Posts on 404 Page','ph-news-feed' ),
			)	
	);

	// Scroll to Top
	$wp_customize-> add_section('phnewsfeed-scrl-to-top', array(
		'title'                    => __('Scroll to Top','ph-news-feed'),
		'description'              => __('Check the box to disable scroll to top','ph-news-feed'),
	
	 ));
	
	 $wp_customize-> add_setting('phnewsfeed-scrl-to-top-set', array(
		'type'                     => 'theme_mod',
		'sanitize_callback'        => 'phnewsfeed_sanitize_checkbox',
	 ));
	 
	 $wp_customize-> add_control( 'phnewsfeed-scrl-to-top', array(
		'label'                   => __('Enable Scroll to Top','ph-news-feed'),
		'description'             => __('Check the box to disable scroll to top','ph-news-feed'),
		'section'                 => 'phnewsfeed-scrl-to-top',
		'settings'                => 'phnewsfeed-scrl-to-top-set',
		'type'                    => 'checkbox',
	 ));
	
	 	 //checkbox sanitization 
		  function phnewsfeed_sanitize_checkbox( $input ) {
	
			// Boolean check 
			return ( ( isset( $input ) && true == $input ) ? true : false );
		}
	
	
}
add_action('customize_register', 'phnewsfeed_basic_settings_customize_register');