<?php
/**
 * Theme Customizer Controls
 *
 * @package Corporate Businessmen
 */

if ( ! function_exists( 'corporate_businessmen_customizer_home_banner_register' ) ) :
function corporate_businessmen_customizer_home_banner_register( $wp_customize ) {
 	
 	$wp_customize->add_section(
        'corporate_businessmen_home_banner_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__( 'Banner Settings', 'corporate-businessmen' )
        )
    );

    // Title label
	$wp_customize->add_setting( 
		'corporate_businessmen_label_banner_settings_title', 
		array(
		    'sanitize_callback' => 'corporate_businessmen_sanitize_title',
		) 
	);

	$wp_customize->add_control( 
		new Corporate_Businessmen_Title_Info_Control( $wp_customize, 'corporate_businessmen_label_banner_settings_title', 
		array(
		    'label'       => esc_html__( 'Banner Settings', 'corporate-businessmen' ),
		    'section'     => 'corporate_businessmen_home_banner_settings',
		    'type'        => 'corporate-businessmen-title',
		    'settings'    => 'corporate_businessmen_label_banner_settings_title',
		) 
	));

     $wp_customize->add_setting('corporate_businessmen_slider_increase',array(
        'default' => '',
        'sanitize_callback' => 'corporate_businessmen_sanitize_number',
    ));
    $wp_customize->add_control('corporate_businessmen_slider_increase',array(
        'label' => __('Number of slides to show','corporate-businessmen'),
        'section' => 'corporate_businessmen_home_banner_settings',
        'type'    => 'number',
        'input_attrs' => array(
            'min' => 1,
            'max' => 2,
        ),  
    ));
      $corporate_businessmen_banner_count =  get_theme_mod('corporate_businessmen_slider_increase');

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

    $wp_customize->add_setting(
        'corporate_businessmen_banner_image'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'corporate_businessmen_sanitize_image',

        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize, 'corporate_businessmen_banner_image'.$i, 
            array(
                'label'           => sprintf( esc_html__( 'Banner Image ', 'corporate-businessmen' ).$i, ),
                'settings'  => 'corporate_businessmen_banner_image'.$i,
                'section'   => 'corporate_businessmen_home_banner_settings'
            ) 
        )
    );

    $wp_customize->add_setting(
        'corporate_businessmen_banner_welcome_text'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_banner_welcome_text'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Welcome Text ( One Word Only ) ', 'corporate-businessmen' ).$i, ),
            'section'         => 'corporate_businessmen_home_banner_settings',
            'settings'        => 'corporate_businessmen_banner_welcome_text'.$i ,
            'type'            => 'text',
        )
    );

    $wp_customize->add_setting(
        'corporate_businessmen_banner_small_head'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_banner_small_head'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Small Heading ', 'corporate-businessmen' ).$i, ),
            'section'         => 'corporate_businessmen_home_banner_settings',
            'settings'        => 'corporate_businessmen_banner_small_head'.$i ,
            'type'            => 'text',
        )
    );

    // Banner Heading
    $wp_customize->add_setting(
        'corporate_businessmen_banner_heading'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_banner_heading'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Heading (maximum 7 words) ', 'corporate-businessmen' ).$i, ),
            'section'         => 'corporate_businessmen_home_banner_settings',
            'settings'        => 'corporate_businessmen_banner_heading'.$i ,
            'type'            => 'text',
        )
    );

    // Banner Content
    $wp_customize->add_setting(
        'corporate_businessmen_banner_content'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_banner_content'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Content ', 'corporate-businessmen' ).$i, ),
            'section'         => 'corporate_businessmen_home_banner_settings',
            'settings'        => 'corporate_businessmen_banner_content'.$i ,
            'type'            => 'text',
        )
    );

    // banner Button
    $wp_customize->add_setting(
        'corporate_businessmen_banner_button_link'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_banner_button_link'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Button Link ', 'corporate-businessmen' ).$i, ),
            'section'         => 'corporate_businessmen_home_banner_settings',
            'settings'        => 'corporate_businessmen_banner_button_link'.$i ,
            'type'            => 'url',
        )
    );

}

    // Slider Content Alignment Setting
    $wp_customize->add_setting(
        'corporate_businessmen_slider_content_alignment',
        array(
            'default'           => 'left',
            'sanitize_callback' => 'corporate_businessmen_sanitize_select',
        )
    );

    $wp_customize->add_control(
        'corporate_businessmen_slider_content_alignment',
        array(
            'label'    => esc_html__( 'Slider Content Alignment', 'corporate-businessmen' ),
            'section'  => 'corporate_businessmen_home_banner_settings',
            'settings' => 'corporate_businessmen_slider_content_alignment',
            'type'     => 'select',
            'choices'  => array(
                'left'   => esc_html__( 'Left', 'corporate-businessmen' ),
                'center' => esc_html__( 'Center', 'corporate-businessmen' ),
                'right'  => esc_html__( 'Right', 'corporate-businessmen' ),
            ),
        )
    );    
}
endif;

add_action( 'customize_register', 'corporate_businessmen_customizer_home_banner_register' );