<?php
/**
 * Homepage banner Customizer controls (single image).
 *
 * @package ttsunsolar
 */

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

/**
 * Register banner settings.
 *
 * @param WP_Customize_Manager $wp_customize Customizer.
 */
function ttsunsolar_customizer_banner( $wp_customize ) {
	$wp_customize->add_section(
		'ttsunsolar_banner',
		array(
			'title'       => esc_html__( 'Homepage Banner', 'ttsunsolar' ),
			'description' => esc_html__( 'Homepage hero only (front page). Uses a different default image than Inner Page Banner. Leave empty for the bundled homepage demo image.', 'ttsunsolar' ),
			'panel'       => 'ttsunsolar_panel',
			'priority'    => 20,
		)
	);

	$wp_customize->add_setting(
		'ttsunsolar_banner_image',
		array(
			'default'           => '',
			'sanitize_callback' => 'esc_url_raw',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Image_Control(
			$wp_customize,
			'ttsunsolar_banner_image',
			array(
				'label'   => esc_html__( 'Banner Image', 'ttsunsolar' ),
				'section' => 'ttsunsolar_banner',
			)
		)
	);

	$texts = array(
		'ttsunsolar_banner_tagline' => array( 'label' => __( 'Banner Tagline', 'ttsunsolar' ), 'default' => __( 'Reliable clean energy', 'ttsunsolar' ) ),
		'ttsunsolar_banner_title'   => array( 'label' => __( 'Banner Title', 'ttsunsolar' ), 'default' => __( 'Lower bills, backup power, and a cleaner grid.', 'ttsunsolar' ) ),
		'ttsunsolar_banner_button'  => array( 'label' => __( 'Banner Button Text', 'ttsunsolar' ), 'default' => __( 'See More', 'ttsunsolar' ) ),
	);

	foreach ( $texts as $id => $args ) {
		$wp_customize->add_setting(
			$id,
			array(
				'default'           => $args['default'],
				'sanitize_callback' => 'sanitize_text_field',
			)
		);
		$wp_customize->add_control(
			$id,
			array(
				'label'   => esc_html( $args['label'] ),
				'section' => 'ttsunsolar_banner',
				'type'    => 'text',
			)
		);
	}

	$wp_customize->add_setting(
		'ttsunsolar_banner_url',
		array(
			'default'           => '',
			'sanitize_callback' => 'esc_url_raw',
		)
	);
	$wp_customize->add_control(
		'ttsunsolar_banner_url',
		array(
			'label'   => esc_html__( 'Banner Button URL', 'ttsunsolar' ),
			'section' => 'ttsunsolar_banner',
			'type'    => 'url',
		)
	);
}
