<?php

//////////////////////////////////////////////////////////////////
// Customizer - Add Settings
//////////////////////////////////////////////////////////////////
function bug_blog_register_theme_customizer( $wp_customize ) {
 	
	// Add Sections
	$wp_customize->add_section( 'bug_blog_new_section_footer' , array(
   		'title'      => __('Footer Settings', 'bug-blog'),
   		'priority'   => 103,
	) );
	$wp_customize->add_section( 'bug_blog_new_section_page' , array(
   		'title'      => __('Page Settings', 'bug-blog'),
   		'priority'   => 102,
	) );
	$wp_customize->add_section( 'bug_blog_new_section_post' , array(
   		'title'      => __('Post Settings', 'bug-blog'),
   		'priority'   => 101,
	) );
	$wp_customize->add_section( 'bug_blog_new_section_general' , array(
   		'title'      => __('General Settings', 'bug-blog'),
   		'priority'   => 100,
	) );
	
	
	
	// Add Setting
		
		// General

		$wp_customize->add_setting(
	        'bug_blog_home_layout',
	        array(
	            'default'     => 'rightsidebar',
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );

		$wp_customize->add_setting(
	        'bug_blog_blog_pagination',
	        array(
	            'default'     => 'pagination',
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );

		$wp_customize->add_setting(
	        'bug_blog_preloader',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );

		
		// Header and logo
		$wp_customize->add_setting(
	        'bug_blog_logo',
	        array(
	        	'sanitize_callback' => 'esc_url_raw'
	        )
	    );
		
		// Post Settings
		$wp_customize->add_setting(
	        'bug_blog_post_author_name',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
	    $wp_customize->add_setting(
	        'bug_blog_post_date',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
	    $wp_customize->add_setting(
	        'bug_blog_post_cat',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
	    $wp_customize->add_setting(
	        'bug_blog_post_tags',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
		$wp_customize->add_setting(
	        'bug_blog_post_author',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
	    $wp_customize->add_setting(
	        'bug_blog_post_nav',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
		$wp_customize->add_setting(
	        'bug_blog_post_related',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
		
		
		// Page Settings
		$wp_customize->add_setting(
	        'bug_blog_page_comments',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
		$wp_customize->add_setting(
	        'bug_blog_page_layout',
	        array(
	            'default'     => 'rightsidebar',
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );


		
		// Footer Options
		$wp_customize->add_setting(
	        'bug_blog_back_to_top',
	        array(
	            'default'     => false,
	            'sanitize_callback' => 'sanitize_text_field'
	        )
	    );
		$wp_customize->add_setting(
	        'bug_blog_footer_copyright',
	        array(
	            'sanitize_callback' => 'wp_kses_post'
	        )
	    );
		
		// Color Options

			// Color general
			$wp_customize->add_setting(
				'bug_blog_theme_color',
				array(
					'default'     => '#00ACDF',
					'sanitize_callback' => 'sanitize_hex_color'
				)
			);
			$wp_customize->add_setting(
				'bug_blog_anchor_color',
				array(
					'default'     => '#23b2dd',
					'sanitize_callback' => 'sanitize_hex_color'
				)
			);
			$wp_customize->add_setting(
				'bug_blog_anchor_hover_color',
				array(
					'default'     => '#00ACDF',
					'sanitize_callback' => 'sanitize_hex_color'
				)
			);


    // Add Control
		
		// General
		
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_home_layout',
				array(
					'label'          => __('Homepage Layout', 'bug-blog'),
					'section'        => 'bug_blog_new_section_general',
					'settings'       => 'bug_blog_home_layout',
					'type'           => 'radio',
					'priority'	 => 2,
					'choices'        => array(
						'full'   => __('Full Posts', 'bug-blog'),
						'rightsidebar'  => __('Right Sidebar', 'bug-blog')
					)
				)
			)
		);
		
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_blog_pagination',
				array(
					'label'          => __('Blog Pagination or Navigation', 'bug-blog'),
					'section'        => 'bug_blog_new_section_general',
					'settings'       => 'bug_blog_blog_pagination',
					'type'           => 'radio',
					'priority'	 => 3,
					'choices'        => array(
						'pagination'   => __('Pagination', 'bug-blog'),
						'navigation'  => __('Navigation', 'bug-blog')
					)
				)
			)
		);
		
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_preloader',
				array(
					'label'      => __('Disable Preloader', 'bug-blog'),
					'section'    => 'bug_blog_new_section_general',
					'settings'   => 'bug_blog_preloader',
					'type'		 => 'checkbox',
					'priority'	 => 4
				)
			)
		);
		
		// Header and Logo
		$wp_customize->add_control(
			new WP_Customize_Image_Control(
				$wp_customize,
				'bug_blog_logo',
				array(
					'label'      => __('Upload Logo', 'bug-blog'),
					'section'    => 'title_tagline',
					'settings'   => 'bug_blog_logo',
					'priority'	 => 60
				)
			)
		);
		
		
		// Post Settings

		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_author_name',
				array(
					'label'      => __('Hide Author Name', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_author_name',
					'type'		 => 'checkbox',
					'priority'	 => 1
				)
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_date',
				array(
					'label'      => __('Hide Date', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_date',
					'type'		 => 'checkbox',
					'priority'	 => 2
				)
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_cat',
				array(
					'label'      => __('Hide Category', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_cat',
					'type'		 => 'checkbox',
					'priority'	 => 3
				)
			)
		);
		
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_tags',
				array(
					'label'      => __('Hide Tags', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_tags',
					'type'		 => 'checkbox',
					'priority'	 => 4
				)
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_author',
				array(
					'label'      => __('Hide Author Box', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_author',
					'type'		 => 'checkbox',
					'priority'	 => 5
				)
			)
		);

		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_post_nav',
				array(
					'label'      => __('Hide Next/Prev Post Navigation', 'bug-blog'),
					'section'    => 'bug_blog_new_section_post',
					'settings'   => 'bug_blog_post_nav',
					'type'		 => 'checkbox',
					'priority'	 => 6
				)
			)
		);
		
		// Page settings
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_page_comments',
				array(
					'label'      => __('Hide Comments', 'bug-blog'),
					'section'    => 'bug_blog_new_section_page',
					'settings'   => 'bug_blog_page_comments',
					'type'		 => 'checkbox',
					'priority'	 => 1
				)
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_page_layout',
				array(
					'label'          => __('Page Layout', 'bug-blog'),
					'section'        => 'bug_blog_new_section_page',
					'settings'       => 'bug_blog_page_layout',
					'type'           => 'radio',
					'priority'	 => 2,
					'choices'        => array(
						'full'   => __('Fullwidth', 'bug-blog'),
						'rightsidebar'  => __('Right Sidebar', 'bug-blog')
					)
				)
			)
		);
		
		// Footer Settings

		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_back_to_top',
				array(
					'label'      => __('Disable Back to top', 'bug-blog'),
					'section'    => 'bug_blog_new_section_footer',
					'settings'   => 'bug_blog_back_to_top',
					'type'		 => 'checkbox',
					'priority'	 => 1
				)
			)
		);
		$wp_customize->add_control(
			new WP_Customize_Control(
				$wp_customize,
				'bug_blog_footer_copyright',
				array(
					'label'      => __('Footer Copyright Text', 'bug-blog'),
					'section'    => 'bug_blog_new_section_footer',
					'settings'   => 'bug_blog_footer_copyright',
					'type'		 => 'textarea',
					'priority'	 => 2
				)
			)
		);
		
		// Color Settings
			
			// Colors general
			$wp_customize->add_control(
				new WP_Customize_Color_Control(
					$wp_customize,
					'bug_blog_theme_color',
					array(
						'label'      => __('Theme Color', 'bug-blog'),
						'section'    => 'colors',
						'settings'   => 'bug_blog_theme_color',
						'priority'	 => 1
					)
				)
			);
			$wp_customize->add_control(
				new WP_Customize_Color_Control(
					$wp_customize,
					'bug_blog_anchor_color',
					array(
						'label'      => __('Anchor Color', 'bug-blog'),
						'section'    => 'colors',
						'settings'   => 'bug_blog_anchor_color',
						'priority'	 => 2
					)
				)
			);
			$wp_customize->add_control(
				new WP_Customize_Color_Control(
					$wp_customize,
					'bug_blog_anchor_hover_color',
					array(
						'label'      => __('Anchor Hover Color', 'bug-blog'),
						'section'    => 'colors',
						'settings'   => 'bug_blog_anchor_hover_color',
						'priority'	 => 3
					)
				)
			);

		
	

	
 
}
add_action( 'customize_register', 'bug_blog_register_theme_customizer' );
?>