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

$default = party_planner_bell_get_default_theme_options();

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

$wp_customize->add_setting( 'theme_options[disable_testimonial_section]',
	array(
		'default'           => $default['disable_testimonial_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_testimonial_section]',
    array(
		'label' 			=> __('Enable/Disable Testimonial Section', 'party-planner-bell'),
		'section'    		=> 'section_home_testimonial',
		 'settings'  		=> 'theme_options[disable_testimonial_section]',
		'on_off_label' 		=> party_planner_bell_switch_options(),
    )
) );

// Testimonial Image
$wp_customize->add_setting('theme_options[testimonial_side_image]', 
	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[testimonial_side_image]', 
	array(
	'label'       => __('Section Background Image', 'party-planner-bell'),
	'section'     => 'section_home_testimonial',   
	'settings'    => 'theme_options[testimonial_side_image]',		
	'active_callback' => 'party_planner_bell_testimonial_active',
	'type'        => 'image',
	)
	)
);
// Add dots enable setting and control.
$wp_customize->add_setting( 'theme_options[testimonial_dots_enable]', array(
	'default'           => $default['testimonial_dots_enable'],
	'sanitize_callback' => 'party_planner_bell_sanitize_checkbox',
) );
$wp_customize->add_control( 'theme_options[testimonial_dots_enable]', array(
	'label'             => esc_html__( 'Enable Post Slider Slider Dots', 'party-planner-bell' ),
	'section'           => 'section_home_testimonial',
	'type'              => 'checkbox',
	'active_callback' => 'party_planner_bell_testimonial_active',
) );

$wp_customize->add_setting( 'theme_options[testimonial_background_color]', array(
    'sanitize_callback' => 'sanitize_hex_color', // The hue is stored as a positive integer.
    'default'           => '#efefef',
    
) );

$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'theme_options[testimonial_background_color]', array(
    'label'    => esc_html__( 'Background Color', 'party-planner-bell' ),
    'section'  => 'section_home_testimonial',
    'active_callback' => 'party_planner_bell_testimonial_active',
) ) );

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

$wp_customize->add_control('theme_options[testimonial_title]', 
	array(
	'label'       => __('Section Title', 'party-planner-bell'),
	'section'     => 'section_home_testimonial',   
	'settings'    => 'theme_options[testimonial_title]',
	'active_callback' => 'party_planner_bell_testimonial_active',		
	'type'        => 'text'
	)
);

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

$wp_customize->add_control('theme_options[testimonial_subtitle]', 
	array(
	'label'       => __('Section Sub Title', 'party-planner-bell'),
	'section'     => 'section_home_testimonial',   
	'settings'    => 'theme_options[testimonial_subtitle]',
	'active_callback' => 'party_planner_bell_testimonial_active',		
	'type'        => 'textarea'
	)
);

$number_of_testimonial_items = party_planner_bell_get_option( 'number_of_testimonial_items' );

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

	// Posts
	$wp_customize->add_setting('theme_options[testimonial_post_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'party_planner_bell_dropdown_pages'
		)
	);

	$wp_customize->add_control('theme_options[testimonial_post_'.$i.']', 
		array(
		'label'       => sprintf( __('Select Post #%1$s', 'party-planner-bell'), $i),
		'section'     => 'section_home_testimonial',   
		'settings'    => 'theme_options[testimonial_post_'.$i.']',		
		'type'        => 'select',
		'choices'	  => party_planner_bell_post_choices(),
		'active_callback' => 'party_planner_bell_testimonial_active',
		)
	);

	$wp_customize->add_setting( 'theme_options[testimonial_position_' . $i . ']', array(
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'theme_options[testimonial_position_' . $i . ']', array(
		'label'           	=> sprintf( __( 'Position %d', 'party-planner-bell' ), $i ),
		'section'        	=> 'section_home_testimonial',	
		'active_callback' 	=> 'party_planner_bell_testimonial_active',
		'type'				=> 'text',
	) );

	// testimonial hr setting and control
	$wp_customize->add_setting( 'theme_options[testimonial_hr_'. $i .']', array(
		'sanitize_callback' => 'sanitize_text_field'
	) );

	$wp_customize->add_control( new Party_Planner_Bell_Customize_Horizontal_Line( $wp_customize, 'theme_options[testimonial_hr_'. $i .']',
		array(
			'label'             => __( '<hr style="width: 100%; border: 2px #bcb1b1 solid;"/>', 'party-planner-bell' ),
			'section'         => 'section_home_testimonial',
			'active_callback' => 'party_planner_bell_testimonial_active',
			'type'			  => 'hr',
	) ) );

}