<?php
function pet_bazaar_general_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'pet_bazaar_general', array(
			'priority' => 31,
			'title' => esc_html__( 'General', 'pet-bazaar' ),
		)
	);
	
	/*=========================================
	Scroller
	=========================================*/
	$wp_customize->add_section(
		'top_scroller', array(
			'title' => esc_html__( 'Top Scroller', 'pet-bazaar' ),
			'priority' => 4,
			'panel' => 'pet_bazaar_general',
		)
	);
	
	$wp_customize->add_setting( 
		'hs_scroller' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 1,
		) 
	);
	
	$wp_customize->add_control(
	'hs_scroller', 
		array(
			'label'	      => esc_html__( 'Hide / Show Scroller', 'pet-bazaar' ),
			'section'     => 'top_scroller',
			'type'        => 'checkbox'
		) 
	);
	
	$wp_customize->add_setting(
		'scroller_icon',
		array(
			'default' => 'fa-arrow-up',
			'sanitize_callback' => 'sanitize_text_field',
			'capability' => 'edit_theme_options',
		)
	);	

	$wp_customize->add_control(new Pet_Bazaar_Icon_Picker_Control($wp_customize, 
		'scroller_icon',
		array(
			'label'   		=> __('Icon','pet-bazaar'),
			'section' 		=> 'top_scroller',
			'iconset' => 'fa',
			
		))  
	);
	
	//Pro Upgrade
	class  Petbazaar_scroll_up_icon__section_upgrade extends WP_Customize_Control {
		public function render_content() { 	
			
		?>
			<a class="customizer_scroll_up_icon_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="https://sellerthemes.com/pet-bazaar-premium/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'scroll_up_icon_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Petbazaar_scroll_up_icon__section_upgrade(
		$wp_customize,
		'scroll_up_icon_upgrade_to_pro',
			array(
				'section'				=> 'top_scroller',
			)
		)
	);
	
	/*=========================================
	Breadcrumb  Section
	=========================================*/
	$wp_customize->add_section(
		'breadcrumb_setting', array(
			'title' => esc_html__( 'Page Breadcrumb', 'pet-bazaar' ),
			'priority' => 12,
			'panel' => 'pet_bazaar_general',
		)
	);
	
	// Settings
	$wp_customize->add_setting(
		'breadcrumb_settings'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_settings',
		array(
			'type' => 'hidden',
			'label' => __('Settings','pet-bazaar'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// Breadcrumb Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'hs_breadcrumb' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'hs_breadcrumb', 
		array(
			'label'	      => esc_html__( 'Hide / Show Section', 'pet-bazaar' ),
			'section'     => 'breadcrumb_setting',
			'type'        => 'checkbox'
		) 
	);
	
	// enable on Page Title
	$wp_customize->add_setting(
		'breadcrumb_title_enable'
			,array(
			'default' => '1',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 3,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_title_enable',
		array(
			'type' => 'checkbox',
			'label' => __('Enable Page Title on Breadcrumb?','pet-bazaar'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// enable on Page Path
	$wp_customize->add_setting(
		'breadcrumb_path_enable'
			,array(
			'default' => '1',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 4,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_path_enable',
		array(
			'type' => 'checkbox',
			'label' => __('Enable Page Path on Breadcrumb?','pet-bazaar'),
			'section' => 'breadcrumb_setting',
		)
	);	
	
		
	// Background // 
	$wp_customize->add_setting(
		'breadcrumb_bg_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 9,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_bg_head',
		array(
			'type' => 'hidden',
			'label' => __('Background','pet-bazaar'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// Background Image // 
    $wp_customize->add_setting( 
    	'breadcrumb_bg_img' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/breadcrumb.png'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',	
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'breadcrumb_bg_img' ,
		array(
			'label'          => esc_html__( 'Background Image', 'pet-bazaar'),
			'section'        => 'breadcrumb_setting',
		) 
	));
	
	// Image Opacity // 
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
	$wp_customize->add_setting(
    	'breadcrumb_bg_img_opacity',
    	array(
	        'default'			=> '0.6',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
			'priority'  => 11,
		)
	);
	$wp_customize->add_control( 
	new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'breadcrumb_bg_img_opacity', 
		array(
			'label'      => __( 'Opacity', 'pet-bazaar'),
			'section'  => 'breadcrumb_setting',
			'settings' => 'breadcrumb_bg_img_opacity',
			 'media_query'   => false,
                'input_attr'    => array(
                    'desktop' => array(
                        'min'           => 0,
                        'max'           => 1,
                        'step'          => 0.1,
                        'default_value' => 0.6,
                    ),
                ),
		) ) 
	);
	}
	
	$wp_customize->add_setting(
	'breadcrumb_overlay_color', 
	array(
		'default' => '#080808',
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_hex_color',
		'priority'  => 12,
    ));
	
	$wp_customize->add_control( 
		new WP_Customize_Color_Control
		($wp_customize, 
			'breadcrumb_overlay_color', 
			array(
				'label'      => __( 'Overlay Color', 'pet-bazaar'),
				'section'    => 'breadcrumb_setting',
			) 
		) 
	);
	
	/*========================
	 **** Pro Upgrade ****
	======================== */
	class  Petbazaar_breadcrumb__section_upgrade extends WP_Customize_Control {
		public function render_content() { 	
			
		?>
			<a class="customizer_breadcrumb_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="https://sellerthemes.com/pet-bazaar-premium/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'breadcrumb_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Petbazaar_breadcrumb__section_upgrade(
		$wp_customize,
		'breadcrumb_upgrade_to_pro',
			array(
				'section'				=> 'breadcrumb_setting',
			)
		)
	);
	
	/*=========================================
	Pet Bazaar Container
	=========================================*/
	$wp_customize->add_section(
        'pet_bazaar_container',
        array(
        	'priority'      => 2,
            'title' 		=> __('Container','pet-bazaar'),
			'panel'  		=> 'pet_bazaar_general',
		)
    );
	
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		//container width
		$wp_customize->add_setting(
			'pet_bazaar_site_cntnr_width',
			array(
				'default'			=> '1320',
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'pet_bazaar_sanitize_range_value',
				'transport'         => 'postMessage',
				'priority'      => 1,
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'pet_bazaar_site_cntnr_width', 
			array(
				'label'      => __( 'Container Width', 'pet-bazaar' ),
				'section'  => 'pet_bazaar_container',
				'media_query'   => true,
                'input_attr'    => array(
                    'mobile'  => array(
                        'min'           => 100,
                        'max'           => 320,
                        'step'          => 1,
                        'default_value' => 320,
                    ),
                    'tablet'  => array(
                        'min'           => 577,
                        'max'           => 768,
                        'step'          => 1,
                        'default_value' => 768,
                    ),
                    'desktop' => array(
                        'min'           => 992,
                        'max'           => 1320,
                        'step'          => 1,
                        'default_value' => 1200,
                    ),
				)
			) ) 
		);
	}
	
	// Pro Upgrade
	class  Petbazaar_cntr__section_upgrade extends WP_Customize_Control {
		public function render_content() { 			
		?>
			<a class="customizer_cntr_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="https://sellerthemes.com/pet-bazaar-premium/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'cntr_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 1,
	));
	$wp_customize->add_control(
		new  Petbazaar_cntr__section_upgrade(
		$wp_customize,
		'cntr_upgrade_to_pro',
			array(
				'section'				=> 'pet_bazaar_container',
			)
		)
	);
	
	
	/*=========================================
	Pet Bazaar Sidebar
	=========================================*/
	$wp_customize->add_section(
        'pet_bazaar_sidebar',
        array(
        	'priority'      => 8,
            'title' 		=> __('Sidebar','pet-bazaar'),
			'panel'  		=> 'pet_bazaar_general',
		)
    );
	
	//  Pages Layout // 
	$wp_customize->add_setting(
		'pet_bazaar_pages_sidebar'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'pet_bazaar_pages_sidebar',
		array(
			'type' => 'hidden',
			'label' => __('Sidebar Layout','pet-bazaar'),
			'section' => 'pet_bazaar_sidebar',
		)
	);
	
	// Default Page
	$wp_customize->add_setting( 
		'pet_bazaar_default_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 2,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_default_pg_sidebar' , 
		array(
			'label'          => __( 'Default Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' 	=> __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	// Archive Page
	$wp_customize->add_setting( 
		'pet_bazaar_archive_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 3,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_archive_pg_sidebar' , 
		array(
			'label'          => __( 'Archive Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' => __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	
	// Single Page
	$wp_customize->add_setting( 
		'pet_bazaar_single_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 4,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_single_pg_sidebar' , 
		array(
			'label'          => __( 'Single Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' => __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	
	// Blog Page
	$wp_customize->add_setting( 
		'pet_bazaar_blog_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 5,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_blog_pg_sidebar' , 
		array(
			'label'          => __( 'Blog Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' => __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	// Search Page
	$wp_customize->add_setting( 
		'pet_bazaar_search_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 5,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_search_pg_sidebar' , 
		array(
			'label'          => __( 'Search Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' => __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	
	// WooCommerce Page
	$wp_customize->add_setting( 
		'pet_bazaar_shop_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_select',
			'priority' => 6,
		) 
	);

	$wp_customize->add_control(
	'pet_bazaar_shop_pg_sidebar' , 
		array(
			'label'          => __( 'WooCommerce Page Sidebar Option', 'pet-bazaar' ),
			'section'        => 'pet_bazaar_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'pet-bazaar' ),
				'right_sidebar' => __( 'Right Sidebar', 'pet-bazaar' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'pet-bazaar' ),
			) 
		) 
	);
	
	// Pro Upgrade
	class  Pet_Bazaar_sidebar__section_upgrade extends WP_Customize_Control {
		public function render_content() { 
			$theme = wp_get_theme(); // gets the current theme	
			
		?>
			<a class="customizer_sidebar_upgrade_section up-to-pro" style="padding:9px 0; text-align:center;" href="https://www.nayrathemes.com/pet-bazaar-pro/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'sidebar_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Pet_Bazaar_sidebar__section_upgrade(
		$wp_customize,
		'sidebar_upgrade_to_pro',
			array(
				'section'				=> 'pet_bazaar_sidebar',
			)
		)
	);
	
	
	// Widget options
	$wp_customize->add_setting(
		'sidebar_options'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority'  => 6
		)
	);

	$wp_customize->add_control(
	'sidebar_options',
		array(
			'type' => 'hidden',
			'label' => __('Options','pet-bazaar'),
			'section' => 'pet_bazaar_sidebar',
		)
	);
	// Sidebar Width 
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		$wp_customize->add_setting(
			'pet_bazaar_sidebar_width',
			array(
				'default'	      => esc_html__( '33', 'pet-bazaar' ),
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage',
				'priority'  => 7
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'pet_bazaar_sidebar_width', 
			array(
				'label'      => __( 'Sidebar Width', 'pet-bazaar' ),
				'section'  => 'pet_bazaar_sidebar',
				'media_query'   => false,
                'input_attr'    => array(                    
                        'min'           => 25,
                        'max'           => 50,
                        'step'          => 1,
                        'default_value' => 33,
				)
				),
			 ) 
		);
	}
	
	// Widget Typography
	$wp_customize->add_setting(
		'sidebar_typography'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'sidebar_typography',
		array(
			'type' => 'hidden',
			'label' => __('Typography','pet-bazaar'),
			'section' => 'pet_bazaar_sidebar',
			'priority'  => 21,
		)
	);
	
	// Widget Title // 
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		$wp_customize->add_setting(
			'pet_bazaar_widget_ttl_size',
			array(
				'default' => 28,
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage'
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'pet_bazaar_widget_ttl_size', 
			array(
				'label'      => __( 'Widget Title Font Size', 'pet-bazaar' ),
				'section'  => 'pet_bazaar_sidebar',
				'priority'  => 23,
				'media_query'   => false,
                'input_attr'    => array(                    
                        'min'           => 25,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 28,
				)
			) ) 
		);
	}
}

add_action( 'customize_register', 'pet_bazaar_general_setting' );
