<?php
function news25_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', 'news-25'),
		) 
	);
	
	if( function_exists('cleverfox_activate')):
	$wp_customize->add_section(
        'footer_above_Section',
        array(
            'title' 		=> __('Above Footer','news-25'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	
	$wp_customize->add_setting(
    'footer_breakingnews_id',
		array(
		'capability' => 'edit_theme_options',
		'priority' => 5,
		'sanitize_callback' => 'sanitize_categories',
		)
	);	
	
	$wp_customize->add_control( new News25_Category_Dropdown_Custom_Control( $wp_customize, 
	'footer_breakingnews_id', 
		array(
		'label'   => __('Select Categories','news-25'),
		'section' => 'footer_above_Section',
		) 
	) );
	
	$wp_customize->add_setting(
    'footer_slider_id',
		array(
		'capability' => 'edit_theme_options',
		'priority' => 5,
		'sanitize_callback' => 'sanitize_categories',
		)
	);	
	$wp_customize->add_control( new News25_Category_Dropdown_Custom_Control( $wp_customize, 
	'footer_slider_id', 
		array(
		'label'   => __('Select Categories','news-25'),
		'section' => 'footer_above_Section',
		) 
	) );
	//footer middle
	$wp_customize->add_section(
        'footer_middle_Section',
        array(
            'title' 		=> __('Footer Middle','news-25'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	// footer middle text // 
	$wp_customize->add_setting(
    	'footer_middle_text1',
    	array(
			'default'          => 'Live',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'news25_sanitize_html',
		)
	);	

	$wp_customize->add_control( 
		'footer_middle_text1',
		array(
		    'label'   		=> __('Footer Middle Text','news-25'),
		    'section'		=> 'footer_middle_Section',
			'type' 			=> 'text',
			'priority'      => 1,
		)  
	);
	
	$wp_customize->add_setting(
    	'footer_middle_text2',
    	array(
			'default'          => 'News',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'news25_sanitize_html',
		)
	);	

	$wp_customize->add_control( 
		'footer_middle_text2',
		array(
		    'label'   		=> __('Footer Middle Text','news-25'),
		    'section'		=> 'footer_middle_Section',
			'type' 			=> 'text',
			'priority'      => 1,
		)  
	);	
	
	$wp_customize->add_setting(
    	'live_news_link',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'news25_sanitize_url',
		)
	);	

	$wp_customize->add_control( 
		'live_news_link',
		array(
		    'label'   		=> __('Live Link','news-25'),
		    'section'		=> 'footer_middle_Section',
			'type' 			=> 'text',
			'priority'      => 1,
		)  
	);	
	
	//  Image // 
    $wp_customize->add_setting( 
    	'footer_middle_img1' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/playstore.png'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'news25_sanitize_url',	
			'priority' => 3,
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'footer_middle_img1' ,
		array(
			'label'          => esc_html__( 'Footer Image One', 'news-25'),
			'section'        => 'footer_middle_Section',
		) 
	));
	
	//  Image // 
    $wp_customize->add_setting( 
    	'footer_middle_img2' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/appstore.png'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'news25_sanitize_url',	
			'priority' => 3,
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'footer_middle_img2' ,
		array(
			'label'          => esc_html__( 'Footer Image Two', 'news-25'),
			'section'        => 'footer_middle_Section',
		) 
	));
	
	$wp_customize->add_setting( 'footer_social', 
			array(
			 'sanitize_callback' => 'news25_repeater_sanitize',
			 'priority' => 7,
			 'default' => news25_get_social_icon_default()
		)
		);
		
		$wp_customize->add_control( 
			new NEWS25_Repeater( $wp_customize, 
				'footer_social', 
					array(
						'label'   => esc_html__('Social Icons','news-25'),
						'add_field_label'   => esc_html__( 'Add New Social', 'news-25' ),
						'item_name'         => esc_html__( 'Social', 'news-25' ),					
						'section' => 'footer_middle_Section',
						'customizer_repeater_title_control' => true,
						'customizer_repeater_icon_control' => true,
						'customizer_repeater_link_control' => true,
					) 
				) 
			);
			
	class  News25_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://www.nayrathemes.com/news25-pro/" target="_blank" ><?php esc_html_e('Upgrade To Pro For More Social','news-25'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'footer_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'news25_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  News25_section_upgrade (
		$wp_customize,
		'footer_upgrade_to_pro',
			array(
				'section'				=> 'footer_middle_Section',
			)
		)
	);
	
			
	endif;
	
	// Footer Setting Section // 
	$wp_customize->add_section(
        'footer_copy_Section',
        array(
            'title' 		=> __('Below Footer','news-25'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	
	// Footer Setting Section // 
	$wp_customize->add_section(
        'footer_copy_Section',
        array(
            'title' 		=> __('Below Footer','news-25'),
			'panel'  		=> 'footer_section',
			'priority'      => 4,
		)
    );
	
	// footer first text // 
	$news25_footer_copyright = esc_html__('Copyright &copy; [current_year] [site_title] | Powered by [theme_author]', 'news-25' );
	$wp_customize->add_setting(
    	'footer_first_custom',
    	array(
			'default' => $news25_footer_copyright,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
		)
	);	

	$wp_customize->add_control( 
		'footer_first_custom',
		array(
		    'label'   		=> __('Copyright','news-25'),
		    'section'		=> 'footer_copy_Section',
			'type' 			=> 'textarea',
			'priority'      => 4,
			'transport'         => $selective_refresh,
		)  
	);	
}
add_action( 'customize_register', 'news25_footer' );
// Footer selective refresh
function news25_footer_partials( $wp_customize ){
	// footer_first_custom
	$wp_customize->selective_refresh->add_partial( 'footer_first_custom', array(
	'selector'            => '.footer-copyright .copyright-text',
		'settings'            => 'footer_first_custom',
		'render_callback'  => 'news25_footer_first_custom_render_callback',
	
	) );
	}
add_action( 'customize_register', 'news25_footer_partials' );

// footer_first_custom
function news25_footer_first_custom_render_callback() {
	return get_theme_mod( 'footer_first_custom' );
}