<?php
/**
 * Services options.
 *
 * @package Party Planner Bell
 */

$default = party_planner_bell_get_default_theme_options();

// Services Section
$wp_customize->add_section( 'section_home_services',
	array(
		'title'      => __( 'Services Section', 'party-planner-bell' ),
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		'active_callback' => 'party_planner_bell_services_design_enable',
		)
);

$wp_customize->add_setting( 'theme_options[disable_services_section]',
	array(
		'default'           => $default['disable_services_section'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'party_planner_bell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new Party_Planner_Bell_Switch_Control( $wp_customize, 'theme_options[disable_services_section]',
    array(
		'label' 			=> __('Enable/Disable Service Section', 'party-planner-bell'),
		'section'    		=> 'section_home_services',
		 'settings'  		=> 'theme_options[disable_services_section]',
		'on_off_label' 		=> party_planner_bell_switch_options(),
    )
) );

$wp_customize->add_setting( 'theme_options[services_background_color]', array(
	'default' 			=> $default['services_background_color'],
	'sanitize_callback' => 'sanitize_hex_color', // The hue is stored as a positive integer.
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'theme_options[services_background_color]', array(
	'label'    => esc_html__( 'Background Color', 'party-planner-bell' ),
	'section'        	=> 'section_home_services',	
	'active_callback' 	=> 'party_planner_bell_services_active',
) ) );

// Add arrow enable setting and control.
$wp_customize->add_setting( 'theme_options[services_content_align]', array(

	'default'           => $default['services_content_align'],
	'sanitize_callback' => 'party_planner_bell_sanitize_select',
) );

$wp_customize->add_control( 'theme_options[services_content_align]', array(
	'label'             => esc_html__( 'Choose Content Align', 'party-planner-bell' ),
	'section'           => 'section_home_services',
	'type'              => 'radio',
	'active_callback' => 'party_planner_bell_services_active',
	'choices'				=> array( 
		'content-right'     => esc_html__( 'Right Side', 'party-planner-bell' ), 
		'content-center'     => esc_html__( 'Center Side', 'party-planner-bell' ), 
		'content-left'     => esc_html__( 'Left Side', 'party-planner-bell' ), 
		'content-justify'     => esc_html__( 'Content Justify', 'party-planner-bell' ),
		)
) );

//Services Section title
$wp_customize->add_setting('theme_options[services_top_title]', 
	array(
	'default'           => $default['services_top_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[services_top_title]', 
	array(
	'label'       => __('Section Top Title', 'party-planner-bell'),
	'section'     => 'section_home_services',   
	'settings'    => 'theme_options[services_top_title]',
	'active_callback' => 'party_planner_bell_services_active',		
	'type'        => 'text'
	)
);

//Services Section Subtitle
$wp_customize->add_setting('theme_options[services_top_content]', 
	array(
	'default'           => $default['services_top_content'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_textarea_field'
	)
);

$wp_customize->add_control('theme_options[services_top_content]', 
	array(
	'label'       => __('Section Top Content', 'party-planner-bell'),
	'section'     => 'section_home_services',   
	'settings'    => 'theme_options[services_top_content]',
	'active_callback' => 'party_planner_bell_services_active',		
	'type'        => 'textarea'
	)
);

//Services Section title
$wp_customize->add_setting('theme_options[services_btn_text]', 
	array(
	'default'           => $default['services_btn_text'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[services_btn_text]', 
	array(
	'label'       => __('Section Button Text', 'party-planner-bell'),
	'section'     => 'section_home_services',   
	'settings'    => 'theme_options[services_btn_text]',
	'active_callback' => 'party_planner_bell_services_active',		
	'type'        => 'text'
	)
);
// Message Button Url
$wp_customize->add_setting('theme_options[services_btn_url]', 
	array(
	'default'           => $default['services_btn_url'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'esc_url_raw'
	)
);

$wp_customize->add_control('theme_options[services_btn_url]', 
	array(
	'label'       => __('Button Link', 'party-planner-bell'),
	'section'     => 'section_home_services',   
	'settings'    => 'theme_options[services_btn_url]',	
	'active_callback' => 'party_planner_bell_services_active',	
	'type'        => 'url'
	)
);
for ($i=1; $i <=4 ; $i++) { 
	// Cta Background Image
	$wp_customize->add_setting('theme_options[services_top_image_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'party_planner_bell_sanitize_image'
		)
	);

	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,
		'theme_options[services_top_image_'.$i.']', 
		array(
		'label'       => sprintf( __('Upload Top Image #%1$s', 'party-planner-bell'), $i),
		'section'     => 'section_home_services',   
		'settings'    => 'theme_options[services_top_image_'.$i.']',		
		'active_callback' => 'party_planner_bell_services_active',
		'type'        => 'image',
		)
	));
}

// Add autoplay enable setting and control.
$wp_customize->add_setting( 'theme_options[disable_services_icon]', array(
	'default'           => $default['disable_services_icon'],
	'sanitize_callback' => 'party_planner_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[disable_services_icon]', array(
	'label' 			=> __('Enable/Disable Service icons', 'party-planner-bell'),
	'description' => __('If Services icons is disable then features image is enable', 'party-planner-bell'),
	'section'    		=> 'section_home_services',
	'settings'  		=> 'theme_options[disable_services_icon]',
	'type'              => 'checkbox',
	'active_callback' => 'party_planner_bell_services_active',
) );

$number_of_services_items = party_planner_bell_get_option( 'number_of_services_items' );

for( $i=1; $i<=$number_of_services_items; $i++ ){

		//Services Section icon
	$wp_customize->add_setting('theme_options[services_icon_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field',
		'default' 			=> $default['services_icon_'.$i],
		)
	);

	$wp_customize->add_control('theme_options[services_icon_'.$i.']', 
		array(
		'label'       => sprintf( __('Icon #%1$s', 'party-planner-bell'), $i),
		'description' => sprintf( __('Please input icon as eg: fa-archive. Find Font-awesome icons %1$shere%2$s', 'party-planner-bell'), '<a href="' . esc_url( 'https://fontawesome.com/v4/icons/' ) . '" target="_blank">', '</a>' ),
		'section'     => 'section_home_services',   
		'settings'    => 'theme_options[services_icon_'.$i.']',
		'active_callback' => 'party_planner_bell_services_active',		
		'type'        => 'text'
		)
	);

	// Additional Information First Post
	$wp_customize->add_setting('theme_options[services_post_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'party_planner_bell_dropdown_posts'
		)
	);
	$wp_customize->add_control( new Party_Planner_Bell_Dropdown_Chooser( $wp_customize,'theme_options[services_post_'.$i.']', 
		array(
		'label'       => sprintf( __('Select Post #%1$s', 'party-planner-bell'), $i),
		'section'     => 'section_home_services',  
		'settings'    => 'theme_options[services_post_'.$i.']',	
		'choices'			=> party_planner_bell_post_choices(),	
		'type'        => 'dropdown-posts',
		'active_callback' => 'party_planner_bell_services_active',
		)
	));
	// services hr setting and control
	$wp_customize->add_setting( 'theme_options[services_hr_'. $i .']', array(
		'sanitize_callback' => 'sanitize_text_field'
	) );

	$wp_customize->add_control( new Party_Planner_Bell_Customize_Horizontal_Line( $wp_customize, 'theme_options[services_hr_'. $i .']',
		array(
			'section'         => 'section_home_services',
			'active_callback' => 'party_planner_bell_services_active',
			'type'			  => 'hr',
	) ) );
}

