<?php
/**
 * General Settings
 *
 * @package relax_spa
 */

/**
 * Social media
 *
 */
function relax_spa_social_media() {
    $social_media = array(
        'facebook' => esc_html__( 'Facebook', 'relax-spa' ),
        'twitter' => esc_html__( 'Twitter', 'relax-spa' ),
        'pinterest' => esc_html__( 'Pinterest', 'relax-spa' ),
        'instagram' => esc_html__( 'Instagram', 'relax-spa' ),
        'youtube' => esc_html__( 'Youtube', 'relax-spa' ),
        'linkedin' => esc_html__( 'LinkedIn', 'relax-spa' ),
        'tripadvisor' => esc_html__( 'Tripadvisor', 'relax-spa' ),
    );
    return $social_media;
}

add_action( 'customize_register', 'relax_spa_customize_social_media' );

function relax_spa_customize_social_media( $wp_customize ) {

    $wp_customize->add_section( 'relax_spa_social_media', array(
        'title'         => esc_html__( 'Social Media', 'relax-spa' ),
        'description'   => esc_html__( 'Social Media', 'relax-spa' ),
        'panel'         => 'relax_spa_header_panel',
        'priority'      => 9,
    ) );
    
    $wp_customize->add_setting( new Relax_Spa_Repeater_Setting( $wp_customize, 'relax_spa_social_media', array(
        'sanitize_callback' => array( 'Relax_Spa_Repeater_Setting', 'sanitize_repeater_setting' ),
    ) ) );

    $wp_customize->add_control( new Relax_Spa_Control_Repeater( $wp_customize, 'relax_spa_social_media', array(
        'section' => 'relax_spa_social_media',
        'settings'    => 'relax_spa_social_media',
        'label'   => esc_html__( 'Social Media', 'relax-spa' ),
        'row_label' => array(
            'type'  => 'field',
            'value' => esc_html__( 'Social Media', 'relax-spa' ),
            'field' => 'social_media_repeater_class',
        ), 
        'fields' => array(
            'social_media_repeater_class' => array(
                'type'        => 'select',
                'label'       => esc_html__( 'Select Social Media', 'relax-spa' ),
                'default'     => 'facebook',
                'choices'   => relax_spa_social_media()
            ),
            'social_media_link' => array(
                'type'      => 'url',
                'label'     => esc_html__( 'Social Media Links', 'relax-spa' ),
            ),          
        ),
                               
    ) ) );

    $wp_customize->selective_refresh->add_partial( 'relax_spa_social_media', array(
        'selector'        => '.social-icons',
        'render_callback' => '',
    ) );
}