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

// Add Promotion section
$wp_customize->add_section( 'charity_give_promotion_section', array(
	'title'             => esc_html__( 'Promotion','charity-give' ),
	'description'       => esc_html__( 'Promotion Section options.', 'charity-give' ),
	'panel'             => 'charity_give_front_page_panel',
) );

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

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

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


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

$wp_customize->add_control( 'charity_give_theme_options[promotion_title]', array(
	'label'           	=> esc_html__( 'Title', 'charity-give' ),
	'section'        	=> 'charity_give_promotion_section',
	'active_callback' 	=> 'charity_give_is_promotion_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[promotion_title]',
		array(
			'selector'            => '#charity_give_promotion_section .entry-title',
			'settings'            => 'charity_give_theme_options[promotion_title]',
			'container_inclusive' => false,
			'fallback_refresh'    => true,
			'render_callback'     => 'charity_give_promotion_title_partial',
		)
	);
}


// promotion description setting and control
$wp_customize->add_setting( 'charity_give_theme_options[promotion_description]', array(
	'sanitize_callback' => 'wp_kses_post',
	'default'			=> $options['promotion_description'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'charity_give_theme_options[promotion_description]', array(
	'label'           	=> esc_html__( 'Description', 'charity-give' ),
	'section'        	=> 'charity_give_promotion_section',
	'active_callback' 	=> 'charity_give_is_promotion_section_enable',
	'type'				=> 'textarea',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'charity_give_theme_options[promotion_description]',
		array(
			'selector'            => '#charity_give_promotion_section .entry-content p',
			'settings'            => 'charity_give_theme_options[promotion_description]',
			'container_inclusive' => false,
			'fallback_refresh'    => true,
			'render_callback'     => 'charity_give_promotion_description_partial',
		)
	);
}



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

$wp_customize->add_control( 'charity_give_theme_options[promotion_video_btn_url]',
	array(
		'label'           	=>  esc_html__( 'Video Link Url ', 'charity-give' ),
		'section'        	=> 'charity_give_promotion_section',
		'active_callback' 	=> 'charity_give_is_promotion_section_enable',
		'type'				=> 'url',
	)
);

// promotion image setting and control.
$wp_customize->add_setting( 'charity_give_theme_options[promotion_image]', array(
	'sanitize_callback' => 'charity_give_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'charity_give_theme_options[promotion_image]',
		array(
		'label'       		=> esc_html__( 'Background Image', 'charity-give' ),
		'description' 		=> sprintf( esc_html__( 'Recommended size: %1$dpx x %2$dpx ', 'charity-give' ), 512, 520 ),
		'section'     		=> 'charity_give_promotion_section',
		'active_callback'	=> 'charity_give_is_promotion_section_enable',
) ) );