<?php
/**
 * Solar Services Customizer controls.
 *
 * @package ttsunsolar
 */

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

/**
 * Register Solar Services settings including hide checkbox.
 *
 * @param WP_Customize_Manager $wp_customize Customizer.
 */
function ttsunsolar_customizer_services( $wp_customize ) {
	$wp_customize->add_section(
		'ttsunsolar_services',
		array(
			'title'       => esc_html__( 'Solar Services', 'ttsunsolar' ),
			'description' => esc_html__( 'Homepage Solar Services section. Select pages for each card, or leave empty to show demo defaults.', 'ttsunsolar' ),
			'panel'       => 'ttsunsolar_panel',
			'priority'    => 30,
		)
	);

	$wp_customize->add_setting(
		'ttsunsolar_hide_services',
		array(
			'default'           => false,
			'sanitize_callback' => 'ttsunsolar_sanitize_checkbox',
		)
	);
	$wp_customize->add_control(
		'ttsunsolar_hide_services',
		array(
			'label'   => esc_html__( 'Hide this section', 'ttsunsolar' ),
			'section' => 'ttsunsolar_services',
			'type'    => 'checkbox',
		)
	);

	$wp_customize->add_setting(
		'ttsunsolar_services_tagline',
		array(
			'default'           => __( 'What we install', 'ttsunsolar' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'ttsunsolar_services_tagline',
		array(
			'label'   => esc_html__( 'Section Tagline', 'ttsunsolar' ),
			'section' => 'ttsunsolar_services',
			'type'    => 'text',
		)
	);

	$wp_customize->add_setting(
		'ttsunsolar_services_title',
		array(
			'default'           => __( 'Solar Services', 'ttsunsolar' ),
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'ttsunsolar_services_title',
		array(
			'label'   => esc_html__( 'Section Title', 'ttsunsolar' ),
			'section' => 'ttsunsolar_services',
			'type'    => 'text',
		)
	);

	for ( $i = 1; $i <= 4; $i++ ) {
		$wp_customize->add_setting(
			'ttsunsolar_service_' . $i,
			array(
				'default'           => 0,
				'capability'        => 'edit_theme_options',
				'sanitize_callback' => 'ttsunsolar_sanitize_page',
			)
		);
		$wp_customize->add_control(
			'ttsunsolar_service_' . $i,
			array(
				'type'    => 'dropdown-pages',
				'label'   => sprintf(
					/* translators: %d: service card number */
					esc_html__( 'Service Card %d Page', 'ttsunsolar' ),
					$i
				),
				'section' => 'ttsunsolar_services',
			)
		);
	}
}
