<?php
/**
 *	Sidebar Recent Posts
 *  Featured Post Footer
 *  Scroll to Top
 */ 
function phnewspaper_general_settings_customize_register( $wp_customize ) {
	$wp_customize->add_panel(
		'phnewspaper-additional-settings', array(
			'title'		=>	__('PH News Paper Options', 'ph-news-paper'),
			'priority'	=>	20
		)
	);

	// Scroll to Top
	$wp_customize-> add_section('phnewspaper-scrl-to-top', array(
		'title'                    => __('Scroll to Top','ph-news-paper'),
		'description'              => __('Check the box to disable scroll to top','ph-news-paper'),
		'panel'                    => 'phnewspaper-additional-settings'

	 ));
	
	 $wp_customize-> add_setting('phnewspaper-scrl-to-top-set', array(
		'type'                     => 'theme_mod',
		'sanitize_callback'        => 'phnewspaper_sanitize_checkbox',
	 ));
	 
	 $wp_customize-> add_control( 'phnewspaper-scrl-to-top', array(
		'label'                   => __('Enable Scroll to Top','ph-news-paper'),
		'description'             => __('Check the box to disable scroll to top','ph-news-paper'),
		'section'                 => 'phnewspaper-scrl-to-top',
		'settings'                => 'phnewspaper-scrl-to-top-set',
		'type'                    => 'checkbox',
	 ));

	 //checkbox sanitization 
	function phnewspaper_sanitize_checkbox( $input ) {
	
		// Boolean check 
		return ( ( isset( $input ) && true == $input ) ? true : false );
	}
     
	// BreadCrumbs
	 $wp_customize-> add_section('phnewspaper-breadcrumbs', array(
		'title'                    => __('Breadcrumbs','ph-news-paper'),
		'description'              => __('Check the box to enable Breadcrumbs','ph-news-paper'),
		'panel'                    => 'phnewspaper-additional-settings'

	 ));
	
	 $wp_customize-> add_setting('phnewspaper-breadcrumbs_set', array(
		'type'                     => 'theme_mod',
		'sanitize_callback'        => 'phnewspaper_sanitize_checkbox'
	 ));

	 $wp_customize-> add_control( 'phnewspaper-breadcrumbs_ctrl', array(
		'label'                   => __('Breadcrumbs','ph-news-paper'),
		'description'             => __('Check the box to enable Breadcrumbs','ph-news-paper'),
		'section'                 => 'phnewspaper-breadcrumbs',
		'settings'                => 'phnewspaper-breadcrumbs_set',
		'type'                    => 'checkbox',
	 ));

	   
	// BreadCrumbs
	$wp_customize-> add_section('phnewspaper-enable-search-bar', array(
		'title'                    => __('Show/Hide Search Bar','ph-news-paper'),
		'description'              => __('Check the box to display search bar','ph-news-paper'),
		'panel'                    => 'phnewspaper-additional-settings'

	 ));
	
	 $wp_customize-> add_setting('phnewspaper-enable-search-bar', array(
		'type'                     => 'theme_mod',
		'sanitize_callback'        => 'phnewspaper_sanitize_checkbox'
	 ));

	 $wp_customize-> add_control( 'phnewspaper-enable-search-bar_ctrl', array(
		'label'                   => __('Show/Hide Search Bar','ph-news-paper'),
		'description'             => __('Check the box to display search bar','ph-news-paper'),
		'section'                 => 'phnewspaper-enable-search-bar',
		'settings'                => 'phnewspaper-enable-search-bar',
		'type'                    => 'checkbox',
	 ));

	 
	 // Add a section within the panel for sticky sidebar
	$wp_customize->add_section( 'phnewspaper-sticky-sidebar', array(
		'title'    => __( 'Sticky Sidebar', 'ph-news-paper' ),
		'priority' => 30,
		'panel'    => 'phnewspaper-additional-settings', // Associate with the 'General Settings' panel
	) );

// Add a setting for sticky sidebar
	$wp_customize->add_setting( 'phnewspaper-sticky-sidebar-set', array(
		'default'           => true,
		'sanitize_callback' => 'phnewspaper_sanitize_checkbox', 
	) );

// Add a control to set the excerpt length
	$wp_customize->add_control( 'phnewspaper-sticky-sidebar_ctrl', array(
		'label'    => __( 'Sticky Sidebar', 'ph-news-paper' ),
		'section'  => 'phnewspaper-sticky-sidebar',
		'settings' => 'phnewspaper-sticky-sidebar-set',
		'type'     => 'checkbox',
		'description' => 'Check the box to enable sticky sidebar',
		'priority' => 10,
	) );
	}
add_action('customize_register', 'phnewspaper_general_settings_customize_register');