<?php
/**
 * Theme Customizer Controls
 *
 * @package Business Article Ship
 */


if ( ! function_exists( 'business_article_ship_customizer_home_banner_register' ) ) :
function business_article_ship_customizer_home_banner_register( $wp_customize ) {
 	
 	$wp_customize->add_section(
        'business_article_ship_home_banner_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__( 'Banner Settings', 'business-article-ship' )
        )
    );

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

	$wp_customize->add_control( 
		new Business_Article_Ship_Title_Info_Control( $wp_customize, 'business_article_ship_label_banner_settings_title', 
		array(
		    'label'       => esc_html__( 'Banner Settings', 'business-article-ship' ),
		    'section'     => 'business_article_ship_home_banner_settings',
		    'type'        => 'business-article-ship-title',
		    'settings'    => 'business_article_ship_label_banner_settings_title',
		) 
	));

    $wp_customize->add_setting('business_article_ship_banner_slider_increase',array(
        'default' => '',
        'sanitize_callback' => 'business_article_ship_sanitize_number',
    ));
    $wp_customize->add_control('business_article_ship_banner_slider_increase',array(
        'label' => __('Number of slides to show','business-article-ship'),
        'section' => 'business_article_ship_home_banner_settings',
        'type'    => 'number'
    ));
      $business_article_ship_banner_count =  get_theme_mod('business_article_ship_banner_slider_increase');

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

    // Button Image
    $wp_customize->add_setting(
        'business_article_ship_banner_image'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'business_article_ship_sanitize_image',

        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize, 'business_article_ship_banner_image'.$i, 
            array(
                'label'           => sprintf( esc_html__( 'Banner Image', 'business-article-ship' ).$i, ),
                'settings'  => 'business_article_ship_banner_image'.$i,
                'section'   => 'business_article_ship_home_banner_settings'
            ) 
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_banner_heading'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Heading', 'business-article-ship' ).$i, ),
            'section'         => 'business_article_ship_home_banner_settings',
            'settings'        => 'business_article_ship_banner_heading'.$i ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_banner_text'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Text', 'business-article-ship' ).$i, ),
            'section'         => 'business_article_ship_home_banner_settings',
            'settings'        => 'business_article_ship_banner_text'.$i ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_banner_button_link'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Button Link', 'business-article-ship' ).$i, ),
            'section'         => 'business_article_ship_home_banner_settings',
            'settings'        => 'business_article_ship_banner_button_link'.$i ,
            'type'            => 'url',
        )
    );
}
// Slider Content Alignment Setting
    $wp_customize->add_setting(
        'business_article_ship_slider_content_alignment',
        array(
            'default'           => 'left',
            'sanitize_callback' => 'business_article_ship_sanitize_select',
        )
    );

    $wp_customize->add_control(
        'business_article_ship_slider_content_alignment',
        array(
            'label'    => esc_html__( 'Slider Content Alignment', 'business-article-ship' ),
            'section'  => 'business_article_ship_home_banner_settings',
            'settings' => 'business_article_ship_slider_content_alignment',
            'type'     => 'select',
            'choices'  => array(
                'left'   => esc_html__( 'Left', 'business-article-ship' ),
                'center' => esc_html__( 'Center', 'business-article-ship' ),
                'right'  => esc_html__( 'Right', 'business-article-ship' ),
            ),
        )
    );
}
endif;

add_action( 'customize_register', 'business_article_ship_customizer_home_banner_register' );