<?php

function solar_system_company_footer( $wp_customize ) {
	$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	// Footer Panel // 
	$wp_customize->add_panel( 
		'solar_system_company_footer_section', 
		array(
			'priority'      => 34,
			'capability'    => 'edit_theme_options',
			'title'			=> __('Footer Options', 'solar-system-company'),
		) 
	);

	// Footer Widgets // 
	$wp_customize->add_section(
        'solar_system_company_footer_top',
        array(
            'title' 		=> __('Footer Widgets','solar-system-company'),
			'panel'  		=> 'solar_system_company_footer_section',
			'priority'      => 3,
		)
    );

    // Footer Widgets Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'solar_system_company_footer_widgets_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'solar_system_company_sanitize_checkbox',
			'capability' => 'edit_theme_options',
		) 
	);
	
	$wp_customize->add_control(
	'solar_system_company_footer_widgets_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Footer Widgets', 'solar-system-company' ),
			'section'     => 'solar_system_company_footer_top',
			'settings'    => 'solar_system_company_footer_widgets_setting',
			'type'        => 'checkbox'
		) 
	);

	// Footer Background Image Setting
	$wp_customize->add_setting('solar_system_company_footer_bg_image',array(
		'default'	=> '',
		'sanitize_callback'	=> 'esc_url_raw',
	));
	$wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,'solar_system_company_footer_bg_image',array(
	'label' => __('Footer Background Image','solar-system-company'),
	'section' => 'solar_system_company_footer_top'
	)));

	// Footer Background Image Opacity
	$wp_customize->add_setting('solar_system_company_footer_bg_image_opacity', array(
		'default'           => 50,
		'sanitize_callback' => 'absint',
		'capability'        => 'edit_theme_options',
	));

	$wp_customize->add_control('solar_system_company_footer_bg_image_opacity', array(
		'label'    => __('Footer Background Image Opacity (%)', 'solar-system-company'),
		'section'  => 'solar_system_company_footer_top',
		'type'     => 'range',
		'input_attrs' => array(
			'min'  => 0,
			'max'  => 100,
			'step' => 1,
		),
	));

	// Footer Background Color Setting
    $wp_customize->add_setting('solar_system_company_footer_bg_color',array(
		'default' => '#000000',
		'sanitize_callback' => 'sanitize_hex_color',
		'capability' => 'edit_theme_options',
	));

    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'solar_system_company_footer_bg_color',array(
		'label' => esc_html__('Footer Background Color', 'solar-system-company'),
		'section' => 'solar_system_company_footer_top', // Adjust section if needed
		'settings' => 'solar_system_company_footer_bg_color',
	)));

	$wp_customize->add_setting( 'solar_system_company_upgrade_page_settings_33',
	array(
		'sanitize_callback' => 'sanitize_text_field'
		)
	);
	$wp_customize->add_control( new Solar_System_Company_Control_Upgrade(
		$wp_customize, 'solar_system_company_upgrade_page_settings_33',
			array(
				'priority'      => 200,
				'section'       => 'solar_system_company_footer_top',
				'settings'      => 'solar_system_company_upgrade_page_settings_33',
				'label'         => __( 'Solar System Company Pro comes with additional features.', 'solar-system-company' ),
				'choices'       => array( __( '15+ Ready-Made Sections', 'solar-system-company' ), __( 'One-Click Demo Import', 'solar-system-company' ), __( 'WooCommerce Integrated', 'solar-system-company' ), __( 'Drag & Drop Section Reordering', 'solar-system-company' ),__( 'Advanced Typography Control', 'solar-system-company' ),__( 'Intuitive Customization Options', 'solar-system-company' ),__( '24/7 Support', 'solar-system-company' ), )
			)
		)
	); 

	// Footer Bottom // 
	$wp_customize->add_section(
        'solar_system_company_footer_bottom',
        array(
            'title' 		=> __('Footer Bottom','solar-system-company'),
			'panel'  		=> 'solar_system_company_footer_section',
			'priority'      => 3,
		)
    );
	
	// Site Title Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'solar_system_company_footer_copyright_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'solar_system_company_sanitize_checkbox',
			'capability' => 'edit_theme_options',
		) 
	);
	
	$wp_customize->add_control(
	'solar_system_company_footer_copyright_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Footer Copytight', 'solar-system-company' ),
			'section'     => 'solar_system_company_footer_bottom',
			'settings'    => 'solar_system_company_footer_copyright_setting',
			'type'        => 'checkbox'
		) 
	);
	
	// Footer Copyright 
	$wp_customize->add_setting(
    	'solar_system_company_footer_copyright',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 4,
		)
	);

	$wp_customize->add_control( 
		'solar_system_company_footer_copyright',
		array(
		    'label'   		=> __('Edit Copyright Text','solar-system-company'),
		    'section'		=> 'solar_system_company_footer_bottom',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	$wp_customize->add_setting( 'solar_system_company_copyright_alignment', array(
        'default'   => 'center',
        'sanitize_callback' => 'solar_system_company_sanitize_copyright_position',
    ));

    $wp_customize->add_control( 'solar_system_company_copyright_alignment', array(
        'label'    => __( 'Copyright Position', 'solar-system-company' ),
        'section'  => 'solar_system_company_footer_bottom',
        'settings' => 'solar_system_company_copyright_alignment',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Align', 'solar-system-company' ),
            'left'  => __( 'Left Align', 'solar-system-company' ),
            'center'  => __( 'Center Align', 'solar-system-company' ),
        ),
    ));

	$wp_customize->add_setting( 'solar_system_company_upgrade_page_settings_122',
	array(
		'sanitize_callback' => 'sanitize_text_field'
		)
	);
	$wp_customize->add_control( new Solar_System_Company_Control_Upgrade(
		$wp_customize, 'solar_system_company_upgrade_page_settings_122',
			array(
				'priority'      => 200,
				'section'       => 'solar_system_company_footer_bottom',
				'settings'      => 'solar_system_company_upgrade_page_settings_122',
				'label'         => __( 'Solar System Company Pro comes with additional features.', 'solar-system-company' ),
				'choices'       => array( __( '15+ Ready-Made Sections', 'solar-system-company' ), __( 'One-Click Demo Import', 'solar-system-company' ), __( 'WooCommerce Integrated', 'solar-system-company' ), __( 'Drag & Drop Section Reordering', 'solar-system-company' ),__( 'Advanced Typography Control', 'solar-system-company' ),__( 'Intuitive Customization Options', 'solar-system-company' ),__( '24/7 Support', 'solar-system-company' ), )
			)
		)
	); 
}
add_action( 'customize_register', 'solar_system_company_footer' );

// Footer selective refresh
function solar_system_company_footer_partials( $wp_customize ){
	// footer_copyright
	$wp_customize->selective_refresh->add_partial( 'footer_copyright', array(
		'selector'            => '.copy-right .copyright-text',
		'settings'            => 'footer_copyright',
		'render_callback'  => 'solar_system_company_footer_copyright_render_callback',
	) );
}
add_action( 'customize_register', 'solar_system_company_footer_partials' );

// copyright_content
function solar_system_company_footer_copyright_render_callback() {
	return get_theme_mod( 'footer_copyright' );
}