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

if ( ! function_exists( 'business_article_ship_customizer_home_services_register' ) ) :
function business_article_ship_customizer_home_services_register( $wp_customize ) {

    $wp_customize->add_section(
        'business_article_ship_home_services_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__( 'Services Settings', 'business-article-ship' )
        )
    );

    // Title label
    $wp_customize->add_setting( 
        'business_article_ship_label_services_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_services_settings_title', 
        array(
            'label'       => esc_html__( 'Services Settings', 'business-article-ship' ),
            'section'     => 'business_article_ship_home_services_settings',
            'type'        => 'business-article-ship-title',
            'settings'    => 'business_article_ship_label_services_settings_title',
        ) 
    ));

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

    $wp_customize->add_control(
        'business_article_ship_services_small_heading',
        array(
            'label'           => sprintf( esc_html__( 'Small Heading', 'business-article-ship' ), ),
            'section'         => 'business_article_ship_home_services_settings',
            'settings'        => 'business_article_ship_services_small_heading' ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_services_main_heading',
        array(
            'label'           => sprintf( esc_html__( 'Main Heading', 'business-article-ship' ), ),
            'section'         => 'business_article_ship_home_services_settings',
            'settings'        => 'business_article_ship_services_main_heading' ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_services_text',
        array(
            'label'           => sprintf( esc_html__( 'Text', 'business-article-ship' ), ),
            'section'         => 'business_article_ship_home_services_settings',
            'settings'        => 'business_article_ship_services_text' ,
            'type'            => 'text',
        )
    );

   $wp_customize->add_setting( 'business_article_ship_services_increase', array(
        'default'           => '', 
        'sanitize_callback' => 'business_article_ship_sanitize_number',
    ));

    // Add control for number of products
    $wp_customize->add_control( 'business_article_ship_services_increase', array(
        'label'       => __( 'Number of Services to Display', 'business-article-ship' ),
        'section'     => 'business_article_ship_home_services_settings', 
        'type'        => 'number',       
    ));

    $business_article_ship_services_count =  get_theme_mod('business_article_ship_services_increase');

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

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

    $wp_customize->add_control(
        'business_article_ship_services_icon'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Services Icon', 'business-article-ship' ).$i, ),
            'input_attrs' => array(
                'placeholder'     => esc_html__( 'bi bi-lightbulb', 'business-article-ship' )),           
            'description'     => 'Add Bootstrap Icon from given link:- https://icons.getbootstrap.com/ ',
            'section'         => 'business_article_ship_home_services_settings',
            'settings'        => 'business_article_ship_services_icon'.$i ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'business_article_ship_services_inner_heading'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Inner Heading', 'business-article-ship' ).$i, ),
            'section'         => 'business_article_ship_home_services_settings',
            'settings'        => 'business_article_ship_services_inner_heading'.$i ,
            'type'            => 'text',
        )
    );
    }
    $wp_customize->add_setting(
            'business_article_ship_services_right_image',
            array(
                'default'           => '',
                'sanitize_callback' => 'business_article_ship_sanitize_image',

            )
        );
        
        $wp_customize->add_control(
            new WP_Customize_Image_Control(
                $wp_customize, 'business_article_ship_services_right_image', 
                array(
                    'label'           => sprintf( esc_html__( 'Right Image', 'business-article-ship' ), ),
                    'settings'  => 'business_article_ship_services_right_image',
                    'section'   => 'business_article_ship_home_services_settings'
                ) 
            )
        );
}
endif;

add_action( 'customize_register', 'business_article_ship_customizer_home_services_register' );