<?php
/**
 * Activities Section options
 *
 * @package Theme Palace
 * @subpackage Ultravel
 * @since Ultravel 1.0.0
 */

// Add Activities section
$wp_customize->add_section( 'ultravel_activities_section', array(
    'title'             => esc_html__( 'Activities','ultravel' ),
    'description'       => esc_html__( 'Activities Section options.', 'ultravel' ),
    'panel'             => 'ultravel_front_page_panel',
) );

// Activities content enable control and setting
$wp_customize->add_setting( 'ultravel_theme_options[activities_section_enable]', array(
    'default'           =>  $options['activities_section_enable'],
    'sanitize_callback' => 'ultravel_sanitize_switch_control',
) );

$wp_customize->add_control( new Ultravel_Switch_Control( $wp_customize, 'ultravel_theme_options[activities_section_enable]', array(
    'label'             => esc_html__( 'Activities Section Enable', 'ultravel' ),
    'section'           => 'ultravel_activities_section',
    'on_off_label'      => ultravel_switch_options(),
) ) );

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


// popular destination read more setting and control
$wp_customize->add_setting( 'ultravel_theme_options[activities_title]', array(
    'default'           => $options['activities_title'],
    'sanitize_callback' => 'sanitize_text_field',
    'transport'         => 'postMessage',
) );

$wp_customize->add_control( 'ultravel_theme_options[activities_title]', array(
    'label'             => esc_html__( 'Title', 'ultravel' ),
    'section'           => 'ultravel_activities_section',
    'active_callback'   => 'ultravel_is_activities_section_enable',
    'type'              => 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'ultravel_theme_options[activities_title]', array(
        'selector'            => '#ultravel_activities_section .section-header h2',
        'settings'            => 'ultravel_theme_options[activities_title]',
        'container_inclusive' => false,
        'fallback_refresh'    => true,
        'render_callback'     => 'ultravel_activities_title_partial',
    ) );
}


$wp_customize->add_setting( 'ultravel_theme_options[activities_sub_title]', array(
    'default'           => $options['activities_sub_title'],
    'sanitize_callback' => 'sanitize_text_field',
    'transport'         => 'postMessage',
) );

$wp_customize->add_control( 'ultravel_theme_options[activities_sub_title]', array(
    'label'             => esc_html__( 'Sub Title', 'ultravel' ),
    'section'           => 'ultravel_activities_section',
    'active_callback'   => 'ultravel_is_activities_section_enable',
    'type'              => 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'ultravel_theme_options[activities_sub_title]', array(
        'selector'            => '#ultravel_activities_section .section-header p',
        'settings'            => 'ultravel_theme_options[activities_sub_title]',
        'container_inclusive' => false,
        'fallback_refresh'    => true,
        'render_callback'     => 'ultravel_activities_sub_title_partial',
    ) );
}

// Activities content type control and setting
$wp_customize->add_setting( 'ultravel_theme_options[activities_content_type]', array(
    'default'           => $options['activities_content_type'],
    'sanitize_callback' => 'ultravel_sanitize_select',
) );

$wp_customize->add_control( 'ultravel_theme_options[activities_content_type]', array(
    'label'             => esc_html__( 'Content Type', 'ultravel' ),
    'section'           => 'ultravel_activities_section',
    'type'              => 'select',
    'active_callback'   => 'ultravel_is_activities_section_enable',
    'choices'           => ultravel_activities_content_type(),
) );

for ( $i=1; $i <= 4; $i++ ) { 
    // Add dropdown category setting and control.
    $wp_customize->add_setting(  'ultravel_theme_options[activities_content_category_' . $i . ']', array(
        'sanitize_callback' => 'ultravel_sanitize_single_category',
    ) ) ;

    $wp_customize->add_control( new Ultravel_Dropdown_Taxonomies_Control( $wp_customize,'ultravel_theme_options[activities_content_category_' . $i . ']', array(
        'label'             => sprintf( esc_html__( 'Select Category %d', 'ultravel'), $i ),
        'description'       => esc_html__( 'Note: Latest selected no of posts will be shown from selected category', 'ultravel' ),
        'section'           => 'ultravel_activities_section',
        'type'              => 'dropdown-taxonomies',
        'active_callback'   => 'ultravel_is_activities_section_content_category_enable'
    ) ) );

    // Add dropdown category setting and control.
    $wp_customize->add_setting(  'ultravel_theme_options[activities_content_trip_types_' . $i . ']', array(
        'sanitize_callback' => 'absint',
    ) ) ;

    $wp_customize->add_control( new Ultravel_Dropdown_Taxonomies_Control( $wp_customize,'ultravel_theme_options[activities_content_trip_types_' . $i . ']', array(
        'label'             => sprintf( esc_html__( 'Select Trip Types %d', 'ultravel'), $i ),
        'section'           => 'ultravel_activities_section',
        'taxonomy'          => 'itinerary_types',
        'type'              => 'dropdown-taxonomies',
        'active_callback'   => 'ultravel_is_activities_section_content_trip_types_enable'
    ) ) );

    // Activities image enable control and setting
    $wp_customize->add_setting( 'ultravel_theme_options[activities_background_image_' . $i . ']', array(
        'sanitize_callback' => 'ultravel_sanitize_image',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'ultravel_theme_options[activities_background_image_' . $i . ']',
            array(
            'label'             => sprintf( esc_html__( 'Category Image %d', 'ultravel' ), $i ),
            'description'       => sprintf( esc_html__( 'Recommended size: %1$dpx x %2$dpx ', 'ultravel' ), 500, 500 ),
            'section'           => 'ultravel_activities_section',
            'active_callback'   => 'ultravel_is_activities_section_content_category_enable',
    ) ) );

    // counter hr setting and control
    $wp_customize->add_setting( 'ultravel_theme_options[activities_hr_'. $i .']', array(
        'sanitize_callback' => 'ultravel_sanitize_html',
    ) );
}


