<?php
function pet_bazaar_footer( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	// Footer Panel // 
	$wp_customize->add_panel( 
		'footer_section', 
		array(
			'priority'      => 34,
			'capability'    => 'edit_theme_options',
			'title'			=> __('Footer', 'pet-bazaar'),
		) 
	);
	
	// Footer Setting Section // 
	$wp_customize->add_section(
        'footer_copy_Section',
        array(
            'title' 		=> __('Below Footer','pet-bazaar'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	
	// Copyright
	$pet_bazaar_copyright = esc_html__('Copyright &copy; [current_year] [site_title] | Powered by [theme_author]', 'pet-bazaar' );
	$wp_customize->add_setting( 
		'footer_copyright' , 
			array(
			'default'	      => $pet_bazaar_copyright,
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'footer_copyright', 
		array(
			'label'	      => esc_html__( 'Copyright', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'textarea',
			'priority' => 10,
		) 
	);
	
	
	/* Payment Options */
		
	$wp_customize->add_setting( 
		'footer_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'footer_payment', 
		array(
			'label'	      => esc_html__( 'Payments', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);	
	
	$wp_customize->add_setting( 
		'visa_payment' , 
			array(
			'default' => 'fa fa-cc-visa',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'visa_payment', 
		array(
			'label'	      => esc_html__( 'Visa', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'visa_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'visa_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'visa_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'visa_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'paypal_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'paypal_payment', 
		array(
			'label'	      => esc_html__( 'Paypal', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'paypal_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'paypal_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'paypal_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'paypal_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'mastercard_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'mastercard_payment', 
		array(
			'label'	      => esc_html__( 'Mastercard', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'mastercard_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'mastercard_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'mastercard_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'mastercard_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'amex_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'amex_payment', 
		array(
			'label'	      => esc_html__( 'Amex', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'amex_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'amex_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'amex_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'amex_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'discover_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'discover_payment', 
		array(
			'label'	      => esc_html__( 'Discover', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'discover_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'discover_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'discover_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'discover_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'jcb_payment' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'jcb_payment', 
		array(
			'label'	      => esc_html__( 'JCB', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'hidden',
			'priority' => 10,
		) 
	);
		
	$wp_customize->add_setting( 
		'jcb_icon' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'jcb_icon', 
		array(
			'label'	      => esc_html__( 'Icon', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_setting( 
		'jcb_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
		) 
	);
	
	$wp_customize->add_control(
	'jcb_link', 
		array(
			'label'	      => esc_html__( 'Link', 'pet-bazaar' ),
			'section'     => 'footer_copy_Section',
			'type'        => 'text',
			'priority' => 10,
		) 
	);
	

	/*=========================================
	Footer Background 
	=========================================*/	
	$wp_customize->add_section(
        'footer_background',
        array(
            'title' 		=> __('Footer Background','pet-bazaar'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	
	//  Image // 
    $wp_customize->add_setting( 
    	'footer_bg_img' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/footer_bg.png'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',	
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'footer_bg_img' ,
		array(
			'label'          => esc_html__( 'Background Image', 'pet-bazaar'),
			'section'        => 'footer_background',
		) 
	));
	
	//  Background Color
	$wp_customize->add_setting(
	'footer_bg_clr', 
	array(
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_text_field',
		'default' => '#000000'
    ));
	
	$wp_customize->add_control( 
		new WP_Customize_Color_Control
		($wp_customize, 
			'footer_bg_clr', 
			array(
				'label'      => __( 'Background Color', 'pet-bazaar' ),
				'section'    => 'footer_background',
			) 
		) 
	);
	
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
	$wp_customize->add_setting(
		'footer_clr_opacity',
		array(
			'default' => '80',
			'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, 'footer_clr_opacity', 
		array(
			'label'      => __( 'Opacity', 'pet-bazaar' ),
			'section'  => 'footer_background',
			 'media_query'   => false,
				'input_attr'    => array(
					'desktop' => array(
						'min'           => 0,
						'max'           => 100,
						'step'          => 1,
						'default_value' => 80,
					),
				),
		) ) 
	);
}

// Pro Upgrade
	class  Petbazaar_footer_bg__section_upgrade extends WP_Customize_Control {
		public function render_content() { 		
		?>
			<a class="customizer_footer_bg_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( 'footer_bg_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Petbazaar_footer_bg__section_upgrade(
		$wp_customize,
		'footer_bg_upgrade_to_pro',
			array(
				'section'				=> 'footer_background',
			)
		)
	);
	
	/*=========================================
	Footer Menu
	=========================================*/
	$wp_customize->add_section(
        'footer_menu',
        array(
            'title' 		=> __('Footer Menu','pet-bazaar'),
			'panel'  		=> 'footer_section',
			'priority'      => 6,
		)
    );
	
	// Menu Head
	$wp_customize->add_setting(
		'footer_menu_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'footer_menu_head',
		array(
			'type' => 'hidden',
			'label' => __('Global','pet-bazaar'),
			'section' => 'footer_menu',
			'priority'  => 1,
		)
	);
		
	// Hide / Show
	$wp_customize->add_setting(
		'footer_menu_hs'
			,array(
			'default'     	=> '2',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
		)
	);

	
	$wp_customize->add_control(
	'footer_menu_hs',
		array(
			'type' => 'checkbox',
			'label' => __('Hide / Show Menu','pet-bazaar'),
			'section' => 'footer_menu',
			'priority'  => 2,
		)
	);
	
}
add_action( 'customize_register', 'pet_bazaar_footer' );
// Footer selective refresh
function pet_bazaar_footer_partials( $wp_customize ){	
	
	// footer_copyright
	$wp_customize->selective_refresh->add_partial( 'footer_copyright', array(
		'selector'            => '.footer-bottom-wrapper',
		'settings'            => 'footer_copyright',
		'render_callback'  => 'pet_bazaar_footer_copyright_render_callback',
	) );
	
	}
add_action( 'customize_register', 'pet_bazaar_footer_partials' );

// footer_copyright
function pet_bazaar_footer_copyright_render_callback() {
	return get_theme_mod( 'footer_copyright' );
}