<?php
function storex_footer( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	// Footer Panel // 
	$wp_customize->add_panel( 
		'storex_footer_section', 
		array(
			'priority'      => 34,
			'capability'    => 'edit_theme_options',
			'title'			=> __('Footer', 'storex'),
		) 
	);
	// Footer Bottom // 
	$wp_customize->add_section(
        'storex_footer_bottom',
        array(
            'title' 		=> __('Footer Bottom','storex'),
			'panel'  		=> 'storex_footer_section',
			'priority'      => 3,
		)
    );
	// Footer Copyright Head
	$wp_customize->add_setting(
		'storex_footer_btm_copy_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'storex_sanitize_text',
			'priority'  => 3,
		)
	);

	$wp_customize->add_control(
	'storex_footer_btm_copy_head',
		array(
			'type' => 'hidden',
			'label' => __('Copyright','storex'),
			'section' => 'storex_footer_bottom',
		)
	);
	
	// Footer Copyright 
	$storex_foo_copy = esc_html__('Copyright &copy; [current_year] [site_title] | Powered by [theme_author]', 'storex' );
	$wp_customize->add_setting(
    	'storex_footer_copyright',
    	array(
			'default' => $storex_foo_copy,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'          => 4,
		)
	);	

	$wp_customize->add_control( 
		'storex_footer_copyright',
		array(
		    'label'   		=> __('Copyright','storex'),
		    'section'		=> 'storex_footer_bottom',
			'type' 			=> 'textarea',
			'transport'         => $selective_refresh,
		)  
	);	
}
add_action( 'customize_register', 'storex_footer' );
// Footer selective refresh
function storex_footer_partials( $wp_customize ){
	// storex_footer_copyright
	$wp_customize->selective_refresh->add_partial( 'storex_footer_copyright', array(
		'selector'            => '.main-footer .footer-bottom .bottom-inner .copyright',
		'settings'            => 'storex_footer_copyright',
		'render_callback'     => 'storex_footer_copyright_render_callback',
	) );
}
add_action( 'customize_register', 'storex_footer_partials' );

// copyright_content
function storex_footer_copyright_render_callback() {
	return get_theme_mod( 'storex_footer_copyright' );
}