<?php
/**
 * Footer Customizer controls.
 *
 * @package ttsunsolar
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Register footer settings.
 *
 * @param WP_Customize_Manager $wp_customize Customizer.
 */
function ttsunsolar_customizer_footer( $wp_customize ) {
	$wp_customize->add_section(
		'ttsunsolar_footer',
		array(
			'title'    => esc_html__( 'Footer', 'ttsunsolar' ),
			'panel'    => 'ttsunsolar_panel',
			'priority' => 40,
		)
	);

	$fields = array(
		'ttsunsolar_footer_about_title'   => array( 'type' => 'text', 'label' => __( 'About Title', 'ttsunsolar' ), 'default' => __( 'About Us', 'ttsunsolar' ) ),
		'ttsunsolar_footer_about_text'    => array(
			'type'    => 'textarea',
			'label'   => __( 'About Text', 'ttsunsolar' ),
			'default' => __( 'TTSun Solar designs, installs, and supports efficient solar energy systems for homes, businesses, and clean transportation.', 'ttsunsolar' ),
		),
		'ttsunsolar_footer_links_title'   => array( 'type' => 'text', 'label' => __( 'Quick Links Title', 'ttsunsolar' ), 'default' => __( 'Quick Links', 'ttsunsolar' ) ),
		'ttsunsolar_footer_posts_title'   => array( 'type' => 'text', 'label' => __( 'Recent Posts Title', 'ttsunsolar' ), 'default' => __( 'Recent Posts', 'ttsunsolar' ) ),
		'ttsunsolar_footer_contact_title' => array( 'type' => 'text', 'label' => __( 'Contact Title', 'ttsunsolar' ), 'default' => __( 'Contact Info', 'ttsunsolar' ) ),
		'ttsunsolar_footer_address'       => array( 'type' => 'text', 'label' => __( 'Footer Address', 'ttsunsolar' ), 'default' => '123 Lorem Ipsum Street, Dolor Sit Amet, 00000' ),
		'ttsunsolar_website'              => array( 'type' => 'url', 'label' => __( 'Website URL', 'ttsunsolar' ), 'default' => 'https://example.com' ),
		'ttsunsolar_footer_extra'         => array(
			'type'    => 'text',
			'label'   => __( 'Copyright bar right text', 'ttsunsolar' ),
			'default' => __( 'Clean energy designed for long-term performance.', 'ttsunsolar' ),
		),
	);

	foreach ( $fields as $id => $args ) {
		$sanitize = ( 'textarea' === $args['type'] ) ? 'sanitize_textarea_field' : ( ( 'url' === $args['type'] ) ? 'esc_url_raw' : 'sanitize_text_field' );
		$wp_customize->add_setting(
			$id,
			array(
				'default'           => $args['default'],
				'sanitize_callback' => $sanitize,
			)
		);
		$wp_customize->add_control(
			$id,
			array(
				'label'   => esc_html( $args['label'] ),
				'section' => 'ttsunsolar_footer',
				'type'    => $args['type'],
			)
		);
	}
}
