<?php 
/**
 * Fields for color options
 * @since 1.0
 * @package RoyalNews
 */

function royalnews_customizer_slider( $section ){
	if( class_exists( 'Kirki' ) ){
		$royalnews_cat = Kirki_Helper::get_terms( 'category' );
		$royalnews_cat[ 0 ] = esc_html__( 'All', 'royalnews' );
	}else{
		$royalnews_cat = array();
	}

	$section[ 'slider_options' ] = array(
		'title' => esc_html__( 'Home Page - Slider/Post Options', 'royalnews' ),
		'priority'    => 20,
		'fields' => array(
			'enable_slider' => array(
				'type' => 'toggle',
				'label' => esc_html__( 'Slider Options', 'royalnews' ),
				'default' => true,
				'priority' => 10,
			),
			'slider_category' => array(
				'type' => 'select',
				'label' => esc_html__( 'Select Category For Slider', 'royalnews' ),
				'default' => '0',
				'priority' => 20,
				'choices' => $royalnews_cat,
				'active_callback' => array(
					array(
						'setting' => 'enable_slider',
						'operator' => '==',
						'value' => true,
					)
				),
			),
			'post_category' => array(
				'type' => 'select',
				'label' => esc_html__( 'Select Category For Post', 'royalnews' ),
				'default' => '0',
				'priority' => 20,
				'description' => esc_html__( 'Only for recent post will be displayed', 'royalnews' ),
				'choices' => $royalnews_cat,
				'active_callback' => array(
					array(
						'setting' => 'enable_slider',
						'operator' => '==',
						'value' => true,
					)
				),
			),
		)
	);
	return $section;
}

add_filter( 'royalnews_customizer_theme_option_panel', 'royalnews_customizer_slider' );