<?php
/**
 * Client Section options
 *
 * @package Theme Palace
 * @subpackage Enlightme
 * @since Enlightme 1.0.0
 */
// Add client Collection section
$wp_customize->add_section( 'enlightme_client_section', array(
    'title'             => esc_html__( 'Client','enlightme' ),
    'description'       => esc_html__( 'Client Section options.', 'enlightme' ),
    'panel'             => 'enlightme_front_page_panel',
) );

// client content enable control and setting
$wp_customize->add_setting( 'enlightme_theme_options[client_section_enable]', array(
    'default'           =>  $options['client_section_enable'],
    'sanitize_callback' => 'enlightme_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[client_section_enable]', array(
    'label'             => esc_html__( 'Client Section Enable', 'enlightme' ),
    'section'           => 'enlightme_client_section',
    'on_off_label'      => enlightme_switch_options(),
) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[client_section_enable]', array(
        'selector'            => '#client .tooltiptext',
        'settings'            => 'enlightme_theme_options[client_section_enable]',
    ) );
}

// featured title setting and control
$wp_customize->add_setting( 'enlightme_theme_options[client_title]', array(
    'sanitize_callback' => 'sanitize_text_field',
    'default'           => $options['client_title'],
    'transport'         => 'postMessage',
) );

$wp_customize->add_control( 'enlightme_theme_options[client_title]', array(
    'label'             => esc_html__( 'Client Section Label', 'enlightme' ),
    'section'           => 'enlightme_client_section',
    'active_callback'   => 'enlightme_is_featured_section_enable',
    'type'              => 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[client_title]', array(
        'selector'            => '#client .wrapper p',
        'settings'            => 'enlightme_theme_options[client_title]',
        'container_inclusive' => false,
        'fallback_refresh'    => true,
        'render_callback'     => 'enlightme_client_title_partial',
    ) );
}

for ($i=1; $i <= 6; $i++) :

    $wp_customize->add_setting( 'enlightme_theme_options[client_image_' . $i . ']', array(
        'sanitize_callback' => 'enlightme_sanitize_image',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_theme_options[client_image_' . $i . ']',
            array(
            'label'             => sprintf( esc_html__( 'Client Logo %d', 'enlightme' ), $i ),
            'section'           => 'enlightme_client_section',
            'active_callback'   => 'enlightme_is_client_section_enable',
    ) ) );

    $wp_customize->add_setting( 'enlightme_theme_options[client_url_' . $i . ']', array(
        'sanitize_callback' => 'esc_url_raw',
    ) );

    $wp_customize->add_control( 'enlightme_theme_options[client_url_' . $i . ']', array(
        'label'             => sprintf( esc_html__( 'Client Url %d', 'enlightme' ), $i ),
        'section'           => 'enlightme_client_section',
        'active_callback'   => 'enlightme_is_client_section_enable',
        'type'              => 'url',
    ) );


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

    $wp_customize->add_control( new Enlightme_Customize_Horizontal_Line( $wp_customize, 'enlightme_theme_options[client_hr_'. $i .']',
        array(
            'section'           => 'enlightme_client_section',
            'active_callback'   => 'enlightme_is_client_section_enable',
            'type'            => 'hr'
    ) ) );

endfor;