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

$wp_customize->add_section(
	'corporaze_cta_section',
	array(
		'panel'    => 'corporaze_front_page_options',
		'title'    => esc_html__( 'CTA Section', 'corporaze' ),
		'priority' => 70,
	)
);

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

$wp_customize->add_control(
	new Corporaze_Toggle_Switch_Custom_Control(
		$wp_customize,
		'corporaze_enable_cta_section',
		array(
			'label'    => esc_html__( 'Enable CTA Section', 'corporaze' ),
			'section'  => 'corporaze_cta_section',
			'settings' => 'corporaze_enable_cta_section',
		)
	)
);

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

// CTA Section - Section Title.
$wp_customize->add_setting(
	'corporaze_cta_title',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'corporaze_cta_title',
	array(
		'label'           => esc_html__( 'Section Title', 'corporaze' ),
		'section'         => 'corporaze_cta_section',
		'settings'        => 'corporaze_cta_title',
		'type'            => 'text',
		'active_callback' => 'corporaze_is_cta_section_enabled',
	)
);

// CTA Section - Section Text.
$wp_customize->add_setting(
	'corporaze_cta_text',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'corporaze_cta_text',
	array(
		'label'           => esc_html__( 'Section Text', 'corporaze' ),
		'section'         => 'corporaze_cta_section',
		'settings'        => 'corporaze_cta_text',
		'type'            => 'text',
		'active_callback' => 'corporaze_is_cta_section_enabled',
	)
);

// CTA Section - Background Image.
$wp_customize->add_setting(
	'corporaze_cta_background_image',
	array(
		'sanitize_callback' => 'corporaze_sanitize_image',
	)
);

$wp_customize->add_control(
	new WP_Customize_Image_Control(
		$wp_customize,
		'corporaze_cta_background_image',
		array(
			'label'           => esc_html__( 'Background Image', 'corporaze' ),
			'section'         => 'corporaze_cta_section',
			'settings'        => 'corporaze_cta_background_image',
			'active_callback' => 'corporaze_is_cta_section_enabled',
		)
	)
);

// CTA Section - Button Label.
$wp_customize->add_setting(
	'corporaze_cta_button_label',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'corporaze_cta_button_label',
	array(
		'label'           => esc_html__( 'Button Label', 'corporaze' ),
		'section'         => 'corporaze_cta_section',
		'settings'        => 'corporaze_cta_button_label',
		'type'            => 'text',
		'active_callback' => 'corporaze_is_cta_section_enabled',
	)
);

// CTA Section - Button Link.
$wp_customize->add_setting(
	'corporaze_cta_button_link',
	array(
		'default'           => '',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	'corporaze_cta_button_link',
	array(
		'label'           => esc_html__( 'Button Link', 'corporaze' ),
		'section'         => 'corporaze_cta_section',
		'settings'        => 'corporaze_cta_button_link',
		'type'            => 'url',
		'active_callback' => 'corporaze_is_cta_section_enabled',
	)
);
