<?php
/**
 * Banner Section
 *
 * @package events_and_celebrations
 */

$wp_customize->add_section(
	'events_and_celebrations_banner_section',
	array(
		'panel'    => 'events_and_celebrations_front_page_options',
		'title'    => esc_html__( 'Banner Section', 'events-and-celebrations' ),
		'priority' => 10,
	)
);

// Banner Section - Enable section.
$wp_customize->add_setting(
	'events_and_celebrations_enable_banner_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'events_and_celebrations_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Events_And_Celebrations_Toggle_Switch_Custom_Control(
		$wp_customize,
		'events_and_celebrations_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'events-and-celebrations' ),
			'section'  => 'events_and_celebrations_banner_section',
			'settings' => 'events_and_celebrations_enable_banner_section',
		)
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'events_and_celebrations_enable_banner_section',
		array(
			'selector' => '#events_and_celebrations_banner_section .section-link',
			'settings' => 'events_and_celebrations_enable_banner_section',
		)
	);
}

// Banner Section - Main title.
$wp_customize->add_setting(
	'events_and_celebrations_banner_section_title',
	array(
		'default'           =>  '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_section_title',
	array(
		'label'           => esc_html__( 'Banner Title', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_section_title',
		'type'            => 'text',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - Description.
$wp_customize->add_setting(
	'events_and_celebrations_banner_section_description',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_textarea_field',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_section_description',
	array(
		'label'           => esc_html__( 'Banner Description', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_section_description',
		'type'            => 'textarea',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - Primary button text.
$wp_customize->add_setting(
	'events_and_celebrations_banner_button_label_',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_button_label_',
	array(
		'label'           => esc_html__( 'Primary Button Text', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_button_label_',
		'type'            => 'text',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - Primary button link.
$wp_customize->add_setting(
	'events_and_celebrations_banner_button_link_',
	array(
		'default'           => '',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_button_link_',
	array(
		'label'           => esc_html__( 'Primary Button Link', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_button_link_',
		'type'            => 'url',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - Secondary button text.
$wp_customize->add_setting(
	'events_and_celebrations_banner_secondary_button_label',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_secondary_button_label',
	array(
		'label'           => esc_html__( 'Secondary Button Text', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_secondary_button_label',
		'type'            => 'text',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - YouTube Video Embed URL.
$wp_customize->add_setting(
	'events_and_celebrations_banner_secondary_button_link',
	array(
		'default'           => '',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_banner_secondary_button_link',
	array(
		'label'           => esc_html__( 'YouTube Video Embed URL', 'events-and-celebrations' ),
		'description'     => esc_html__( 'Enter a YouTube embed URL (not the normal watch URL). Example: https://www.youtube.com/embed/u_qFlTu7HTw?si=L1OvkFNK77nZJ-NY', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_banner_section',
		'settings'        => 'events_and_celebrations_banner_secondary_button_link',
		'type'            => 'url',
		'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
	)
);

// Banner Section - Hero image.
$wp_customize->add_setting(
	'events_and_celebrations_banner_section_image',
	array(
		'default'           => get_template_directory_uri() . '/resource/img/default1.png',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	new WP_Customize_Image_Control(
		$wp_customize,
		'events_and_celebrations_banner_section_image',
		array(
			'label'           => esc_html__( 'Banner Image', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);


for ( $events_and_celebrations_i = 1; $events_and_celebrations_i <= 4; $events_and_celebrations_i++ ) {

    // Feature Icon
    $wp_customize->add_setting(
        'events_and_celebrations_banner_feature_icon_' . $events_and_celebrations_i,
        array(
            'default'           => 'fas fa-star',
            'sanitize_callback' => 'sanitize_text_field',
            'capability'        => 'edit_theme_options',
        )
    );

    $wp_customize->add_control(
        new Events_And_Celebrations_Change_Icon_Control(
            $wp_customize,
            'events_and_celebrations_banner_feature_icon_' . $events_and_celebrations_i,
            array(
                'label'           => sprintf( __( 'Feature %d Icon', 'events-and-celebrations' ), $events_and_celebrations_i ),
                'section'         => 'events_and_celebrations_banner_section',
                'iconset'         => 'fa',
                'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
            )
        )
    );

    // Feature Title
    $wp_customize->add_setting(
        'events_and_celebrations_banner_feature_title_' . $events_and_celebrations_i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'events_and_celebrations_banner_feature_title_' . $events_and_celebrations_i,
        array(
            'label'           => sprintf( __( 'Feature %d Title', 'events-and-celebrations' ), $events_and_celebrations_i ),
            'section'         => 'events_and_celebrations_banner_section',
            'type'            => 'text',
            'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
        )
    );
}

// Primary button text color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_btn_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_btn_color',
		array(
			'label'           => esc_html__( 'Primary Button Label Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_btn_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);

// Primary button background color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_btn_bg_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_btn_bg_color',
		array(
			'label'           => esc_html__( 'Primary Button Background Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_btn_bg_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);

// Primary button border color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_btn_border_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_btn_border_color',
		array(
			'label'           => esc_html__( 'Primary Button Border Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_btn_border_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);

// Secondary button text color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_secondary_btn_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_secondary_btn_color',
		array(
			'label'           => esc_html__( 'Secondary Button Label Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_secondary_btn_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);

// Secondary button background color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_secondary_btn_bg_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_secondary_btn_bg_color',
		array(
			'label'           => esc_html__( 'Secondary Button Background Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_secondary_btn_bg_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);

// Secondary button border color.
$wp_customize->add_setting(
	'events_and_celebrations_banner_secondary_btn_border_color',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);

$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'events_and_celebrations_banner_secondary_btn_border_color',
		array(
			'label'           => esc_html__( 'Secondary Button Border Color', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_banner_section',
			'settings'        => 'events_and_celebrations_banner_secondary_btn_border_color',
			'active_callback' => 'events_and_celebrations_is_banner_slider_section_enabled',
		)
	)
);
