<?php
/**
 * gallery Section options
 *
 * @package Theme Palace
 * @subpackage Charity Give
 * @since Charity Give 1.0.0
 */

// Add Product section
$wp_customize->add_section( 'charity_give_gallery_section',
	array(
		'title'             => esc_html__( 'Gallery','charity-give' ),
        'panel'       		=> 'charity_give_front_page_panel',
	)
);

// Product content enable control and setting
$wp_customize->add_setting( 'charity_give_theme_options[gallery_section_enable]',
	array(
		'default'			=> 	$options['gallery_section_enable'],
		'sanitize_callback' => 'charity_give_sanitize_switch_control',
	)
);

$wp_customize->add_control( new Charity_Give_Switch_Control( $wp_customize,
	'charity_give_theme_options[gallery_section_enable]',
		array(
			'label'             => esc_html__( 'Gallery Section Enable', 'charity-give' ),
			'section'           => 'charity_give_gallery_section',
			'on_off_label' 		=> charity_give_switch_options(),
		)
	)
);

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

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

$wp_customize->add_control( 'charity_give_theme_options[gallery_title]',
	array(
		'label'           	=> esc_html__( 'Section Title', 'charity-give' ),
		'section'        	=> 'charity_give_gallery_section',
		'active_callback' 	=> 'charity_give_is_gallery_section_enable',
		'type'				=> 'text',
	)
);


// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'charity_give_theme_options[gallery_title]',
		array(
			'selector'            => '#charity_give_gallery_section .section-title',
			'settings'            => 'charity_give_theme_options[gallery_title]',
			'container_inclusive' => false,
			'fallback_refresh'    => true,
			'render_callback'     => 'charity_give_gallery_title_partial',
		)
	);
}

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

$wp_customize->add_control( 'charity_give_theme_options[gallery_sub_title]',
	array(
		'label'           	=> esc_html__( 'Section Sub Title', 'charity-give' ),
		'section'        	=> 'charity_give_gallery_section',
		'active_callback' 	=> 'charity_give_is_gallery_section_enable',
		'type'				=> 'text',
	)
);


// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'charity_give_theme_options[gallery_sub_title]',
		array(
			'selector'            => '#charity_give_gallery_section .section-subtitle',
			'settings'            => 'charity_give_theme_options[gallery_sub_title]',
			'container_inclusive' => false,
			'fallback_refresh'    => true,
			'render_callback'     => 'charity_give_gallery_sub_title_partial',
		)
	);
}

// Add dropdown category setting and control.
$wp_customize->add_setting(  'charity_give_theme_options[gallery_category]', array(
	'sanitize_callback' => 'charity_give_sanitize_single_category',
	) ) ;

$wp_customize->add_control( new Charity_Give_Dropdown_Taxonomies_Control( $wp_customize,'charity_give_theme_options[gallery_category]', array(
	'label'             => esc_html__( 'Select Category', 'charity-give' ),
	'description'      	=> esc_html__( 'Note: Latest selected no of posts will be shown from selected category', 'charity-give' ),
	'section'           => 'charity_give_gallery_section',
	'type'              => 'dropdown-taxonomies',
	'active_callback'	=> 'charity_give_is_gallery_section_enable'
	) ) );

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

$wp_customize->add_control( 'charity_give_theme_options[gallery_btn_title]',
	array(
		'label'           	=> esc_html__( 'Button Label ', 'charity-give' ),
		'section'        	=> 'charity_give_gallery_section',
		'active_callback' 	=>  function( $control) {
			return (
				charity_give_is_gallery_section_enable( $control )
			);
		},
		'type'				=> 'text',
	)
);


// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'charity_give_theme_options[gallery_btn_title]',
		array(
			'selector'            => '#charity_give_gallery_section .read-more .btn',
			'settings'            => 'charity_give_theme_options[gallery_btn_title]',
			'container_inclusive' => false,
			'fallback_refresh'    => true,
			'render_callback'     => 'charity_give_gallery_btn_title_partial',
		)
	);
}

$wp_customize->add_setting( 'charity_give_theme_options[gallery_btn_url]',
    array(
        'sanitize_callback' => 'esc_url_raw',
    )
);

$wp_customize->add_control( 'charity_give_theme_options[gallery_btn_url]',
    array(
        'label'           	=> esc_html__( 'Button URL', 'charity-give' ),
        'section'        	=> 'charity_give_gallery_section',
        'active_callback' 	=>  function( $control) {
			return (
				charity_give_is_gallery_section_enable( $control )
			);
		},
        'type'				=> 'url',
    ) 
);