<?php
/**
 *	Basic Settings
 *  Background Image
 *  Homepage
 *  Archives
 *  Search Results Page
 *  Page Settings
 *  Single Post Settings
 *  404 Error Page
 */ 
function phnewspaper_basic_settings_customize_register( $wp_customize ) {
	
	$wp_customize->add_panel(
		'phnewspaper-basic-settings', array(
			'title'		=>	__('Basic Settings', 'ph-news-paper'),
			'priority'	=>	20
		)
	);
	
	//Homepage Settings
	$wp_customize->add_section(
		'phnewspaper-homepage', array(
			'title'		=>	__('Homepage (Blog)', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting(
		'phnewspaper-latest-post-title', array(
			'default'		=>	__('Latest Story','ph-news-paper'),
			'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		'phnewspaper-latest-post-title', array(
			  'type' => 'text',
			  'section'		=>	'phnewspaper-homepage',
			  'label' => __( 'Latest Posts Heading','ph-news-paper' ),
			  'description' => __( 'The Heading of the Section which displays the latest posts on the homepage. Below all featured areas.','ph-news-paper' ),
			)	
	);
	
	$wp_customize->add_setting(
		'phnewspaper-home-layout', array(
			'default' => 'style2',
			'sanitize_callback'	=>	'phnewspaper_sanitize_fa_style'
		)
	);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-home-layout', array(
				'type' => 'radio',
				'label' => esc_html__('Latest Posts Style', 'ph-news-paper'),
				'section' => 'phnewspaper-homepage',
				'settings' => 'phnewspaper-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',
				)
			)
		)
	);
	
	$wp_customize->add_setting(
			'phnewspaper-primary-width-home', array(
				'default'	=>	'right-sidebar',
				'sanitize_callback'	=>	'phnewspaper_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-primary-width-home', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-paper'),
				'section' => 'phnewspaper-homepage',
				'settings' => 'phnewspaper-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 = 'phnewspaper-basic-settings';
	$wp_customize->get_section('background_image')->priority = 5;
	
	//Archives
	$wp_customize->add_section(
		'phnewspaper-archives', array(
			'title'		=>	__('Archives (Category/Tags)', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-archive-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	
			
	$wp_customize->add_setting(
			'phnewspaper-primary-width-archives', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewspaper_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-primary-width-archives', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-paper'),
				'section' => 'phnewspaper-archives',
				'settings' => 'phnewspaper-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(
		'phnewspaper-page-settings', array(
			'title'		=>	__('Pages', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-page-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewspaper_Custom_Notice_Control(
			$wp_customize, 'pixahive-page-message', array(
				'label'		=>	__('Page Settings', 'ph-news-paper'),
				'description'	=>	__('Use this section to customize the layout of pages of your site.', 'ph-news-paper'),
				'priority'		=>	1,
				'section'		=>	'phnewspaper-page-settings',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewspaper-primary-width-page', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewspaper_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-primary-width-page', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-paper'),
				'section' => 'phnewspaper-page-settings',
				'settings' => 'phnewspaper-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(
		'phnewspaper-single-post', array(
			'title'		=>	__('Single Posts', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-single-post-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewspaper_Custom_Notice_Control(
			$wp_customize, 'pixahive-single-post-message', array(
				'label'		=>	__('Single Post Settings', 'ph-news-paper'),
				'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-paper'),
				'priority'		=>	1,
				'section'		=>	'phnewspaper-single-post',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewspaper-single-post-style', array(
				'default'	=>	'style3',
				'sanitize_callback'	=>	'phnewspaper_sanitize_fa_style'
			)
		);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-single-post-style', array(
				'type' => 'radio',
				'label' => esc_html__('Post Style', 'ph-news-paper'),
				'section' => 'phnewspaper-single-post',
				'settings' => 'phnewspaper-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',
					'style3' => get_template_directory_uri() . '/inc/customizer/images/single-style3.png',
				)
			)
		)
	);	
	
	$wp_customize->add_setting(
		'phnewspaper-primary-width-single-post', array(
				'default'	=>	'no-sidebar-narrow-primary',
				'sanitize_callback'	=>	'phnewspaper_sanitize_sidebar_layout'
			)
		);
		
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-primary-width-single-post', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-paper'),
				'section' => 'phnewspaper-single-post',
				'settings' => 'phnewspaper-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(
		'phnewspaper-search-results', array(
			'title'		=>	__('Search Results Page', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-search-results-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);

	$wp_customize->add_setting(
		'phnewspaper-primary-width-search', array(
			'default'	=>	'no-sidebar-narrow-primary',
			'sanitize_callback'	=>	'phnewspaper_sanitize_sidebar_layout'
		)
	);
	
	$wp_customize->add_control(
		new phnewspaper_Image_Radio_Control($wp_customize, 
			'phnewspaper-primary-width-search', array(
				'type' => 'radio',
				'label' => esc_html__('Sidebar Layout', 'ph-news-paper'),
				'section' => 'phnewspaper-search-results',
				'settings' => 'phnewspaper-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(
		'phnewspaper-404-error', array(
			'title'		=>	__('404 Error Page', 'ph-news-paper'),
			'priority'	=>	10,
			'panel'		=>	'phnewspaper-basic-settings'
		)
	);
	
	$wp_customize->add_setting('pixahive-404page-message', array(
		'sanitize_callback'	=>	'sanitize_text_field' 
		)
	);
	
	$wp_customize->add_control(
		new phnewspaper_Custom_Notice_Control(
			$wp_customize, 'pixahive-404page-message', array(
				'label'		=>	__('404 Page', 'ph-news-paper'),
				'description'	=>	__('Use this page to customize the 404 Error Page.', 'ph-news-paper'),
				'priority'		=>	1,
				'section'		=>	'phnewspaper-404-error',
			)
		)
	);
	
	$wp_customize->add_setting(
		'phnewspaper-enable-404-posts', array(
			'default'		=>	1,
			'sanitize_callback'	=>	'absint' 
		)
	);
		
	$wp_customize->add_control(
		'phnewspaper-enable-404-posts', array(
			  'type' => 'checkbox',
			  'section'		=>	'phnewspaper-404-error',
			  'label' => __( 'Show Latest Posts on 404 Page','ph-news-paper' ),
			)	
	);
	
	
	
}
add_action('customize_register', 'phnewspaper_basic_settings_customize_register');