<?php
/**
 * Services Section
 *
 * @package aster_portfolio
 */

$wp_customize->add_section(
	'aster_portfolio_services_section',
	array(
		'panel'    => 'aster_portfolio_front_page_options',
		'title'    => esc_html__( 'Services Section', 'aster-portfolio' ),
		'priority' => 10,
	)
);

// services Section - Enable Section.
$wp_customize->add_setting(
	'aster_portfolio_enable_services_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'aster_portfolio_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Aster_Portfolio_Toggle_Switch_Custom_Control(
		$wp_customize,
		'aster_portfolio_enable_services_section',
		array(
			'label'    => esc_html__( 'Enable Services Section', 'aster-portfolio' ),
			'section'  => 'aster_portfolio_services_section',
			'settings' => 'aster_portfolio_enable_services_section',
		)
	)
);

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

// services Section - services Content
$wp_customize->add_setting(
	'aster_portfolio_services_short_content',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'aster_portfolio_services_short_content',
	array(
		'label'           => sprintf( esc_html__( 'Services Sub Heading', 'aster-portfolio' )),
		'section'         => 'aster_portfolio_services_section',
		'settings'        => 'aster_portfolio_services_short_content',
		'type'            => 'text',
		'active_callback' => 'aster_portfolio_is_services_section_enabled',
	)
);

// services Section - services Heading.
$wp_customize->add_setting(
	'aster_portfolio_services_section_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'aster_portfolio_services_section_heading',
	array(
		'label'           => sprintf( esc_html__( 'Services Heading', 'aster-portfolio' )),
		'section'         => 'aster_portfolio_services_section',
		'settings'        => 'aster_portfolio_services_section_heading',
		'type'            => 'text',
		'active_callback' => 'aster_portfolio_is_services_section_enabled',
	)
);

// services Section - services Content.
$wp_customize->add_setting(
	'aster_portfolio_services_section_content',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'aster_portfolio_services_section_content',
	array(
		'label'           => sprintf( esc_html__( 'Services Content', 'aster-portfolio' )),
		'section'         => 'aster_portfolio_services_section',
		'settings'        => 'aster_portfolio_services_section_content',
		'type'            => 'text',
		'active_callback' => 'aster_portfolio_is_services_section_enabled',
	)
);

// Post Categories
$aster_portfolio_categories = get_categories();
$aster_portfolio_cat_posts = array();
$default = '';
$aster_portfolio_cat_posts[] = 'Select';
foreach ($aster_portfolio_categories as $aster_portfolio_category) {
	$aster_portfolio_cat_posts[$aster_portfolio_category->slug] = $aster_portfolio_category->name;
}

$wp_customize->add_setting(
	'aster_portfolio_blog_args_',
	array(
		'default'            => 'select',
		'sanitize_callback'  => 'aster_portfolio_sanitize_choices',
	)
);
$wp_customize->add_control(
	'aster_portfolio_blog_args_',
	array(
		'type'     => 'select',
		'choices'  => $aster_portfolio_cat_posts,
		'label'    => __('Select Category', 'aster-portfolio'),
		'section'  => 'aster_portfolio_services_section',
		'active_callback' => 'aster_portfolio_is_services_section_enabled',
	)
);

for ($aster_portfolio_i=1; $aster_portfolio_i <= 10; $aster_portfolio_i++) {

	$wp_customize->add_setting('aster_portfolio_category_icon'.$aster_portfolio_i,array(
		'default'   => '',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control(new Aster_Portfolio_Change_Icon_Control(
		$wp_customize,'aster_portfolio_category_icon'.$aster_portfolio_i,array(
		'label' => __('Feature Icon ','aster-portfolio').$aster_portfolio_i,
		'section'  => 'aster_portfolio_services_section',
		'active_callback' => 'aster_portfolio_is_services_section_enabled',
		'type'      => 'icon'
	)));
}

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

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