<?php
/**
 * About Section
 *
 * @package Construktly
 */

$wp_customize->add_section(
	'construktly_about_section',
	array(
		'panel' => 'construktly_front_page_options',
		'title' => esc_html__( 'About Section', 'construktly' ),
	)
);

// About Section - Enable Section.
$wp_customize->add_setting(
	'construktly_enable_about_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'construktly_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Construktly_Toggle_Switch_Custom_Control(
		$wp_customize,
		'construktly_enable_about_section',
		array(
			'label'    => esc_html__( 'Enable About Section', 'construktly' ),
			'section'  => 'construktly_about_section',
			'settings' => 'construktly_enable_about_section',
		)
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'construktly_enable_about_section',
		array(
			'selector' => '#construktly_about_section .section-link',
			'settings' => 'construktly_enable_about_section',
		)
	);
}

// About Section - Section Subtitle.
$wp_customize->add_setting(
	'construktly_about_subtitle',
	array(
		'default'           => __( 'About us', 'construktly' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'construktly_about_subtitle',
	array(
		'label'           => esc_html__( 'Section Subtitle', 'construktly' ),
		'section'         => 'construktly_about_section',
		'settings'        => 'construktly_about_subtitle',
		'type'            => 'text',
		'active_callback' => 'construktly_is_about_section_enabled',
	)
);

// About Section - Content Type.
$wp_customize->add_setting(
	'construktly_about_content_type',
	array(
		'default'           => 'page',
		'sanitize_callback' => 'construktly_sanitize_select',
	)
);

$wp_customize->add_control(
	'construktly_about_content_type',
	array(
		'label'           => esc_html__( 'Select Content Type', 'construktly' ),
		'section'         => 'construktly_about_section',
		'settings'        => 'construktly_about_content_type',
		'type'            => 'select',
		'active_callback' => 'construktly_is_about_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'construktly' ),
			'post' => esc_html__( 'Post', 'construktly' ),
		),
	)
);

// About Section - Content Type Post.
$wp_customize->add_setting(
	'construktly_about_content_post',
	array(
		'sanitize_callback' => 'absint',
	)
);

$wp_customize->add_control(
	'construktly_about_content_post',
	array(
		'section'         => 'construktly_about_section',
		'settings'        => 'construktly_about_content_post',
		'label'           => esc_html__( 'Select Post', 'construktly' ),
		'active_callback' => 'construktly_is_about_section_and_content_type_post_enabled',
		'type'            => 'select',
		'choices'         => construktly_get_post_choices(),
	)
);

// About Section - Content Type Page.
$wp_customize->add_setting(
	'construktly_about_content_page',
	array(
		'sanitize_callback' => 'absint',
	)
);

$wp_customize->add_control(
	'construktly_about_content_page',
	array(
		'label'           => esc_html__( 'Select Page', 'construktly' ),
		'section'         => 'construktly_about_section',
		'settings'        => 'construktly_about_content_page',
		'active_callback' => 'construktly_is_about_section_and_content_type_page_enabled',
		'type'            => 'select',
		'choices'         => construktly_get_page_choices(),
	)
);

// About Section - Button Label.
$wp_customize->add_setting(
	'construktly_about_button_label',
	array(
		'default'           => __( 'Read More', 'construktly' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'construktly_about_button_label',
	array(
		'label'           => esc_html__( 'Button Label', 'construktly' ),
		'section'         => 'construktly_about_section',
		'settings'        => 'construktly_about_button_label',
		'type'            => 'text',
		'active_callback' => 'construktly_is_about_section_enabled',
	)
);
