<?php

/**
 * Banner Section
 *
 * @package bridal_jewelry_store
 */

$wp_customize->add_section(
	'bridal_jewelry_store_banner_section',
	array(
		'panel'    => 'bridal_jewelry_store_front_page_options',
		'title'    => esc_html__( 'Banner Section', 'bridal-jewelry-store' ),
		'priority' => 10,
	)
);

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

$wp_customize->add_control(
	new Bridal_Jewelry_Store_Toggle_Switch_Custom_Control(
		$wp_customize,
		'bridal_jewelry_store_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'bridal-jewelry-store' ),
			'section'  => 'bridal_jewelry_store_banner_section',
			'settings' => 'bridal_jewelry_store_enable_banner_section',
		)
	)
);

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


// Banner Section - Banner Slider Content Type.
$wp_customize->add_setting(
	'bridal_jewelry_store_banner_slider_content_type',
	array(
		'default'           => 'post',
		'sanitize_callback' => 'bridal_jewelry_store_sanitize_select',
	)
);

$wp_customize->add_control(
	'bridal_jewelry_store_banner_slider_content_type',
	array(
		'label'           => esc_html__( 'Select Banner Slider Content Type', 'bridal-jewelry-store' ),
		'section'         => 'bridal_jewelry_store_banner_section',
		'settings'        => 'bridal_jewelry_store_banner_slider_content_type',
		'type'            => 'select',
		'active_callback' => 'bridal_jewelry_store_is_banner_slider_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'bridal-jewelry-store' ),
			'post' => esc_html__( 'Post', 'bridal-jewelry-store' ),
		),
	)
);

for ( $bridal_jewelry_store_i = 1; $bridal_jewelry_store_i <= 3; $bridal_jewelry_store_i++ ) {

	// Banner Section - Select Banner Post.
	$wp_customize->add_setting(
		'bridal_jewelry_store_banner_slider_content_post_' . $bridal_jewelry_store_i,
		array(
			'sanitize_callback' => 'absint',
		)
	);

	$wp_customize->add_control(
		'bridal_jewelry_store_banner_slider_content_post_' . $bridal_jewelry_store_i,
		array(
			/* translators: %d: Post Count. */
			'label'           => sprintf( esc_html__( 'Select Post %d', 'bridal-jewelry-store' ), $bridal_jewelry_store_i ),
			'section'         => 'bridal_jewelry_store_banner_section',
			'settings'        => 'bridal_jewelry_store_banner_slider_content_post_' . $bridal_jewelry_store_i,
			'active_callback' => 'bridal_jewelry_store_is_banner_slider_section_and_content_type_post_enabled',
			'type'            => 'select',
			'choices'         => bridal_jewelry_store_get_post_choices(),
		)
	);

	// Banner Section - Select Banner Page.
	$wp_customize->add_setting(
		'bridal_jewelry_store_banner_slider_content_page_' . $bridal_jewelry_store_i,
		array(
			'sanitize_callback' => 'absint',
		)
	);

	$wp_customize->add_control(
		'bridal_jewelry_store_banner_slider_content_page_' . $bridal_jewelry_store_i,
		array(
			/* translators: %d: Page Count. */
			'label'           => sprintf( esc_html__( 'Select Page %d', 'bridal-jewelry-store' ), $bridal_jewelry_store_i ),
			'section'         => 'bridal_jewelry_store_banner_section',
			'settings'        => 'bridal_jewelry_store_banner_slider_content_page_' . $bridal_jewelry_store_i,
			'active_callback' => 'bridal_jewelry_store_is_banner_slider_section_and_content_type_page_enabled',
			'type'            => 'select',
			'choices'         => bridal_jewelry_store_get_page_choices(),
		)
	);

	// Banner Section - Button Label.
	$wp_customize->add_setting(
		'bridal_jewelry_store_banner_button_label_' . $bridal_jewelry_store_i,
		array(
			'default'           => '',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'bridal_jewelry_store_banner_button_label_' . $bridal_jewelry_store_i,
		array(
			/* translators: %d: Button Label Count. */
			'label'           => sprintf( esc_html__( 'Button Label %d', 'bridal-jewelry-store' ), $bridal_jewelry_store_i ),
			'section'         => 'bridal_jewelry_store_banner_section',
			'settings'        => 'bridal_jewelry_store_banner_button_label_' . $bridal_jewelry_store_i,
			'type'            => 'text',
			'active_callback' => 'bridal_jewelry_store_is_banner_slider_section_enabled',
		)
	);

	// Banner Section - Button Link.
	$wp_customize->add_setting(
		'bridal_jewelry_store_banner_button_link_' . $bridal_jewelry_store_i,
		array(
			'default'           => '',
			'sanitize_callback' => 'esc_url_raw',
		)
	);

	$wp_customize->add_control(
		'bridal_jewelry_store_banner_button_link_' . $bridal_jewelry_store_i,
		array(
			/* translators: %d: Button Link Count. */
			'label'           => sprintf( esc_html__( 'Button Link %d', 'bridal-jewelry-store' ), $bridal_jewelry_store_i ),
			'section'         => 'bridal_jewelry_store_banner_section',
			'settings'        => 'bridal_jewelry_store_banner_button_link_' . $bridal_jewelry_store_i,
			'type'            => 'url',
			'active_callback' => 'bridal_jewelry_store_is_banner_slider_section_enabled',
		)
	);
}

$wp_customize->add_setting( 
	'bridal_jewelry_store_banner_settings_upgraded_features',
	array(
		'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control(
	'bridal_jewelry_store_banner_settings_upgraded_features', 
	array(
		'type'=> 'hidden',
		'description' => "
			<div class='customizer-upgraded-features'>
				<i class='fas fa-info-circle'></i>
				<span class='pro-text'>
					Unlock Premium <strong>Features</strong> ?<br>
					<a target='_blank' href='". esc_url(BRIDAL_JEWELRY_STORE_PREMIUM_PAGE) ." '>Upgrade Pro</a>
				</div>
			</div>
		",
		'section' => 'bridal_jewelry_store_banner_section'
	)
);