<?php
/**
 * Mission Section
 *
 * @package Corporaze
 */

$wp_customize->add_section(
	'corporaze_mission_section',
	array(
		'panel'    => 'corporaze_front_page_options',
		'title'    => esc_html__( 'Mission Section', 'corporaze' ),
		'priority' => 40,
	)
);

// Mission Section - Enable Section.
$wp_customize->add_setting(
	'corporaze_enable_mission_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'corporaze_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Corporaze_Toggle_Switch_Custom_Control(
		$wp_customize,
		'corporaze_enable_mission_section',
		array(
			'label'    => esc_html__( 'Enable Mission Section', 'corporaze' ),
			'section'  => 'corporaze_mission_section',
			'settings' => 'corporaze_enable_mission_section',
		)
	)
);

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

// Mission Section - Section Subtitle.
$wp_customize->add_setting(
	'corporaze_mission_subtitle',
	array(
		'default'           => __( 'Our Mission', 'corporaze' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'corporaze_mission_subtitle',
	array(
		'label'           => esc_html__( 'Section Subtitle', 'corporaze' ),
		'section'         => 'corporaze_mission_section',
		'settings'        => 'corporaze_mission_subtitle',
		'type'            => 'text',
		'active_callback' => 'corporaze_is_mission_section_enabled',
	)
);

// Mission Section - Content Type.
$wp_customize->add_setting(
	'corporaze_mission_content_type',
	array(
		'default'           => 'page',
		'sanitize_callback' => 'corporaze_sanitize_select',
	)
);

$wp_customize->add_control(
	'corporaze_mission_content_type',
	array(
		'label'           => esc_html__( 'Select Content Type', 'corporaze' ),
		'section'         => 'corporaze_mission_section',
		'settings'        => 'corporaze_mission_content_type',
		'type'            => 'select',
		'active_callback' => 'corporaze_is_mission_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'corporaze' ),
			'post' => esc_html__( 'Post', 'corporaze' ),
		),
	)
);

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

$wp_customize->add_control(
	'corporaze_mission_content_post',
	array(
		'section'         => 'corporaze_mission_section',
		'settings'        => 'corporaze_mission_content_post',
		'label'           => esc_html__( 'Select Post', 'corporaze' ),
		'active_callback' => 'corporaze_is_mission_section_and_content_type_post_enabled',
		'type'            => 'select',
		'choices'         => corporaze_get_post_choices(),
	)
);

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

$wp_customize->add_control(
	'corporaze_mission_content_page',
	array(
		'label'           => esc_html__( 'Select Page', 'corporaze' ),
		'section'         => 'corporaze_mission_section',
		'settings'        => 'corporaze_mission_content_page',
		'active_callback' => 'corporaze_is_mission_section_and_content_type_page_enabled',
		'type'            => 'select',
		'choices'         => corporaze_get_page_choices(),
	)
);

// Mission Section - Button Label.
$wp_customize->add_setting(
	'corporaze_mission_button_label',
	array(
		'default'           => __( 'Explore More', 'corporaze' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'corporaze_mission_button_label',
	array(
		'label'           => esc_html__( 'Button Label', 'corporaze' ),
		'section'         => 'corporaze_mission_section',
		'settings'        => 'corporaze_mission_button_label',
		'type'            => 'text',
		'active_callback' => 'corporaze_is_mission_section_enabled',
	)
);
