<?php
/**
 * Service Section
 *
 * @package interior_services
 */

 $wp_customize->add_section(
	'interior_services_services_section',
	array(
		'panel'    => 'interior_services_front_page_options',
		'title'    => esc_html__( 'services Section', 'interior-services' ),
		'priority' => 10,
	)
);

//Service Section - Enable Section.
$wp_customize->add_setting(
	'interior_services_enable_services_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'interior_services_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Interior_Services_Toggle_Switch_Custom_Control(
		$wp_customize,
		'interior_services_enable_services_section',
		array(
			'label'    => esc_html__( 'Enable services Section', 'interior-services' ),
			'section'  => 'interior_services_services_section',
			'settings' => 'interior_services_enable_services_section'
		)
	)
);

// Service Section - Content Label.
$wp_customize->add_setting(
	'interior_services_trending_post_content',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'interior_services_trending_post_content',
	array(
		'label'           => esc_html__( 'Sub Heading', 'interior-services' ),
		'section'         => 'interior_services_services_section',
		'settings'        => 'interior_services_trending_post_content',
		'type'            => 'text',
		'active_callback' => 'interior_services_is_services_section_enabled',
	)
);

// Service Section - Heading Label.
$wp_customize->add_setting(
	'interior_services_trending_post_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'interior_services_trending_post_heading',
	array(
		'label'           => esc_html__( 'Heading', 'interior-services' ),
		'section'         => 'interior_services_services_section',
		'settings'        => 'interior_services_trending_post_heading',
		'type'            => 'text',
		'active_callback' => 'interior_services_is_services_section_enabled',
	)
);

// Number of Service Posts to Show
$wp_customize->add_setting('interior_services_services_post_count',array(
	'default'	=> '',
	'sanitize_callback'	=> 'sanitize_text_field',
));
$wp_customize->add_control('interior_services_services_post_count',array(
	'label'	=> __('Number of services to show','interior-services'),
	'description' => __('Add number and refresh tab','interior-services'),
	'section'	=> 'interior_services_services_section',
	'type'		=> 'number',
	'active_callback' => 'interior_services_is_services_section_enabled',
	'input_attrs' => array(
		'step'             => 1,
		'min'              => 0,
		'max'              => 12,
	)
));
$interior_services_featured_post = get_theme_mod('interior_services_services_post_count');

for ( $interior_services_i = 1; $interior_services_i <= $interior_services_featured_post; $interior_services_i++ ) {
	
	// Service Section - Select Post.
	$wp_customize->add_setting(
		'interior_services_services_content_post_' . $interior_services_i,
		array(
			'sanitize_callback' => 'absint',
		)
	);

	$wp_customize->add_control(
		'interior_services_services_content_post_' . $interior_services_i,
		array(
			'label'           => esc_html__( 'Select Post ', 'interior-services' ) . $interior_services_i,
			'section'         => 'interior_services_services_section',
			'settings'        => 'interior_services_services_content_post_' . $interior_services_i,
			'type'            => 'select',
			'choices'         => interior_services_get_post_choices(),
		)
	);

	$wp_customize->add_setting('interior_services_services_icon'.$interior_services_i,array(
		'default'=> '',
		'sanitize_callback' => 'sanitize_text_field'
	));
		$wp_customize->add_control('interior_services_services_icon'.$interior_services_i,array(
		'label' => __('Icon ','interior-services').$interior_services_i,
		'description' => __('Fontawesome Icon (e.g., fas fa-couch)','interior-services'),
		'section'=> 'interior_services_services_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting('interior_services_services_name' . $interior_services_i, array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	$wp_customize->add_control('interior_services_services_name' . $interior_services_i, array(
		'label'    => __('Services Name ', 'interior-services') . $interior_services_i,
		'section'  => 'interior_services_services_section',
		'type'     => 'text',
	));

}

// Partial Refresh
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'interior_services_enable_services_section',
		array(
			'selector' => '#interior_services_services_section .section-link',
			'settings' => 'interior_services_enable_services_section',
		)
	);
}

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

$wp_customize->add_control(
	'interior_services_service_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(INTERIOR_SERVICES_PREMIUM_PAGE) ." '>Upgrade Pro</a>
				</div>
			</div>
		",
		'section' => 'interior_services_services_section'
	)
);