<?php
/**
 * Events Section
 *
 * @package events_and_celebrations
 */

 $wp_customize->add_section(
	'events_and_celebrations_services_section',
	array(
		'panel'    => 'events_and_celebrations_front_page_options',
		'title'    => esc_html__( 'Our Events Section', 'events-and-celebrations' ),
		'priority' => 10,
	)
);

//Events Section - Enable Section.
$wp_customize->add_setting(
	'events_and_celebrations_enable_services_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'events_and_celebrations_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Events_And_Celebrations_Toggle_Switch_Custom_Control(
		$wp_customize,
		'events_and_celebrations_enable_services_section',
		array(
			'label'    => esc_html__( 'Enable Events Section', 'events-and-celebrations' ),
			'section'  => 'events_and_celebrations_services_section',
			'settings' => 'events_and_celebrations_enable_services_section'
		)
	)
);

// Partial Refresh
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'events_and_celebrations_enable_services_section',
		array(
			'selector' => '#events_and_celebrations_services_section .section-link',
			'settings' => 'events_and_celebrations_enable_services_section',
		)
	);
}

// Background decorative heading text.
$wp_customize->add_setting(
	'events_and_celebrations_services_bg_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'events_and_celebrations_services_bg_heading',
	array(
		'label'           => esc_html__( 'Section Sub-Title', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_services_section',
		'type'            => 'text',
		'active_callback' => 'events_and_celebrations_is_services_section_enabled',
	)
);

// Section title (new standalone setting; falls back to trending_post_content if empty).
$wp_customize->add_setting(
	'events_and_celebrations_services_section_title',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'events_and_celebrations_services_section_title',
	array(
		'label'           => esc_html__( 'Section Title (Heading)', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_services_section',
		'type'            => 'text',
		'active_callback' => 'events_and_celebrations_is_services_section_enabled',
	)
);

// Number of event posts to show.
$wp_customize->add_setting(
	'events_and_celebrations_services_posts_count',
	array(
		'default'           => 4,
		'sanitize_callback' => 'events_and_celebrations_sanitize_range_value',
	)
);

$wp_customize->add_control(
	'events_and_celebrations_services_posts_count',
	array(
		'label'           => esc_html__( 'Events Post Count', 'events-and-celebrations' ),
		'section'         => 'events_and_celebrations_services_section',
		'type'            => 'number',
		'input_attrs'     => array(
			'min'  => 1,
			'max'  => 12,
			'step' => 1,
		),
		'active_callback' => 'events_and_celebrations_is_services_section_enabled',
	)
);

// Select category for events posts.
$wp_customize->add_setting(
	'events_and_celebrations_services_category',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	new Events_And_Celebrations_Customize_Category_Dropdown_Control(
		$wp_customize,
		'events_and_celebrations_services_category',
		array(
			'label'           => esc_html__( 'Select Category', 'events-and-celebrations' ),
			'section'         => 'events_and_celebrations_services_section',
			'settings'        => 'events_and_celebrations_services_category',
			'active_callback' => 'events_and_celebrations_is_services_section_enabled',
		)
	)
);