<?php
/**
 * Grocery Supermarket Chain Theme Customizer
 *
 * @package Grocery Supermarket Chain
 */

// Customize Controls.
require get_template_directory() . '/inc/custom-settings-control/customize-controls.php';

// Customize Controls.
require get_template_directory() . '/inc/custom-range-controls.php';

// Sanitization For Customize Controls.
require get_template_directory() . '/inc/custom-settings-control/sanitization.php';


/**
 * Provide postMessage support for the Theme Customizer's site title and description.
 */
function grocery_supermarket_chain_customize_register( $wp_customize ) {

	// General Settings Panel.
    $wp_customize->add_panel( 'grocery_supermarket_chain_general_settings_panel',
        array(
            'title'      => esc_html__( 'General Settings', 'grocery-supermarket-chain' ),
            'priority'   => 2,
            'capability' => 'edit_theme_options',
        )
    );

	// Header Settings Panel.
	$wp_customize->add_panel( 'grocery_supermarket_chain_header_settings_panel',
		array(
			'title'      => esc_html__( 'Header Settings', 'grocery-supermarket-chain' ),
			'priority'   => 2,
			'capability' => 'edit_theme_options',
		)
	);

	// Frontpage Sections Settings Panel.
	$wp_customize->add_panel( 'grocery_supermarket_chain_frontpage_sections_settings_panel',
		array(
			'title'      => esc_html__( 'Frontpage Sections Settings', 'grocery-supermarket-chain' ),
			'priority'   => 3,
			'capability' => 'edit_theme_options',
		)
	);

	// Footer Settings Panel.
	$wp_customize->add_panel( 'grocery_supermarket_chain_footer_settings_panel',
		array(
			'title'      => esc_html__( 'Footer Settings', 'grocery-supermarket-chain' ),
			'priority'   => 3,
			'capability' => 'edit_theme_options',
		)
	);

	// Site Identity

	$wp_customize->get_section( 'title_tagline' )->panel = 'grocery_supermarket_chain_header_settings_panel';

	$wp_customize->add_setting(
		'grocery_supermarket_chain_site_logo',
		array(
			'default'           => false,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new grocery_supermarket_chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_site_logo',
			array(
				'label'    => esc_html__( 'ON / OFF Site Logo', 'grocery-supermarket-chain' ),
				'section'  => 'title_tagline',
				'settings' => 'grocery_supermarket_chain_site_logo',
			)
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_site_title_text',
		array(
			'default'           => true,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new grocery_supermarket_chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_site_title_text',
			array(
				'label'    => esc_html__( 'ON / OFF Site Title', 'grocery-supermarket-chain' ),
				'section'  => 'title_tagline',
				'settings' => 'grocery_supermarket_chain_site_title_text',
			)
		)
	);

	


	$wp_customize->add_setting(
        'grocery_supermarket_chain_title_font_size',
        array(
            'default'    => 25,
            'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number_range',
        )
    );

    $wp_customize->add_control(
        new grocery_supermarket_chain_Slider(
            $wp_customize,
            'grocery_supermarket_chain_title_font_size',
            array(
                'label'    => esc_html__( 'Site Title Font Size', 'grocery-supermarket-chain' ),
                'section'  => 'title_tagline',
                'label' => esc_html__('Site Title Font Size', 'grocery-supermarket-chain'),
                'input_attrs' => array(
					'reset'			   => 25,
		            'step'             => 1,
					'min'              => 0,
					'max'              => 50,
		        ),
            )
        )
    );


   


	$wp_customize->add_setting(
		'grocery_supermarket_chain_site_tagline_text',
		array(
			'default'           => false,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new grocery_supermarket_chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_site_tagline_text',
			array(
				'label'    => esc_html__( 'ON / OFF Site Tagline', 'grocery-supermarket-chain' ),
				'section'  => 'title_tagline',
				'settings' => 'grocery_supermarket_chain_site_tagline_text',
			)
		)
	);

	

	$wp_customize->add_setting(
        'grocery_supermarket_chain_site_tagline_font_size',
        array(
            'default'    => 15,
            'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number_range',
        )
    );

    $wp_customize->add_control(
        new grocery_supermarket_chain_Slider(
            $wp_customize,
            'grocery_supermarket_chain_site_tagline_font_size',
            array(
                'label'    => esc_html__( 'Tagline Font Size', 'grocery-supermarket-chain' ),
                'section'  => 'title_tagline',
                'label' => esc_html__('Tagline Font Size', 'grocery-supermarket-chain'),
                'input_attrs' => array(
					'reset'			   => 15,
		            'step'             => 1,
					'min'              => 0,
					'max'              => 50,
		        ),
            )
        )
    );

    //Woo Coomerce
    $wp_customize->add_setting('grocery_supermarket_chain_per_columns',array(
        'default'=> 3,
        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number_absint'
    ));
    $wp_customize->add_control('grocery_supermarket_chain_per_columns',array(
        'label' => __('Product Per Row','grocery-supermarket-chain'),
        'section'=> 'woocommerce_product_catalog',
        'type'=> 'number',
        'input_attrs' => array(
            'min' => 1,
            'max' => 6,
            'step' => 1,
        ),
    ));
    $wp_customize->add_setting('grocery_supermarket_chain_product_per_page',array(
        'default'=> 10,
        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number_absint'
    ));
    $wp_customize->add_control('grocery_supermarket_chain_product_per_page',array(
        'label' => __('Product Per Page','grocery-supermarket-chain'),
        'section'=> 'woocommerce_product_catalog',
        'type'=> 'number',
        'input_attrs' => array(
            'min' => 1,
            'max' => 20,
            'step' => 1,
        ),
    ));

    $wp_customize->add_section(
		'woocommerce_product_extra_section',
		array(
			'panel'      => 'woocommerce',
			'title'    => esc_html__( 'Extra WooCommerce Settings', 'grocery-supermarket-chain' ),
		)
	);

    $wp_customize->add_setting( 'grocery_supermarket_chain_single_product_sidebar', array(
		'default'           => true,
		'transport'         => 'refresh',
		'sanitize_callback' => 'grocery_supermarket_chain_sanitize_checkbox',
	) );
	$wp_customize->add_control( new grocery_supermarket_chain_On_Off_Custom_Control( $wp_customize, 'grocery_supermarket_chain_single_product_sidebar', array(
		'label'       => esc_html__( 'Show / Hide Product Page Sidebar', 'grocery-supermarket-chain' ),
		'section'     => 'woocommerce_product_extra_section',
		'type'        => 'toggle',
		'settings'    => 'grocery_supermarket_chain_single_product_sidebar',
	) ) );

	// Header Options

	$wp_customize->add_section(
		'grocery_supermarket_chain_header_section',
		array(
			'panel'      => 'grocery_supermarket_chain_header_settings_panel',
			'title'    => esc_html__( 'Header Options', 'grocery-supermarket-chain' ),
		)
	);

	//MENU TYPOGRAPHY
	
	$wp_customize->add_setting('grocery_supermarket_chain_menu_font_weight',array(
        'default' => '',
        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_choices'
	));
	$wp_customize->add_control('grocery_supermarket_chain_menu_font_weight',array(
     'type' => 'radio',
     'label'     => __('Menu Font Weight', 'grocery-supermarket-chain'),
     'section' => 'grocery_supermarket_chain_header_section',
     'type' => 'select',
     'choices' => array(
         '100' => __('100','grocery-supermarket-chain'),
         '200' => __('200','grocery-supermarket-chain'),
         '300' => __('300','grocery-supermarket-chain'),
         '400' => __('400','grocery-supermarket-chain'),
         '500' => __('500','grocery-supermarket-chain'),
         '600' => __('600','grocery-supermarket-chain'),
         '700' => __('700','grocery-supermarket-chain'),
         '800' => __('800','grocery-supermarket-chain'),
         '900' => __('900','grocery-supermarket-chain')
     ),
	) );
	
	$wp_customize->add_setting('grocery_supermarket_chain_menu_text_tranform',array(
		'default' => 'Capitalize',
		'sanitize_callback' => 'grocery_supermarket_chain_sanitize_choices'
 	));
 	$wp_customize->add_control('grocery_supermarket_chain_menu_text_tranform',array(
		'type' => 'select',
		'label' => __('Menu Text Transform','grocery-supermarket-chain'),
		'section' => 'grocery_supermarket_chain_header_section',
		'choices' => array(
		   'Uppercase' => __('Uppercase','grocery-supermarket-chain'),
		   'Lowercase' => __('Lowercase','grocery-supermarket-chain'),
		   'Capitalize' => __('Capitalize','grocery-supermarket-chain'),
		),
	) );
	$wp_customize->add_setting('grocery_supermarket_chain_menu_font_size', array(
	    'default'	=> 17,
        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number_range',
	));
	$wp_customize->add_control(new grocery_supermarket_chain_Slider($wp_customize, 'grocery_supermarket_chain_menu_font_size', array(
        'section' => 'grocery_supermarket_chain_header_section',
        'label' => esc_html__('Menu Font Size', 'grocery-supermarket-chain'),
        'input_attrs' => array(
					'reset'			   => 17,
		            'step'             => 1,
					'min'              => 0,
					'max'              => 35,
		        ),
	)));

	$wp_customize->add_setting(
		'grocery_supermarket_chain_sticky_header',
		array(
			'default'           => false,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new grocery_supermarket_chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_sticky_header',
			array(
				'label'    => esc_html__( 'ON / OFF Sticky Header', 'grocery-supermarket-chain' ),
				'section'  => 'grocery_supermarket_chain_header_section',
				'settings' => 'grocery_supermarket_chain_sticky_header',
			)
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_email_address',
		array(
			'default'           => 'supermarket@example.com',
			'sanitize_callback' => 'sanitize_email',
		)
	);
	
	$wp_customize->add_control(
		'grocery_supermarket_chain_email_address',
		array(
			'label'           => esc_html__( 'Add Email Address', 'grocery-supermarket-chain' ),
			'section'         => 'grocery_supermarket_chain_header_section',
			'settings'        => 'grocery_supermarket_chain_email_address',
			'type'            => 'email',
		)
	);
	

	$wp_customize->add_setting(
		'grocery_supermarket_chain_phone_number',
		array(
			'default'           => '00 12321545648',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	
	$wp_customize->add_control(
		'grocery_supermarket_chain_phone_number',
		array(
			'label'           => esc_html__( 'Add Phone Number', 'grocery-supermarket-chain' ),
			'section'         => 'grocery_supermarket_chain_header_section',
			'settings'        => 'grocery_supermarket_chain_phone_number',
			'type'            => 'text',
		)
	);


	// Social Option

	$wp_customize->add_section(
		'grocery_supermarket_chain_social_section',
		array(
			'panel'      => 'grocery_supermarket_chain_header_settings_panel',
			'title'    => esc_html__( 'Social Options', 'grocery-supermarket-chain' ),
		)
	);

    $wp_customize->add_setting(
        'grocery_supermarket_chain_facebook_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

	$wp_customize->add_control(
        'grocery_supermarket_chain_facebook_url',
        array(
            'label'           => sprintf( esc_html__( 'Add Facebook Link', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_social_section',
            'settings'        => 'grocery_supermarket_chain_facebook_url' ,
            'type'            => 'url',
        )
    );

	$wp_customize->add_setting(
        'grocery_supermarket_chain_twitter_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

	$wp_customize->add_control(
        'grocery_supermarket_chain_twitter_url',
        array(
            'label'           => sprintf( esc_html__( 'Add Twitter Link', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_social_section',
            'settings'        => 'grocery_supermarket_chain_twitter_url' ,
            'type'            => 'url',
        )
    );

    $wp_customize->add_setting(
        'grocery_supermarket_chain_instagram_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

	$wp_customize->add_control(
        'grocery_supermarket_chain_instagram_url',
        array(
            'label'           => sprintf( esc_html__( 'Add Instagram Link', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_social_section',
            'settings'        => 'grocery_supermarket_chain_instagram_url' ,
            'type'            => 'url',
        )
    );

    $wp_customize->add_setting(
        'grocery_supermarket_chain_youtube_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

	$wp_customize->add_control(
        'grocery_supermarket_chain_youtube_url',
        array(
            'label'           => sprintf( esc_html__( 'Add Youtube Link', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_social_section',
            'settings'        => 'grocery_supermarket_chain_youtube_url' ,
            'type'            => 'url',
        )
    );

	$wp_customize->add_setting(
        'grocery_supermarket_chain_whatsapp_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

	$wp_customize->add_control(
        'grocery_supermarket_chain_whatsapp_url',
        array(
            'label'           => sprintf( esc_html__( 'Add Whatsapp Link', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_social_section',
            'settings'        => 'grocery_supermarket_chain_whatsapp_url' ,
            'type'            => 'url',
        )
    );
	
	// Banner Option

	$wp_customize->add_section(
		'grocery_supermarket_chain_banner_section',
		array(
			'panel'      => 'grocery_supermarket_chain_frontpage_sections_settings_panel',
			'title'    => esc_html__( 'Banner Options', 'grocery-supermarket-chain' ),
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_banner_section_on_off_setting',
		array(
			'default'           => false,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new Grocery_Supermarket_Chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_banner_section_on_off_setting',
			array(
				'label'    => esc_html__( 'ON / OFF Banner Section', 'grocery-supermarket-chain' ),
				'section'  => 'grocery_supermarket_chain_banner_section',
				'settings' => 'grocery_supermarket_chain_banner_section_on_off_setting',
			)
		)
	);

	$wp_customize->add_setting(
	    'grocery_supermarket_chain_slider',
	    array(
	        'default'           => '',
	        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_number',
	    )
	);

	$wp_customize->add_control(
	    'grocery_supermarket_chain_slider',
	    array(
	        'label'       => esc_html__( 'No of banner', 'grocery-supermarket-chain' ),
	        'section'     => 'grocery_supermarket_chain_banner_section',
	        'settings'    => 'grocery_supermarket_chain_slider',
	        'type'        => 'number',
	        'input_attrs' => array(
	            'min' => 1,
	            'max' => 3,
	        ),
	    )
	);

	$grocery_supermarket_chain_banner = get_theme_mod( 'grocery_supermarket_chain_slider');
	for ( $i = 1; $i <= $grocery_supermarket_chain_banner; $i++ ){
		$wp_customize->add_setting(
			'grocery_supermarket_chain_banner_short_heading'.$i,
			array(
				'default'           => '',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'grocery_supermarket_chain_banner_short_heading'.$i,
				array(
				'label'           => sprintf( esc_html__( 'Banner Short Heading 0', 'grocery-supermarket-chain' ).$i, ),
				'section'         => 'grocery_supermarket_chain_banner_section',
				'settings'        => 'grocery_supermarket_chain_banner_short_heading'.$i,
				'type'            => 'text',
			)
		);

		$wp_customize->add_setting(
			'grocery_supermarket_chain_banner_heading'.$i,
			array(
				'default'           => '',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			'grocery_supermarket_chain_banner_heading'.$i,
			array(
				'label'           => sprintf( esc_html__( 'Banner Heading 0', 'grocery-supermarket-chain' ).$i, ),
				'section'         => 'grocery_supermarket_chain_banner_section',
				'settings'        => 'grocery_supermarket_chain_banner_heading'.$i,
				'type'            => 'text',
			)
		);

        $wp_customize->add_setting(
            'grocery_supermarket_chain_banner_btn'.$i,
            array(
                'default'           => '',
                'sanitize_callback' => 'sanitize_text_field',
            )
        );

        $wp_customize->add_control(
            'grocery_supermarket_chain_banner_btn'.$i,
            array(
                'label'           => sprintf( esc_html__( 'Banner Button 0', 'grocery-supermarket-chain' ).$i, ),
                'section'         => 'grocery_supermarket_chain_banner_section',
                'settings'        => 'grocery_supermarket_chain_banner_btn'.$i,
                'type'            => 'text',
            )
        );

		$wp_customize->add_setting(
			'grocery_supermarket_chain_banner_button_link'.$i,
			array(
				'default'           => '',
				'sanitize_callback' => 'esc_url_raw',
			)
		);

		$wp_customize->add_control(
			'grocery_supermarket_chain_banner_button_link'.$i,
			array(
				'label'           => sprintf( esc_html__( 'Banner Button Link 0', 'grocery-supermarket-chain' ).$i, ),
				'section'         => 'grocery_supermarket_chain_banner_section',
				'settings'        => 'grocery_supermarket_chain_banner_button_link'.$i,
				'type'            => 'url',
			)
		);
		
		$wp_customize->add_setting(
			'grocery_supermarket_chain_banner_image'.$i,
			array(
	        	'default'           => '',
	        	'sanitize_callback' => 'grocery_supermarket_chain_sanitize_image',

	    	)
	    );
	    
	    $wp_customize->add_control(
	     	new WP_Customize_Image_Control(
	    		$wp_customize, 'grocery_supermarket_chain_banner_image'.$i, 
	    		array(
	    			'label'           => sprintf( esc_html__( 'Banner Image 0', 'grocery-supermarket-chain' ).$i, ),
			        'settings'  => 'grocery_supermarket_chain_banner_image'.$i,
			        'section'   => 'grocery_supermarket_chain_banner_section'
	    		) 
	    	)
	    );
	}

    // Product Option

	$wp_customize->add_section(
		'grocery_supermarket_chain_product_section',
		array(
			'panel'      => 'grocery_supermarket_chain_frontpage_sections_settings_panel',
			'title'    => esc_html__( 'Product Options', 'grocery-supermarket-chain' ),
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_product_section_on_off_setting',
		array(
			'default'           => false,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new Grocery_Supermarket_Chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_product_section_on_off_setting',
			array(
				'label'    => esc_html__( 'ON / OFF Product Section', 'grocery-supermarket-chain' ),
				'section'  => 'grocery_supermarket_chain_product_section',
				'settings' => 'grocery_supermarket_chain_product_section_on_off_setting',
			)
		)
	);

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

	$wp_customize->add_control(
        'grocery_supermarket_chain_product_heading',
        array(
            'label'           => sprintf( esc_html__( 'Product Heading', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_product_section',
            'settings'        => 'grocery_supermarket_chain_product_heading' ,
            'type'            => 'text',
        )
    );

	// Post Categories
	$categories = get_terms(array(
	    'taxonomy'   => 'product_cat',
	    'hide_empty' => false,
	));

	$cat_posts = array();
	$cat_posts[] = 'Select'; // Add a default "Select" option

	// Ensure categories are returned as objects
	if (!is_wp_error($categories) && !empty($categories)) {
	    foreach ($categories as $category) {
	        if (is_object($category)) {
	            $cat_posts[$category->slug] = $category->name;
	        }
	    }
	} else {
	    // Handle error or no categories found
	    $cat_posts[] = __('No categories available', 'grocery-supermarket-chain');
	}

	// Add Customizer setting
	$wp_customize->add_setting(
	    'grocery_supermarket_chain_trending_post_slider_args',
	    array(
	        'default'           => 'product_cat1',
	        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_choices',
	    )
	);

	// Add Customizer control
	$wp_customize->add_control(
	    'grocery_supermarket_chain_trending_post_slider_args',
	    array(
	        'type'    => 'select',
	        'choices' => $cat_posts,
	        'label'   => __('Select category to display products', 'grocery-supermarket-chain'),
	        'section' => 'grocery_supermarket_chain_product_section',
	    )
	);

	// Global Color Options

	$wp_customize->add_section(
		'grocery_supermarket_chain_global_color_section',
		array(
			'panel'      => 'grocery_supermarket_chain_general_settings_panel',
			'title'    => esc_html__( 'Global Color Options', 'grocery-supermarket-chain' ),
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_global_color',
		array(
			'default'           => '#31b67e',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'grocery_supermarket_chain_global_color',
			array(
				'label'    => __( 'Global Color', 'grocery-supermarket-chain' ),
				'section'  => 'grocery_supermarket_chain_global_color_section',
			)
		)
	);

	// Global Font Family Options

	$wp_customize->add_section(
		'grocery_supermarket_chain_global_font_section',
		array(
			'panel'      => 'grocery_supermarket_chain_general_settings_panel',
			'title'    => esc_html__( 'Global Font Family Options', 'grocery-supermarket-chain' ),
		)
	);

	$wp_customize->add_setting(
		'grocery_supermarket_chain_global_font_setting',
		array(
			'default'           => '',
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_google_fonts',
		)
	);
	
	$wp_customize->add_control(
		'grocery_supermarket_chain_global_font_setting',
		array(
			'label'    => esc_html__( 'Global Font Family', 'grocery-supermarket-chain' ),
			'section'  => 'grocery_supermarket_chain_global_font_section',
			'settings' => 'grocery_supermarket_chain_global_font_setting',
			'type'     => 'select',
			'choices'  => grocery_supermarket_chain_get_all_google_font_families(),
		)
	);	

	// Footer Option

	$wp_customize->add_section(
        'grocery_supermarket_chain_footer_widgets_section',
        array(
            'panel'      => 'grocery_supermarket_chain_footer_settings_panel',
            'title'    => esc_html__( 'Footer Widgets Options', 'grocery-supermarket-chain' ),
        )
    );

	$wp_customize->add_setting(
		'grocery_supermarket_chain_footer_widgets_section_on_off_setting',
		array(
			'default'           => true,
			'sanitize_callback' => 'grocery_supermarket_chain_sanitize_on_off',
		)
	);

	$wp_customize->add_control(
		new grocery_supermarket_chain_On_Off_Custom_Control(
			$wp_customize,
			'grocery_supermarket_chain_footer_widgets_section_on_off_setting',
			array(
				'label'    => esc_html__( 'ON / OFF Footer Widgets', 'grocery-supermarket-chain' ),
				'section'  => 'grocery_supermarket_chain_footer_widgets_section',
				'settings' => 'grocery_supermarket_chain_footer_widgets_section_on_off_setting',
			)
		)
	);

	$wp_customize->add_setting( 'grocery_supermarket_chain_footer_widget_background_color', array(
		    'default' => '',
		    'sanitize_callback' => 'sanitize_hex_color'
		));
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'grocery_supermarket_chain_footer_widget_background_color', array(
		    'label'     => __('Footer Widget Background Color', 'grocery-supermarket-chain'),
		    'description' => __('It will change the complete footer widget background color.', 'grocery-supermarket-chain'),
		    'section' => 'grocery_supermarket_chain_footer_widgets_section',
		    'settings' => 'grocery_supermarket_chain_footer_widget_background_color',
		)));

		$wp_customize->add_setting('grocery_supermarket_chain_footer_widget_background_image',array(
		    'default'   => '',
		    'sanitize_callback' => 'esc_url_raw',
		));
		$wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,'grocery_supermarket_chain_footer_widget_background_image',array(
		    'label' => __('Footer Widget Background Image','grocery-supermarket-chain'),
		    'section' => 'grocery_supermarket_chain_footer_widgets_section'
		)));
	
	$wp_customize->add_section(
        'grocery_supermarket_chain_copyright_section',
        array(
            'panel'      => 'grocery_supermarket_chain_footer_settings_panel',
            'title'    => esc_html__( 'Copyright Options', 'grocery-supermarket-chain' ),
        )
    );

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

    $wp_customize->add_control(
        'grocery_supermarket_chain_footer_text',
        array(
            'label'           => sprintf( esc_html__( 'Edit Copyright Text', 'grocery-supermarket-chain' ), ),
            'section'         => 'grocery_supermarket_chain_copyright_section',
            'settings'        => 'grocery_supermarket_chain_footer_text' ,
            'type'            => 'text',
        )
    );

    // Add Settings and Controls for Scroll top
	$wp_customize->add_setting('grocery_supermarket_chain_scroll_top_position',array(
        'default' => 'Right',
        'sanitize_callback' => 'grocery_supermarket_chain_sanitize_choices'
	));
	$wp_customize->add_control('grocery_supermarket_chain_scroll_top_position',array(
        'type' => 'radio',
        'label'     => __('Scroll to top Position', 'grocery-supermarket-chain'),
        'description'   => __('This option work for scroll to top', 'grocery-supermarket-chain'),
       'section' => 'grocery_supermarket_chain_copyright_section',
       'choices' => array(
            'Right' => __('Right','grocery-supermarket-chain'),
            'Left' => __('Left','grocery-supermarket-chain'),
            'Center' => __('Center','grocery-supermarket-chain')
     ),
	) );

}
add_action( 'customize_register', 'grocery_supermarket_chain_customize_register' );

/**
 * Create the site title for the partial selective refresh.
 *
 * @return void
 */
function grocery_supermarket_chain_customize_partial_blogname() {
	bloginfo( 'name' );
}

/**
 * Create the website's slogan for the partial selective refresh.
 *
 * @return void
 */
function grocery_supermarket_chain_customize_partial_blogdescription() {
	bloginfo( 'description' );
}


/**
 * Singleton class for handling the theme's customizer integration.
 *
 * @since  1.0.0
 * @access public
 */
final class Grocery_Supermarket_Chain_Customize_Buttons {
	/**
	 * Returns the instance.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return object
	 */
	public static function Grocery_Supermarket_Chain_get_instance() {

		static $grocery_supermarket_chain_instance = null;

		if ( is_null( $grocery_supermarket_chain_instance ) ) {
			$grocery_supermarket_chain_instance = new self;
			$grocery_supermarket_chain_instance->Grocery_Supermarket_Chain_setup_actions();
		}

		return $grocery_supermarket_chain_instance;
	}

	/**
	 * Constructor method.
	 *
	 * @since  1.0.0
	 * @access private
	 * @return void
	 */
	private function __construct() {}

	/**
	 * Sets up initial actions.
	 *
	 * @since  1.0.0
	 * @access private
	 * @return void
	 */
	private function Grocery_Supermarket_Chain_setup_actions() {

		// Register panels, sections, settings, controls, and partials.
		add_action( 'customize_register', array( $this, 'sections' ) );

		// Register scripts and styles for the controls.
		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
	}

	/**
	 * Sets up the customizer sections.
	 *
	 * @since  1.0.0
	 * @access public
	 * @param  object  $grocery_supermarket_chain_manager
	 * @return void
	*/
	public function sections( $grocery_supermarket_chain_manager ) {
		load_template( trailingslashit( get_template_directory() ) . '/inc/grocery-supermarket-chain-section-pro.php' );

		$grocery_supermarket_chain_manager->register_section_type( 'Grocery_Supermarket_Chain_Customize_Section_Pro' );

		$grocery_supermarket_chain_manager->add_section( new Grocery_Supermarket_Chain_Customize_Section_Pro( $grocery_supermarket_chain_manager,'grocery_supermarket_chain_buy_now', array(
			'priority'   => 1,
			'title'    => esc_html__( 'Buy Grocery Supermarket Chain Pro', 'grocery-supermarket-chain' ),
			'pro_text' => esc_html__( 'Buy Pro Theme', 'grocery-supermarket-chain' ),
			'pro_url'    => esc_url( GROCERY_SUPERMARKET_CHAIN_BUY_NOW ),
		) )	);

		$grocery_supermarket_chain_manager->add_section( new Grocery_Supermarket_Chain_Customize_Section_Pro( $grocery_supermarket_chain_manager, 'grocery_supermarket_chain_live_demo', array(
		    'priority'   => 1,
		    'title'      => esc_html__( 'Preview Pro Theme', 'grocery-supermarket-chain' ),
		    'pro_text'   => esc_html__( 'View Live Demo', 'grocery-supermarket-chain' ),
		    'pro_url'    => esc_url( GROCERY_SUPERMARKET_CHAIN_LIVE_DEMO ),
		) ) );	
	}

	/**
	 * Loads theme customizer CSS.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return void
	 */
	public function enqueue_control_scripts() {

		wp_enqueue_script( 'grocery-supermarket-chain-customize-controls', trailingslashit( get_template_directory_uri() ) . '/assets/js/customize-controls.js', array( 'customize-controls' ) );

		wp_enqueue_style( 'grocery-supermarket-chain-customize-controls', trailingslashit( get_template_directory_uri() ) . '/assets/css/customize-controls.css' );
	}
}
Grocery_Supermarket_Chain_Customize_Buttons::Grocery_Supermarket_Chain_get_instance();