<?php
/**
* Why choose us Settings
*
* @package relax_spa
*/

add_action( 'customize_register', 'relax_spa_customize_why_choose_us_option' );

function relax_spa_customize_why_choose_us_option( $wp_customize ) {

    $wp_customize->add_section( 'relax_spa_why_choose_us_section', array(
        'title'         => esc_html__( 'Why choose us Section', 'relax-spa' ),
        'panel'         => 'relax_spa_homepage_panel'
    ) );

    $wp_customize->add_setting('bs_why_choose_us_display_option', array(
        'sanitize_callback' => 'relax_spa_sanitize_checkbox',
        'default' => true
    ));

    $wp_customize->add_control(new Relax_Spa_Toggle_Control($wp_customize, 'bs_why_choose_us_display_option', array(
        'label' => esc_html__('Hide / Show', 'relax-spa'),
        'section' => 'relax_spa_why_choose_us_section',
        'type'=> 'relax-spa-toggle',
    )));

    $wp_customize->add_setting('bs_top_heading_for_why_choose_us', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
        'default' => ''
    ));

    $wp_customize->add_control('bs_top_heading_for_why_choose_us', array(
        'label' => esc_html__('Enter Top Heading', 'relax-spa'),
        'section' => 'relax_spa_why_choose_us_section',
        'type' => 'text',
    ));

    $wp_customize->add_setting('bs_heading_for_why_choose_us', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
        'default' => ''
    ));

    $wp_customize->add_control('bs_heading_for_why_choose_us', array(
        'label' => esc_html__('Enter Main Heading', 'relax-spa'),
        'section' => 'relax_spa_why_choose_us_section',
        'type' => 'text',
    ));

    $wp_customize->add_setting( 'bs_image_for_why_choose_us', array(
        'sanitize_callback'     =>  'relax_spa_sanitize_image',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'bs_image_for_why_choose_us', array(
        'label'      => esc_html__( 'Image', 'relax-spa' ),
        'section'    => 'relax_spa_why_choose_us_section',
        'settings'   => 'bs_image_for_why_choose_us',
    ) ) );

    $wp_customize->add_setting( new Relax_Spa_Repeater_Setting( $wp_customize, 'bs_points_for_why_choose_us', array(
        'sanitize_callback' => array( 'Relax_Spa_Repeater_Setting', 'sanitize_repeater_setting' ),
    ) ) );

    $wp_customize->add_control( new Relax_Spa_Control_Repeater( $wp_customize, 'bs_points_for_why_choose_us', array(
        'section' => 'relax_spa_why_choose_us_section',
        'settings'    => 'bs_points_for_why_choose_us',
        'label'			=> __( 'Add Points ', 'relax-spa' ),
        'row_label' => array(
            'type'  => 'field',
            'value' => esc_html__( 'points', 'relax-spa' ),
            'field' => 'bs_why_choose_us_title',
        ), 
        'fields'     => array(
            'bs_why_choose_us_thumbnail'     => array(
                'type'   => 'image',
                'label'  => __( 'Thumbnail', 'relax-spa' ),
            ),
            'bs_why_choose_us_title'     => array(
                'type'  => 'text',
                'label' => __( 'Title', 'relax-spa' ),
            ),
            'bs_why_choose_us_desc'     => array(
                'type'  => 'textarea',
                'label' => __( 'Description', 'relax-spa' ),
            ),
        ),                   
    ) ) );

    $wp_customize->selective_refresh->add_partial('bs_why_choose_us_display_option', array(
        'selector' => '.why-choose > .container', // You can also select a css class
    ));

}