<?php
/**
 * About Section options
 *
 * @package Theme Palace
 * @subpackage Raise Charity Pro
 * @since Raise Charity Pro 1.0.0
 */

// Add About section
$wp_customize->add_section( 'raise_charity_pro_about_section', array(
	'title'             => esc_html__( 'About Us','raise-charity-pro' ),
	'description'       => esc_html__( 'About Us Section options.', 'raise-charity-pro' ),
	'panel'             => 'raise_charity_pro_front_page_panel',
) );

// About content enable control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_section_enable]', array(
	'default'			=> 	$options['about_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[about_section_enable]', array(
	'label'             => esc_html__( 'About Section Enable', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_about_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[about_section_enable]', array(
		'selector'            => '#about-section .tooltiptext',
		'settings'            => 'raise_charity_pro_theme_options[about_section_enable]',
    ) );
}

if( $options['home_layout'] !== 'sixth-design' ):
// about sub title setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_information_text]', array(
	'sanitize_callback' => 'wp_kses_post',
	'default'			=> $options['about_information_text'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_information_text]', array(
	'label'           	=> esc_html__( 'Information Text', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_about_section',
	'active_callback' 	=> 'raise_charity_pro_is_about_section_enable',
	'type'				=> 'textarea',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[about_information_text]', array(
		'selector'            => '#about-section div.info-wrapper',
		'settings'            => 'raise_charity_pro_theme_options[about_information_text]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'raise_charity_pro_about_information_text_partial',
    ) );
}
endif;

// long Excerpt length setting and control.
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_excerpt_length]', array(
	'sanitize_callback' => 'raise_charity_pro_sanitize_number_range',
	'validate_callback' => 'raise_charity_pro_validate_long_excerpt',
	'default'			=> $options['about_excerpt_length'],
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_excerpt_length]', array(
	'label'       		=> esc_html__( 'About Excerpt Length', 'raise-charity-pro' ),
	'description' 		=> esc_html__( 'Total description words to be displayed in about posts.', 'raise-charity-pro' ),
	'section'     		=> 'raise_charity_pro_about_section',
	'active_callback' 	=> 'raise_charity_pro_is_about_section_enable',
	'type'        		=> 'number',
	'input_attrs' 		=> array(
		'style'       => 'width: 80px;',
		'max'         => 100,
		'min'         => 5,
	),
) );

// About content type control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_content_type]', array(
	'default'          	=> $options['about_content_type'],
	'sanitize_callback' => 'raise_charity_pro_sanitize_select',
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_content_type]', array(
	'label'             => esc_html__( 'Content Type', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_about_section',
	'type'				=> 'select',
	'active_callback' 	=> 'raise_charity_pro_is_about_section_enable',
	'choices'			=> array( 
		'page' 		=> esc_html__( 'Page', 'raise-charity-pro' ),
		'post' 		=> esc_html__( 'Post', 'raise-charity-pro' ),
		'custom' 	=> esc_html__( 'Custom', 'raise-charity-pro' ),
	),
) );

// about pages drop down chooser control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_content_page]', array(
	'sanitize_callback' => 'raise_charity_pro_sanitize_page',
) );

$wp_customize->add_control( new Raise_Charity_Pro_Dropdown_Chooser( $wp_customize, 'raise_charity_pro_theme_options[about_content_page]', array(
	'label'             => esc_html__( 'Select Page', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_about_section',
	'choices'			=> raise_charity_pro_page_choices(),
	'active_callback'	=> 'raise_charity_pro_is_about_section_content_page_enable',
) ) );

// about posts drop down chooser control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_content_post]', array(
	'sanitize_callback' => 'raise_charity_pro_sanitize_page',
) );

$wp_customize->add_control( new Raise_Charity_Pro_Dropdown_Chooser( $wp_customize, 'raise_charity_pro_theme_options[about_content_post]', array(
	'label'             => esc_html__( 'Select Post', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_about_section',
	'choices'			=> raise_charity_pro_post_choices(),
	'active_callback'	=> 'raise_charity_pro_is_about_section_content_post_enable',
) ) );

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

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

// about description setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_description]', array(
	'sanitize_callback' => 'wp_kses_post',
	'default'			=> $options['about_description'],
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_description]', array(
	'label'           	=> esc_html__( 'Description', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_about_section',
	'active_callback' 	=> 'raise_charity_pro_is_about_section_content_custom_enable',
	'type'				=> 'textarea',
) );

// about image setting and control.
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_image]', array(
	'sanitize_callback' => 'raise_charity_pro_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'raise_charity_pro_theme_options[about_image]',
		array(
		'label'       		=> esc_html__( 'Image', 'raise-charity-pro' ),
		'section'     		=> 'raise_charity_pro_about_section',
		'active_callback'	=> 'raise_charity_pro_is_about_section_content_custom_enable',
) ) );

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

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_btn_title]', array(
	'label'           	=> esc_html__( 'Button Label', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_about_section',
	'active_callback' 	=> 'raise_charity_pro_is_about_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[about_btn_title]', array(
		'selector'            => '#about-section div.read-more a',
		'settings'            => 'raise_charity_pro_theme_options[about_btn_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'raise_charity_pro_about_btn_title_partial',
    ) );
}

// about btn link setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[about_btn_link]', array(
	'sanitize_callback' => 'esc_url_raw',
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[about_btn_link]', array(
	'label'           	=> esc_html__( 'Button Link', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_about_section',
	'active_callback' 	=> 'raise_charity_pro_is_about_section_content_custom_enable',
	'type'				=> 'url',
) );