<?php
/**
 * collection Section options
 *
 * @package Theme Palace
 * @subpackage Raise_Charity Pro
 * @since Raise_Charity Pro 1.0.0
 */

if ( !class_exists('WooCommerce') ) {
    return;
}

// Add collection section
$wp_customize->add_section( 'raise_charity_pro_collection_section', array(
	'title'             => esc_html__( 'Products Collection','raise-charity-pro' ),
	'description'       => esc_html__( 'Note: To activate this section you need to install WooCommerce Plugin.', 'raise-charity-pro' ),
	'panel'             => 'raise_charity_pro_front_page_panel',
) );

// collection content enable control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[collection_section_enable]', array(
	'default'			=> 	$options['collection_section_enable'],
	'sanitize_callback' => 'raise_charity_pro_sanitize_switch_control',
) );

$wp_customize->add_control( new Raise_Charity_Pro_Switch_Control( $wp_customize, 'raise_charity_pro_theme_options[collection_section_enable]', array(
	'label'             => esc_html__( 'collection Section Enable', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_collection_section',
	'on_off_label' 		=> raise_charity_pro_switch_options(),
) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[collection_section_enable]', array(
		'selector'            => '#products-collection .tooltiptext',
		'settings'            => 'raise_charity_pro_theme_options[collection_section_enable]',
    ) );
}

// collection subtitle setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[collection_subtitle]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['collection_subtitle'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[collection_subtitle]', array(
	'label'           	=> esc_html__( 'Sub Title', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_collection_section',
	'active_callback' 	=> 'raise_charity_pro_is_collection_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[collection_subtitle]', array(
        'selector'            => '#products-collection p.section-subtitle',
        'settings'            => 'raise_charity_pro_theme_options[collection_subtitle]',
        'container_inclusive' => false,
        'fallback_refresh'    => true,
        'render_callback'     => 'raise_charity_pro_collection_subtitle_partial',
    ) );
}

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

$wp_customize->add_control( 'raise_charity_pro_theme_options[collection_title]', array(
	'label'           	=> esc_html__( 'Title', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_collection_section',
	'active_callback' 	=> 'raise_charity_pro_is_collection_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[collection_title]', array(
        'selector'            => '#products-collection h2.section-title',
        'settings'            => 'raise_charity_pro_theme_options[collection_title]',
        'container_inclusive' => false,
        'fallback_refresh'    => true,
        'render_callback'     => 'raise_charity_pro_collection_title_partial',
    ) );
}

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


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

	$wp_customize->add_control( new Raise_Charity_Pro_Dropdown_Taxonomies_Control( $wp_customize,'raise_charity_pro_theme_options[collection_content_product_category_'.$i.']', array(
		'label'             => esc_html__( 'Select collection Category ', 'raise-charity-pro' ).$i,
		'section'           => 'raise_charity_pro_collection_section',
		'taxonomy'			=> 'product_cat',
		'type'              => 'dropdown-taxonomies',
		'active_callback'	=> 'raise_charity_pro_is_collection_section_enable'
	) ) );

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

	$wp_customize->add_control( 'raise_charity_pro_theme_options[collection_banner_title_'.$i.']', array(
		'label'           	=> esc_html__( 'Banner Title ', 'raise-charity-pro' ).$i,
		'section'        	=> 'raise_charity_pro_collection_section',
		'active_callback' 	=> 'raise_charity_pro_is_collection_section_enable',
		'type'				=> 'text',
	) );

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

	$wp_customize->add_control( 'raise_charity_pro_theme_options[collection_button_'.$i.']', array(
		'label'           	=> esc_html__( 'Button Label ', 'raise-charity-pro' ).$i,
		'section'        	=> 'raise_charity_pro_collection_section',
		'active_callback' 	=> 'raise_charity_pro_is_collection_section_enable',
		'type'				=> 'text',
	) );

endfor;
